Subject: hardware clock 'corrupted' by ddb (and possibly other things)
To: None <tech-kern@netbsd.org>
From: David Laight <david@l8s.co.uk>
List: tech-kern
Date: 07/10/2002 18:03:25
I've noticed that if the system loses timer interrupts
(eg by being stopped in ddb) then the machines hardware clock
also loses time.

It seems that there is code cpu_reboot() (in arch/x/y/machedep.c)
to reset the hardware clock to the current time during EVERY
system shutdown.  The effect is that the system time is now
at best as accurate as the crystal that generates the system timer
interrupt - rather than the (hopefully more accurate) RTC chip.
If the kernel misses any interrupts things are much worse.

Now The hardware clock is reset by the call to resettodr() in
settime() (in kern_time.c) whenever the system clock is changed.

Thus there is no need to apply all the accumulated error in the
system clock to the hardware clock during shutdown.

The CVS history seems shows that the resettodr() call was added
to the i386 machdep.c in delta 1.55 (26/10/1993), the comment
doesn't indicate why!

Anyone remember why???

Maybe the kernel ought to reset its clock to match the hardware
one occaisionally as well!

	David

-- 
David Laight: david@l8s.co.uk