[SDL] Why not nanosleep()?

Daniel Vogel 666 at grafzahl.de
Mon Apr 3 07:09:53 PDT 2000


Christian Bauer wrote:
> 
> Hi!
> 
> On Mon, 3 Apr 2000, Maxim Sobolev wrote:
> > I'm wondering why the SDL library doesn't use POSIX conformant nanosleep()
> > function in its SDL_Delay() routine. Currently select() used for this purpose,
> 
> I also wondered a while ago and tried to replace the select() with
> nanosleep() and usleep(). The result: under Linux 2.2.x, the select()
> timeout seems to have a far higher accuracy and resolution than *sleep(),
> e.g. nanosleep(3ms) on my machine usually waits for about 20-30ms,
> sometimes 14-16ms, while select() is relatively constant at ~3ms.

I did a 1000 x 1 ms sleep with 'sleep' == usleep it took 20 secs and
with select only 10. Then I did try a 100x 10 ms sleep and it took 2
seconds with select. Looks as if select takes about 10ms more than I
want :( Well, at least it performs better than usleep.


-- 
Daniel Vogel                           My opinions may have changed,
666 @ http://grafzahl.de               but not the fact that I am right



More information about the SDL mailing list