[Top][All Lists]

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: Higher resolution timers

From: Vesa Jääskeläinen
Subject: Re: Higher resolution timers
Date: Sat, 24 May 2008 18:25:06 +0300
User-agent: Thunderbird (Windows/20080421)

Marco Gerards wrote:
Hi Colin,

Colin D Bennett <address@hidden> writes:
What would be the best way to do this? Possibilities that I am aware of
are: * RDTSC instruction (must calibrate with RTC at startup?)
 * HPET (complex to use?)
 * RTC (can we set the timer interrupt rate to >18 Hz?)

Does anyone have any thoughts on these options?

I think that using the TSC (w/ RDTSC instruction) and calibrating it
with a quick 2-3 RTC tick loop at startup might be the easiest option.

Only something that really returns a time seems like a good choise to
me.  AFAIK RDTSC returns clock cycles that passed since the system was
switched on.  This means that code will run faster on a processor with
a higher clock speed.  Am I mistaken?

That's way you calibrate it :) Then you can get pretty good accuracy :)

So I prefer something that can be used to wait a microsecond and not a
certain amount of clock cycles.  Using the RTC seems a good choice,
but we have to keep in mind the BIOS uses it as well.

Default rate for RTC is bad for any accuracy. At least in this case.

Isn't HPET only available on newer processors?


But the idea is to use best possible resolution available. So if choice A is not there then fallback for choice B. Of course in some cases animation will not be so smooth. But at least it will work.

reply via email to

[Prev in Thread] Current Thread [Next in Thread]