[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
Re: Short sleeps.
Mark Collins wrote:
>
> On Friday 11 January 2002 12:59 am, you wrote:
> <snip>
>
> I'm not sure about LInux, but I'm sure it has an equivilent to this:
>
> ====
> perf_freq = QueryPerformanceFrequency();
>
> start_time = QueryPerformanceTimer()/perf_freq;
>
> while ((end_time - start_time) > delay) {
> end_time = QueryPerformanceTimer()/perf_freq;
> }
> =====
>
> Where the QueryPerformanceTimer() function is a high-resolution clock I
> can't find details about the Linux equiv, but surely it exists?
Yes - sure there is an equivelant - but that's a busy-wait which
prevents other processes from running - something that I explicitly
wish to avoid.
Linux's nanosleep() will do busy-waits for up to 2 milliseconds - or
you can do as you did by looping on gettimeofday or something and get
microsecond precision busy-waits.
However, I want to actually give up the CPU while I'm waiting.
----------------------------- Steve Baker -------------------------------
Mail : <sjbaker1@airmail.net> WorkMail: <sjbaker@link.com>
URLs : http://www.sjbaker.org
http://plib.sf.net http://tuxaqfh.sf.net http://tuxkart.sf.net
http://prettypoly.sf.net http://freeglut.sf.net
http://toobular.sf.net http://lodestone.sf.net