Subject: Re: CVS commit: src/sys/arch/i386/i386
To: Manuel Bouyer <bouyer@antioche.eu.org>
From: David Laight <david@l8s.co.uk>
List: source-changes
Date: 04/16/2003 21:45:31
> Hum ... what if ntp correct the clock with ntp_adjtime() ?
> I suspect that after a long uptime, the RTC may have drifted significantly
> from the kernel time.

I'm sure I'd looked through that code when I first fixed my kernel.
I was completely fed up with the system clock being out by best
part of an hour after a kernel debugging session.

Anyway I'll add the code below to kern_ntptime and let the reboot
code set the time if ntp_active is non zero.

	David

Index: kern_ntptime.c
===================================================================
RCS file: /cvsroot/src/sys/kern/kern_ntptime.c,v
retrieving revision 1.22
diff -u -p -r1.22 kern_ntptime.c
--- kern_ntptime.c	2003/01/18 10:06:28	1.22
+++ kern_ntptime.c	2003/04/16 20:46:09
@@ -69,6 +69,9 @@ __KERNEL_RCSID(0, "$NetBSD: kern_ntptime
 
 #include <machine/cpu.h>
 
+/* Record if it is possible that NTP is playing with the system clock */
+int ntp_active = 0;
+
 #ifdef NTP
 /*
  * The following variables are used by the hardclock() routine in the
@@ -99,6 +102,7 @@ extern long pps_errcnt;		/* calibration 
 extern long pps_stbcnt;		/* stability limit exceeded */
 #endif /* PPS_SYNC */
 
+
 /*ARGSUSED*/
 /*
  * ntp_gettime() - NTP user application interface
@@ -231,6 +235,8 @@ ntp_adjtime1(ntv, v, retval)
 	 * what it is doing.
 	 */
 	modes = ntv->modes;
+	if (modes != 0)
+		ntp_active = 1;
 	s = splclock();
 	if (modes & MOD_FREQUENCY)
 #ifdef PPS_SYNC

	David

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