[SDL] Why not nanosleep()?
666 at grafzahl.de
Mon Apr 3 09:48:25 PDT 2000
Mattias Engdegård wrote:
> On Linux, select() and usleep() have a 10ms granularity, but usleep
> often overshoots by up to 10ms since it has to sleep at least the
> asked amount, not less. If you usleep() near the end of a tick, the delay
> will be closer to what you asked for, but I presume your test program
> did it just after the beginning of a tick.
> (Except on Alpha, where a tick = 1/1024 s.)
Thanks for the info. I knew that nanosleep had this granularity but
didn't know about usleep. Why isn't that in the man pages??? Well,
browsing the glibc source usleep calls nanosleep so that explains the
10ms granularity for usleep.
> I don't think SDL_Delay should busy-wait (often you delay to let other
> threads run), so nanosleep() is out. We could provide a SDL_BusyWait(),
> but the implementation is so trivial there's little point.
Yes, most of the time you call delay to give other tasks like input/
event handling some time to gather/ process them. I don't see why
anybody would want a busy wait with ms granularity except for driver
Daniel Vogel My opinions may have changed,
666 @ http://grafzahl.de but not the fact that I am right
More information about the SDL