Time Library Organisation
Marcin 'Qrczak' Kowalczyk
qrczak at knm.org.pl
Thu Jan 27 15:40:05 EST 2005
Aaron Denney <wnoise at ofb.net> writes:
>>>> DJB (the author of libtai) disagrees with POSIX about what
>>>> gettimeofday should return, and assumes that it actually returns
>>>> what he wishes it returned.
> More accurately, he expects admins to set it to TAI, and not run
> programs that set it to other than non-TAI.
Does he propose a way for programs to discover whether the system
clock is TAI or UTC?
Does he provide an NTP client which works when it's TAI?
It would still not solve the problem of programs which assume that
it's UTC like POSIX says. In particular it breaks gmtime() in the C
library, it breaks implementations of Java (no matter whether they
use gmtime() or reimplement it themselves) etc.
> It'd be convenient if there were, say, environment variables defined for
> this purpose. (Or another convenient system. A file would be fine too,
> but I think environment variable would involve the least overhead.)
A correct long-term solution should allow both conventions to coexist,
without changing the behavior of an existing standarized API. I prefer
to have a system which slows down for a second when leap seconds are
announced, than to have a system where all the time different programs
have different ideas about the current time.
For example there would be new syscalls for TAI time; a new kernel
would treat the hardware clock as TAI and compute UTC from this when
a process asks for gettimeofday (which is more accurate than the other
direction); glibc would nevertheless translate in the other direction
when run on an old kernel, so programs would work at all; and there
would be a central place to keep the leap second table, with a special
program to notify the kernel about updates (which would propagate to
running processes); and NTP clients would be enhanced to use the new
API when avaiable.
Note that it's realistic that a process runs for over half a year,
so restarting each process between a leap second is announced and
the time it happens is not enough, and notifying each running program
separately would be bad too - it would be a hack, not a solution.
I wonder why DJB and other people didn't propose such a solution,
and instead they complain how POSIX is broken and propose something
which breaks programs which obey POSIX rules.
Anyway, all this effort will be wasted if there are no more leap
seconds and the system will be changed, e.g. by adjusting by an hour
every couple of centuries instead of a second every couple of months...
__("< Marcin Kowalczyk
\__/ qrczak at knm.org.pl
More information about the Libraries