[SDL] Re: Why not nanosleep()?
pphaneuf at sx.nec.com
Tue Apr 4 08:19:54 PDT 2000
Daniel Vogel wrote:
> > Huh. What's the resolution of the internal Pentium timers? It's gotta be
> > better than SDL's current resolution, and if that's really important, we
> > could go that route and start doing things that way. I have improved
> > resolution timer code for both x86 Pentium machines and Mac PPCs, if
> > anybody wants.
> That would result in a 'busy wait'... The trick is you want the system
> to suspend your task for the time you sleep so we can't change code in
> SDL to achieve this :) One thing that could be done is that when the
> argument to sleep is less than 10ms (on i386) it could do a busy wait,
> but I don't think this would be a good idea...
Hmm, BTW, while I agree that using the internal Pentium timer for a
timer would result in a busy-wait (bad), it would be very interesting to
have a portable SDL_GetTime() function (if there isn't already one) that
uses a bit of assembler to grab the internal Pentium timer (or the
equivalent on other platforms), with a fallback on gettimeofday(). The
advantage would be in avoiding a system call. With the typical use of
"gettime()"-type functions, this would be a very useful saving I think.
More information about the SDL