[SDL] Why not nanosleep()?

Loren Osborn sondheim at mail.lokigames.com
Tue Apr 4 11:46:48 PDT 2000


> 
> > Loren Osborn wrote:
> 
> > > The problem is that sleep(0) isn't as predictable/portable as we might
> > > hope... If I remember correctly from FileNET, something like this works
> > > reasonably well on WinNT, but I wouldn't trust it on Linux.
> 
> > The sleep(0) works okay on Linux (we use it in Quadra). In Windows, it
> > is Sleep(0) you have to use (damn Win32, why the useless
> > difference???)...
> 
> sleep() sleeps seconds
> Sleep() sleeps milliseconds
> 
> 	-Sam Lantinga, Lead Programmer, Loki Entertainment Software
> 

Just to clarify:  Yes, 0 seconds == 0 milliseconds == 0 microseconds!

On WinNT Sleep(0) acts as a sort of "process yeild" letting other processes
use CPU time if they need it, but returning control to the calling process
at earliest convienience.  What sleep(0) or usleep(0) do in Unix/Linux I'm
not so sure of... (May yeild... may act as NOP... haven't tried it...)

Regards,

-Loren




More information about the SDL mailing list