in reply to Efficient Daemon Looping?

Unless some external event can signal your process directly, sleep() is about as efficient as it gets. You should tune your sleep durations to be as long as acceptable, but really, the CPU won't waste the effort to give your process a second thought until the sleeping time elapses. (Sleep is NOT equivalent to 1 while (time < wakeup);)

--
[ e d @ h a l l e y . c c ]

Replies are listed 'Best First'.
Re: Re: Efficient Daemon Looping?
by pbeckingham (Parson) on Mar 19, 2004 at 16:32 UTC

    You make a very good point. It is a common misconception that sleep is unduly expensive.

    This sounds like a good candidate for a FAQ, even though it's not A'd very F.

Re: Re: Efficient Daemon Looping?
by kesterkester (Hermit) on Mar 19, 2004 at 16:50 UTC
    Great, thanks much!