An ontology of clocks

Kurt Roeckx kurt at roeckx.be
Fri Feb 19 23:57:28 UTC 2016


On Fri, Feb 19, 2016 at 05:56:04PM -0500, Daniel Franke wrote:
> At a high level, a clock is characterized by the answers to three questions:

I guess that should be four ...

> # II - What drives it?
> 
> A typical PC has several oscillators. In addition to the main one,
> which sends clock interrupts to the CPU, there's likely to be a
> separate one on each NIC (important for PTP), one driving the RTC (aka
> BIOS clock), and perhaps an external oscillator providing a PPS
> signal.

You're missing at least a few ones here that are available on
typical PC hardware, including the pit, hpet, tsc, ACPI timer.

> * CLOCK_MONOTONIC_RAW is an atomic clock with an unspecified epoch and
> a precision of one nanosecond. It is driven by the system oscillator.
> It supports no adjustments at all. It is corrupted by suspending or
> rebooting the machine.

I'm sure what you mean by corrupt in the case of suspending.  It's
still measuring something, but maybe not something you (or ntp)
cares about.  I guess this falls under your category of "clocks
that count time selectively".

Also, the 1 nanosecond might not be the resolution.  It's going to
depend on the system.  You need to call clock_getres() to find out
what the real resolution is.  But 1 nanosecond is the best you can
expect.

> * /dev/rtc0 is a clumsy clock with a specified epoch and a precision
> of one second. It is driven by the RTC oscillator. It supports
> stepping. It is corrupted only by the death of the CMOS battery.

It actually supports various frequencies.

There is also at least /dev/hpet that you might want to look at.


Kurt



More information about the devel mailing list