[SDL] framerate counter

Sam Lantinga slouken at devolution.com
Wed Apr 4 12:27:42 PDT 2001

> This is one reason my code only works on Windows and Linux, but with
> SDL_Delay so coarse I have no choice.

Foo.  SDL_Delay is implemented on UNIX using select()
The timer resolution is based on the kernel scheduling resolution, not
anything inherent in the calls being made.  usleep() has the same resolution,
and is implemented with select() as well.

>From the nanosleep man page:

       The current implementation of nanosleep is  based  on  the
       normal  kernel  timer mechanism, which has a resolution of
       1/HZ s (i.e, 10 ms on Linux/i386 and 1 ms on Linux/Alpha).
       Therefore, nanosleep pauses always for at least the speci-
       fied time, however it can take up to  10  ms  longer  than
       specified  until  the  process becomes runnable again. For
       the same reason, the value returned in case of a delivered
       signal  in *rem is usually rounded to the next larger mul-
       tiple of 1/HZ s.

David, you don't need to reply. :)

See ya!
	-Sam Lantinga, Lead Programmer, Loki Entertainment Software

More information about the SDL mailing list