Question about timebase accuracy in X86 Linux

From: Alex van der Wal (nomailplease_at_hotmail.com)
Date: 05/26/05


Date: Thu, 26 May 2005 11:29:29 +0200

Does the Linux (2.6) kernel compensate for PIT clock divider issues on a X86
system without a local APIC (e.g. Celerons and other resource challenged hardware)?

Here's the 'problem'.
If an X86 does not have a local APIC, it uses the PIT for timer interrupt
generation. The PIT has an input frequency of 11931190 Hz.
The 1000 Hz jiffie counter is setup by setting a clock divider in the PIT.
(11931190 / 1000 = 11931.19)
Since the clock divider is an integer, 11931.19 is rounded down to 11931
This sets the effective jiffie frequency to:
11931190 / 11931 = 1000,01592..... Hz
In one hour this leads to a clock error of:
0,1592 * 3600 = 573.2964.... jiffies ==> 573 milliseconds.

So, unless the clock divider is dynamically adjusted (by increasing the clock
divider value once in a while) to compensate for the rounding of the division
error, time in Linux progresses too fast.

Does the code in the Linux kernel do this or does it accept that the time is a
wee bit fast?

Please do not comment about the wonderful nature of NTP. I know about it and
simply don't care. A Linux kernel should be able to keep better time than the
sort of digital watch presented as an exclusive gift by book clubs and insurance
companies.

Regards,

Alex