strange system clock issues
Thomas Charron
twaffle at gmail.com
Thu Aug 27 08:18:23 EDT 2009
On Wed, Aug 26, 2009 at 8:43 PM, Ben Scott<dragonhawk at gmail.com> wrote:
> On Wed, Aug 26, 2009 at 6:33 PM, Thomas Charron<twaffle at gmail.com> wrote:
> It's not a query, but many Linux distros invoke "hwclock --systohc"
> during shutdown. Otherwise, time corrections made with the "date"
> command or by ntpd wouldn't survive a reboot. Unlike MS-DOS and MS
> Windows, changing the system clock in Linux does *not* implicitly
> update the battery clock as well.
My bad, I assumed it would. :-D
>> However, the RTC itself will generate a system time interupt every
>> second.
> I do not believe the IBM-PC/AT RTC (what I call "battery clock",
> since "real-time clock" is non-obvious) normally generates an
> interrupt once per second.
I was simplifying it. However, the rate is programable, and occurs on IRQ8.
> The RTC certainly doesn't advance the system clock. That's done by
> IRQ0, which fires 18 times per second. The original IBM-PC and PC/XT
> did not *have* an RTC. You had to set the system clock at boot, and
> then IRQ0 drove the show.
Actually, it's updated by whatever the kernel uses as a clock. A
perfect example is when the kernel decides to use the TSC timer as
it's system timer. When it does, and the bios and/or something
external (Aka, Intel Speedstep) modifies the TSC to save power, wacky
time things happen. Specifically, time warps, lags, etc.
As a matter of fact, if Pauls kernel IS using the TSC as it's time
source, and the system is throttling down from say, 2Ghz to 500Mhz
because it is under very little load, then 1 second can very well be,
4 seconds.
> The RTC can can be programmed to generate periodic interrupts, or
> interrupts at a particular time. Those come in on IRQ8. (I had
> forgotten this, but Google just reminded me). That was useful in the
> days of MS-DOS, when there was no OS and everything was single task
> and interrupt driven. It's not for the system clock.
Anything that can be a clock, including the RTC, can be used as the
clock source for the kernel. timer_hpet, timer_pmtmr, timer_tsc,
timer_pit, timer_none are the five most commonly used timer sources
for the kernel.
> Disclaimer: It may be that Linux does something different to advance
> the system clock. The above is how the BIOS does things. But since
> the latest and greatest from Intel and AMD are still backwards
> compatible with the original IBM-PC (1981), that's still how things
> work unless the OS does different.
It does do something different. There is a whole section on it
under 'Understanding the Linux Kernel'. Last month I spent a few days
looking a whole lot of it up, as I'm setting up Linux in a real time
motion control environment.
> According to that, the RTC interrupt (IRQ8) has fired 3 times since
> boot, while the system timer (IRQ0) has fired roughly 2.3 billion
> times. Which do you think is advancing the system clock? :)
Whatever time source the kernel has decided to use. :-D Which, I
can definitively concede, is NOT the RTC on your system.
--
-- Thomas
More information about the gnhlug-discuss
mailing list