This is the mail archive of the cygwin mailing list for the Cygwin project.


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]
Other format: [Raw text]

Re: milliseconds on Windows


Robert D. Holtz - Lists wrote:
>> Hello Brian,
> 
> http://cygwin.com/acronyms/#PPIOSPE
> 
> 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:      http://cygwin.com/ml/#unsubscribe-simple
Problem reports:       http://cygwin.com/problems.html
Documentation:         http://cygwin.com/docs.html
FAQ:                   http://cygwin.com/faq/


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]