The adjtimex utility has an --adjust mode that can be used to compare the system clock with the CMOS clock, calculate suggested values for the tick and frequency offset kernel time variables, and automatically install these suggested values.

By default, this does 8 comparisons (count), with a 10 second interval between comparisons (interval). The suggested values are automatically installed after every 3rd comparison, not including the first two.

Here's the sample output of adjtimex --adjust. The whole process (with the default values for count and interval) takes 70 seconds:

                                      --- current ---   -- suggested --
cmos time     system-cmos  error_ppm   tick      freq    tick      freq
1391731712      -3.877457
1391731722      -3.879791     -233.4  10000         0
1391731732      -3.882372     -258.1  10000         0   10002   3806862
1391731742      -3.884677     -230.5  10000         0   10002   1999050
1391731752      -3.887348     -267.1  10000         0   10002   4397487
1391731762      -3.887226       12.2  10002   4397487   10002   3599050
1391731772      -3.886892       33.4  10002   4397487   10002   2208425
1391731782      -3.886588       30.4  10002   4397487   10002   2405300

My question is, does anyone know why were these default values (count=8, interval=10) chosen?

I would think that the longer the interval between comparisons, the more accurate estimation you would get of the drift between the system and CMOS clocks. So, assuming that we want tio stick to the 70 second duration for the whole process, I would have thought that count=3, interval=35 would have been the obvious choice (note that min. 3 comparisons are needed in order to get suggested tick and freq values).

Can anyone shed some light on this?


David L. Mills (The creator of the adjtimex utility) wrote quite a few papers on the subject, available (with references) here the answers that you are looking for can be found in his paper: Improved Algorithms for Synchronizing Computer Network Clocks (1995)

Your question specifically questions why more than 3 counts are taken, (in this case 8) over a period of 70 seconds. Although only 3 comparisons (samples) are needed, a higher number of samples can be used to establish a 95% confidence interval of a value that estimates the Systematic Drift of the clock.

The calculated suggested tick values are installed after every 3rd comparison to further refine the accuracy of the estimated drift.

Statistically, the more samples that you take, over a longer interval, the closer to the actual drift value you will be.

Some fun history from Dr. Mill's papers: In the original Unix design a hardware timer interrupts the kernel at a fixed rate: 100 Hz in the SunOS kernel, 256 Hz in the Ultrix kernel and 1024 Hz in the OSF/1 kernel. Since the Ultrix timer interval (reciprocal of the rate) does not evenly divide one second in microseconds, the kernel adds 64 microseconds once each second, so the timescale consists of 255 advances of 3906 µs plus one of 3970 µs

The Unix 4.3bsd clock model requires a periodic hard ware timer interrupt produced by an oscillator operating in the 100-1000 Hz range. Each interrupt causes an increment tick to be added to the kernel time variable. The value of the increment is chosen so that the counter, plus an initial offset established by the settimeofday() call, is equal to the time of day in seconds and microseconds. When the tick does not evenly divide the second in microseconds, an additional increment fixtick is added to the kernel time once each second to make up the difference.

"The stability of a clock is how well it can maintain a constant frequency, the accuracy is how well its time compares with the system clock and the precision is to what degree time can be resolved. All of these factors need to be combined to "

  • What I say is that in this process, measurement error is much more significant than statistic error. More samples, if taken in a shorter time period, will not lead to a better result. By doing two rounds (at iteration 5 the suggested tick/freq values are installed and a new round starts), each round is actually shorter than the total duration (70 s). My point is that doing one single round instead of two, and instead increasing the time between samples, would actually yield better results as the measurement error gets less significant. – Grodriguez Feb 21 '14 at 8:29
  • As far as increasing the time between samples goes: there is probably a desire to have the clock in working order sooner than later. – dfc Feb 21 '14 at 20:02
  • @dfc: Yes, what I say is that assuming the total duration is fixed (70 seconds) I think that a better choice would be {count=3, interval=35} rather than {count=8, interval=10} – Grodriguez Feb 25 '14 at 15:40

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.