RFC 1589 (rfc1589) - Page 3 of 37


A Kernel Model for Precision Timekeeping



Alternative Format: Original Text Document



RFC 1589         Kernel Model for Precision Timekeeping       March 1994


   installation instructions are given in a specific README files
   included in the kernel distributions.

   In this memorandum, NTP Version 3 and the Unix implementation xntp3
   are used as an example application of the new system calls for use by
   a synchronization daemon. In principle, the new system calls can be
   used by other protocols and implementations as well. Even in cases
   where the local time is maintained by periodic exchanges of messages
   at relatively long intervals, such as using the NIST Automated
   Computer Time Service, the ability to precisely adjust the system
   clock frequency simplifies the synchronization procedures and allows
   the telephone call frequency to be considerably reduced.

2. Design Approach

   While not strictly necessary for an understanding or implementation
   of the model, it may be helpful to briefly describe how NTP operates
   to control the system clock in a client workstation. As described in
   [1], the NTP protocol exchanges timestamps with one or more peers
   sharing a synchronization subnet to calculate the time offsets
   between peer clocks and the local clock. These offsets are processed
   by several algorithms which refine and combine the offsets to produce
   an ensemble average, which is then used to adjust the local clock
   time and frequency. The manner in which the local clock is adjusted
   represents the main topic of this memorandum. The goal in the
   enterprise is the most accurate and stable system clock possible with
   the available kernel software and workstation hardware.

   In order to understand how the new software works, it is useful to
   review how most Unix kernels maintain the system time. In the Unix
   design a hardware counter 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 Ultrix
   kernel adds 64 microseconds once each second, so the timescale
   consists of 255 advances of 3906 us plus one of 3970 us. Similarly,
   the OSF/1 kernel adds 576 us once each second, so its timescale
   consists of 1023 advances of 976 us plus one of 1552 us.

   2.1. Mechanisms to Adjust Time and Frequency

      In most Unix kernels it is possible to slew the system clock to a
      new offset relative to the current time by using the adjtime()
      system call. To do this the clock frequency is changed by adding
      or subtracting a fixed amount (tickadj) at each timer interrupt
      (tick) for a calculated number of ticks. Since this calculation
      involves dividing the requested offset by tickadj, it is possible
      to slew to a new offset with a precision only of tickadj, which is



Mills