milliseconds on Windows

Tim Prince
Wed Oct 24 01:09:00 GMT 2007

Robert D. Holtz - Lists wrote:
>> Hello Brian,
> I've redirected this message and set the Reply-To appropriately.
>> I'm a student at Bonn university and I'm researching robotics. I'm trying
>> to write a robot controller for Windows XP (wasn't my choice!) and
>> measuring elapsed time down to milliseconds precision is crucial. Do you
>> happen to remember this discussion on the cygwin mailing list?

>> So if you know how to measure 1ms (less would be even better) on Win XP,
>> can you please tell me how to do that?
> If you're feeling frisky it's also possible to write a low level routine
> that hooks the hardware clock and uses it for retrieving the time.
> This clock does go down to microsecond granularity.
As gcc hasn't implemented the Microsoft style __rdtsc() intrinsic, we
use routinely the usual gcc 32-bit-only stuff:

unsigned long long int rdtsc( )
   long long a;
   asm volatile("rdtsc":"=A" (a));
   return a;

which gives you a number of CPU clock ticks (on current platforms,
typically derived from the buss clock and nominal CPU clock speed ratio).

Unsubscribe info:
Problem reports:

More information about the Cygwin mailing list