Subject: Re: Avoiding microtime(9) global state
To: Erik E. Fair <email@example.com>
From: David Laight <firstname.lastname@example.org>
Date: 06/30/2004 22:42:50
On Wed, Jun 30, 2004 at 01:19:44PM -0700, Erik E. Fair wrote:
> It's very important to separate Time of Day from interval timing.
> Time of Day you adjust to be correct with NTP, or just with date(1),
> so that when you want to record the time that an event occurred, you
> take this value.
> Interval timing is to measure between a start point and a stop point.
> You never want this going backwards. Principally, you want the
> frequency of the counter to be accurate, so you might adjust how fast
> it's ticking, once you figure out (with NTP or some other method) how
> bad your system's clock crystal is.
> NetBSD should provide both facilities (ToD & interval time), and the
> code we write needs to be clear about which it is using and why.
Yes, the problem at the moment is that microtime() is used as an
interval time (eg in mi_switch() to calculate the length of time
a program has run for), but is actually wall-clock time and subject
to be changed by date(1) - there is a fudge at startup and at least
one XXX in kern_time.c.
The cost of adding a local epoch to 'system time' in order to generate
'wall clock' (UTC) time is minimal- especially if you can manage with
1 second accuracy on the epoch.
date(1) (et al) would change the epoch for large changes, and drift the
counter frequency for small changes.
If a trawl of all the timer uses is needed, doing that as well should
David Laight: email@example.com