Re: [PATCH] i386: Selectable Frequency of the Timer Interrupt

Vojtech Pavlik
2005-07-12T12:13:44Z

On Mon, Jul 11, 2005 at 05:38:05PM -0700, George Anzinger wrote:

> I would like to interject an addition data point, and I will NOT be
> subjective. The nature of the PIT is that it can _hit_ some frequencies
> better than others. We have had complaints about repeating timers not
> keeping good time. These are not jitter issues, but drift issues. The
> standard says we may not return early from a timer so any timer will either
> be on time or late. The amount of lateness depends very much on the HZ
> value. Here is what the values are for the standard CLOCK_TICK_RATE:
>
> HZ TICK RATE jiffie(ns) second(ns) error (ppbillion)
> 100 1193180 10000000 1000000000 0
> 200 1193180 5000098 1000019600 19600
> 250 1193180 4000250 1000062500 62500
> 500 1193180 1999703 1001851203 1851203
> 1000 1193180 999848 1000847848 847848
>
> The jiffie values here are exactly what the kernel uses and are based on
> the best one can do with the PIT hardware.

The PIT crystal runs at 14.3181818 MHz (CGA dotclock, found on ISA, ...)
and is divided by 12 to get PIT tick rate

14.3181818 MHz / 12 = 1193182 Hz

The reality is that the crystal is usually off by 50-100 ppm from the
standard value, depending on temperature.

HZ ticks/jiffie 1 second error (ppm)
---------------------------------------------------
100 11932 1.000015238 15.2
200 5966 1.000015238 15.2
250 4773 1.000057143 57.1
300 3977 0.999931429 -68.6
333 3583 0.999964114 -35.9
500 2386 0.999847619 -152.4
1000 1193 0.999847619 -152.4

Some HZ values indeed fit the tick frequency better than others, up to
333 the error is lost in the physical error of the crystal, for 500 and
1000, it definitely is larger, and thus noticeable.

Some (less round and nice) values of HZ would fit even better:

HZ ticks/jiffie 1 second error (ppm)
---------------------------------------------------
82 14551 1.000000152 0.2
96 12429 1.000001829 1.8
209 5709 0.999999314 -0.7
363 3287 0.999999314 -0.7
519 2299 0.999999314 -0.7
864 1381 1.000001829 1.8

--
Vojtech Pavlik
SuSE Labs, SuSE CR