small patch for setting RTC on Linux/intel

Urs Thuermann (urs@isnogud.escape.de)
Wed, 12 Nov 1997 04:49:08 +0100


if 1000000 is an integer multiple of hz (as is the case on linux/intel
with hz=100) and if xtime.tv_usec is n*tick + tick/2, the rtc is not
set to the value of the system clock every ~11min as stated in the
sources. e.g., with tick = 10000 and xtime.tv_usec = 5000 + n * tick,
we have xtime.tv_usec = 485000, 495000, 505000, 515000, ... and the
condition 500000 - tick/2 < xtime.tv_usec < 500000 + tick/2 will
necver be true.

the following patch corrects that.

--- time.c.orig Sun Nov 10 18:40:53 1996
+++ time.c Tue Nov 11 19:46:03 1997
@@ -351,8 +351,8 @@
* called as close as possible to 500 ms before the new second starts.
*/
if (time_state != TIME_BAD && xtime.tv_sec > last_rtc_update + 660 &&
- xtime.tv_usec > 500000 - (tick >> 1) &&
- xtime.tv_usec < 500000 + (tick >> 1))
+ xtime.tv_usec >= 500000 - (tick >> 1) &&
+ xtime.tv_usec <= 500000 + (tick >> 1))
if (set_rtc_mmss(xtime.tv_sec) == 0)
last_rtc_update = xtime.tv_sec;
else

urs