PROPHET/OS
NAME
clock: shows the clocks of this machine, their frequency and how far they drift apart
SYNOPSIS
clock [--tui]
DESCRIPTION
Shows the clocks of this machine, their frequency and how far they drift apart.
date says what time it is. This shows the hardware behind that answer.
The title says which clock the kernel measures time with, which one drives the tick, what the wall clock has learned about its own rate, and how wide the window of the drift measurement was.
One row per clock. The TSC of the processor and the main counter of the HPET stand first, because they are counters and no service leads them; below them come the providers of the service timer and the providers of the service rtc, highest precedence first. A new timer appears here by itself, because the rows come out of the registry and not out of a list.
Source says how the frequency was found, and that is the column worth reading: CPUID 0x15 is what the processor says about itself, measured against the PIT is the fallback the kernel takes when it says nothing, and for the HPET it is the capability register of the chip. A frequency the kernel had to measure is a frequency that can be wrong.
Role says what the kernel takes the clock for.
| Word | What it means | |---|---| | time base | every deadline and every sleep is measured on it | | tick | it drives the scheduler | | wall clock | it says which day it is, and it survives the power | | counter | it runs and can be read, and nothing hangs on it | | stands by | it would carry, and something above it does | | missing | this machine does not have it, and Source says why |
Fires counts the interrupts a clock delivered, and for the wall clock how often it was read.
ppm is measured and not read. Every clock is read twice with a wait in between, and the seconds each one counted in that window are held against the seconds the time base counted. A clock that names a frequency it does not keep shows up there and nowhere else.
The counter itself has no column of its own. It is the input of that measurement and not its answer, it runs to twenty digits on the TSC, and a counter cut off at a column width is a wrong number.
A dash in ppm means the window was too narrow for this clock to say anything: the error of a measurement over n counter steps is one part in n, so a tick of a hundred per second carries 25 steps in a quarter second, which is four percent, and four percent says nothing about a hundred parts per million. The computation stands in os/include/time/clocks.h, once, and the self-test of the area drives the same two functions.
Above a hundred parts per million a row stands red: that is nine seconds a day, which every comparison of timestamps feels.
--tui takes the whole screen and keeps the table live; the arrows and the two page keys move in it, q leaves. Both shapes show the same table, and that is why they cannot drift apart: it stands once, in lib/os/board.c.
EXAMPLE
$ clock time base tsc at 2611137287 Hz, tick timer.tscdeadline at 100 Hz, wall clock has learned no rate yet, drift over 250 ms Clock Hz Source Role Fires ppm tsc 2611137287 measured against the PIT time base 0 0 hpet 100000000 the capability register counter 0 0 timer.tscdeadline 100 the rate asked for tick 1910 - timer.hpet - not started, no rate stands by 0 - timer.pit - not started, no rate stands by 0 - rtc.cmos 1 the board, one second wall clock 62 -