Subject: Re: microtime
To: David Laight <david@l8s.co.uk>
From: Erik E. Fair <fair@clock.org>
List: tech-kern
Date: 08/21/2002 06:08:04
Beware. The Time Of Day (TOD) and interval time are not the same thing.
At the end of each June and December, the International Earth
Rotation Service (IERS) can declare a "leap second" to be added or
deleted from UTC, resulting in 23:59:60 or an apparent jump from
23:59:58 to 00:00:00.
UNIX has traditionally kept Greenwich Mean Time (GMT, the precessor
to UTC) in the kernel for TOD, and converted all printed timestamps
to local time zone in routines found in libc (e.g. ctime(3)). V7 UNIX
even had the local time zone offset from GMT in the kernel, too, but
that was just a convenient place to store it so that libraries and
applications could get it.
The NTP daemon makes constant adjustments to the TOD on the systems
where it is running (mostly by speeding up or slowing down the
counting of clock ticks, as deeemed necessary by the calculation of
the drift of the local system clock against reference time servers
out on the Internet), to keep the value returned by gettimeofday(2)
as accurate as possible.
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.
Dr. David Mills, inventor of NTP (among many other things) has said
that it is very important for OS designers and application
programmers to keep TOD and interval time separate (and be clear on
which one you want at any given point), because they have, at best, a
weak link.
this moment in time brought to you by,
Erik <fair@clock.org>