[time-nuts] Could computers represent the timestamp differently?

Attila Kinali attila at kinali.ch
Fri Dec 23 16:02:03 EST 2016

On Fri, 23 Dec 2016 13:10:30 +0000
Peter Vince <petervince1952 at gmail.com> wrote:

> Would it not make sense now for the
> next generation of operating systems to do that?  Yes, those who need to
> find the elapsed time between two time-stamps would still have a problem,
> but isn't the overwhelming major requirement just to represent the
> date/time, and be able to easily show if one timestamp is before or after
> another?

You don't need to wait for the next generation of operating systems
for this. With the 2004 revision of POSIX-1[1], we got an additional
clock source called CLOCK_MONOTONIC, which is has to be monotonically
increasing, may not be set using a system call (and thus have
discontinuities) and may never jump backwards. It's starting point (epoch)
may be arbitrary, though. All current POSIX complient systems (Linux,
all BSD's, MacOSX) have CLOCK_MONOTONIC implemented since virtually forever.

On Linux (kernel 3.10 and newer) you can have some additional clock
sources[2], one of which is defined as CLOCK_TAI and is exactly what
the name says. Unfortunately, it's only set correctly if the OS knows
what TAI actually is. By default the offset between CLOCK_REALTIME
(which may or may not be the same as CLOCK_UTC) is set to 0 but a
modern ntpd can set it if it knows the offset. I am not sure whether
any of the BSDs offers something similar. Though, if I am not mistaken,
MirBSD choose to use TAI instead of UTC as the basis of their internal
clock and thus should also have a way to access it as TAI.

			Attila Kinali

[1] IEEE 1003.1-2004 System Interfaces, Section 2.8.5 Clocks and Timers

[2] clock_gettime(2)
Malek's Law:
        Any simple idea will be worded in the most complicated way.

More information about the time-nuts mailing list