Re: small patch for setting RTC on Linux/intel (fwd)

Ulrich Windl (ulrich.windl@rz.uni-regensburg.de)
Thu, 13 Nov 1997 08:19:19 +0100


I was asked abou my opinion about this:

Hubert, watch for CC:s...

> ---------- Forwarded message ----------
> Date: Wed, 12 Nov 1997 04:49:08 +0100
> From: Urs Thuermann <urs@isnogud.escape.de>
> To: linux-kernel@vger.rutgers.edu
> Subject: small patch for setting RTC on Linux/intel
>
> 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

I think "lowerbound <= usec < upper_bound" would have been enough,
but:

If you remember that tick can be adjusted (maybe to 9999), you can
have the additional problem tha tthe interval is still too small.
What about replacing "(tick / 2)" with "((tick + 1) / 2)". (gcc
shouldn't care about ">> 1" or "/ 2" if the number is unsigned...)

Ulrich