in reply to Re: Wakeup: event-loop system
in thread Wakeup: event-loop system

Thank you! Sleep 1 has decreased about 50% of clock consumption.
Do you think the code is ok now?

Replies are listed 'Best First'.
Re^3: Wakeup: event-loop system
by GrandFather (Saint) on Mar 01, 2009 at 19:00 UTC

    A similar solution is required fro your second loop - put a sleep in it. As it stands the loop will run just as fast as it can output stuff with print. That will be slower than an empty loop, but still pretty fast.

    Another issue is that there is no way of stopping the 'alarm' loop. At the very least you should replace the while (1) with a down counter so it stops by itself eventually.


    True laziness is hard work