[SDL] SDL_Delay() granularity

Ryan C. Gordon icculus at clutteredmind.org
Wed Jul 10 22:43:01 PDT 2002


> Is SDL_Delay() on Linux limited to a granularity of 10 ms?  I could have
> sworn that previously I was able to ask for and get delays of less than
> 10 ms, but playing with testgl.c I observe that the delay is always 10,
> 20, ... ms.  Is my memory playing up again?

10 is the minimum, without the aid of a Real Time kernel. Don't use
SDL_Delay in loops that need to pause for explicit amounts of time, since
even without the 10 ms minimum, you aren't guaranteed to get an exact
amount...well, with preemptive multitasking you aren't anyhow, but if you
only need to delay for a few milliseconds, hog the CPU in a busy-loop and
keep checking the current time until you have waited as long as you like.

--ryan.







More information about the SDL mailing list