From Ulrich.Windl@rz.uni-regensburg.de Sun Jun 16 03:32:38 1996
From: Ulrich Windl <Ulrich.Windl@rz.uni-regensburg.de>
Organization: Universitaet Regensburg, Klinikum
To: mills@copland.udel.edu
Date: Tue, 14 May 1996 09:00:40 +0200
Mime-Version: 1.0
Content-Type: text/plain; charset=US-ASCII
Content-Transfer-Encoding: 7BIT
Subject: patch for kern.c (kernel.tar)
Priority: normal
X-Mailer: Pegasus Mail for Windows (v2.23)

Hello Dave,

the kern.c reference implementation dos not limit maxerror. Thus it 
will overflow when xndpd stops to work. My patch limits the maxerror 
to roughly MAXPHASE and switches the clock to status UNSYNC if the 
maxerror is reached. I think that is useful behaviour.

What I never understood was why MAXPHASE is used to preset maxerror, 
and why that particular value was chosen. For 32bit integers, wouldn't 
0x70000000 be a better value (still not causing an overflow too 
soon)?

Ulrich


--- kern.c	1994/12/17 04:22:47	1.1
+++ kern.c	1996/05/12 16:33:07	1.2
@@ -17,6 +17,9 @@
 /*
  * Modification history kern.c
  *
+ * 12 May 96	Ulrich Windl
+ *	Limit maxerror and modify status STA_UNSYNC if maxerror is too big.
+ *
  * 16 Dec 94	David L. Mills
  *	Added support for symmetric multiprocessor systems.
  *
@@ -551,7 +554,10 @@
 	if (time.tv_usec >= 1000000) {
 		time.tv_usec -= 1000000;
 		time.tv_sec++;
-		time_maxerror += time_tolerance >> SHIFT_USEC;
+		if ( time_maxerror <= MAXPHASE )
+			time_maxerror += time_tolerance >> SHIFT_USEC;
+		else
+			time_status |= STA_UNSYNC;
 
 		/*
 		 * Leap second processing. If in leap-insert state at

