Subject: Re: Problem with clock_gettime()
To: None <>
From: None <>
List: tech-kern
Date: 11/24/2003 05:52:45 (Ian McIntosh) writes:
> When doing this I have noticed some strange behaviour
> with clock_gettime(). I can call clock_gettime() and 
> store the result in a temporary variable and then 
> when I call it again the time returned is before 
> the time in the temporary variable (indicating that 
> time has gone backwards????). 

This is an old problem.  PR 14100  (and probably others)

As an aside, if you need to measure delay-time you probably want to
use the TSC if you have one in your processor.  You get much finer
granularity time in units of your processor's internal clock speed.
(eg. 3.2 Ghz clock ticks on a 3.2Ghz CPU.)

 /* x86 stub for reading the CPU's tick counter */

 typedef unsigned long long u64;

 inline          u64
     u64             ticks;
     asm             volatile("rdtsc":"=A"(ticks));
     return ticks;

Wolfgang S. Rupprecht
       The above "From:" address is valid.  Don't mess with it.