Subject: Re: microtime
To: <>
From: David Laight <david@l8s.co.uk>
List: tech-kern
Date: 08/21/2002 23:46:20
On Wed, Aug 21, 2002 at 06:08:04AM -0700, Erik E. Fair wrote:
> 
> Thus, taking a TOD timestamp, doing something, taking another TOD 
> timestamp, and subtracting may not give you an accurate measurement 
> of the *interval* between those two timestamps, if the TOD has been 
> adjusted in between.

I did wonder how to solve this - without duplicating loads of code.

For 'interval' times (especially short ones) it is probably best
to assume that the system clock is accurate.
For long times and times requested as 'absolute' then you need
'real time'.

Unfortunately very few of the interfaces are completely clear
as to what is required.  Made all the harder by the effect of
putting a system to sleep/suspend.

What I wondered is whether it would be better to save a 'boot time'
and a 'system clock ticks since boot'.  Adjustments by NTP (and other
date setting facilities) would adjust the former, leaving the
latter definitely monatonic.
(probably worth using 64bit usec counts for both values).

The residual 'microtime going backwards' errors could be down
to NTP playing with the time.

	David

-- 
David Laight: david@l8s.co.uk