use faster adjustment for larger corrections
authorMike Karels <karels@ucbvax.Berkeley.EDU>
Wed, 28 May 1986 06:21:56 +0000 (22:21 -0800)
committerMike Karels <karels@ucbvax.Berkeley.EDU>
Wed, 28 May 1986 06:21:56 +0000 (22:21 -0800)
SCCS-vsn: sys/kern/kern_clock.c 6.16
SCCS-vsn: sys/kern/kern_time.c 6.10

usr/src/sys/kern/kern_clock.c
usr/src/sys/kern/kern_time.c

index 0e505ac..33fe91c 100644 (file)
@@ -3,7 +3,7 @@
  * All rights reserved.  The Berkeley software License Agreement
  * specifies the terms and conditions for redistribution.
  *
  * All rights reserved.  The Berkeley software License Agreement
  * specifies the terms and conditions for redistribution.
  *
- *     @(#)kern_clock.c        6.15 (Berkeley) %G%
+ *     @(#)kern_clock.c        6.16 (Berkeley) %G%
  */
 
 #include "../machine/reg.h"
  */
 
 #include "../machine/reg.h"
@@ -211,17 +211,17 @@ hardclock(pc, ps)
                }
        }
 #else
                }
        }
 #else
-       if (adjtimedelta == 0)
+       if (timedelta == 0)
                BUMPTIME(&time, tick)
        else {
                register delta;
 
                BUMPTIME(&time, tick)
        else {
                register delta;
 
-               if (adjtimedelta < 0) {
-                       delta = tick - tickadj;
-                       adjtimedelta += tickadj;
+               if (timedelta < 0) {
+                       delta = tick - tickdelta;
+                       timedelta += tickdelta;
                } else {
                } else {
-                       delta = tick + tickadj;
-                       adjtimedelta -= tickadj;
+                       delta = tick + tickdelta;
+                       timedelta -= tickdelta;
                }
                BUMPTIME(&time, delta);
        }
                }
                BUMPTIME(&time, delta);
        }
index 1f79805..6cc14a6 100644 (file)
@@ -3,7 +3,7 @@
  * All rights reserved.  The Berkeley software License Agreement
  * specifies the terms and conditions for redistribution.
  *
  * All rights reserved.  The Berkeley software License Agreement
  * specifies the terms and conditions for redistribution.
  *
- *     @(#)kern_time.c 6.9 (Berkeley) %G%
+ *     @(#)kern_time.c 6.10 (Berkeley) %G%
  */
 
 #include "../machine/reg.h"
  */
 
 #include "../machine/reg.h"
@@ -78,8 +78,10 @@ setthetime(tv)
        resettodr();
 }
 
        resettodr();
 }
 
-int adjtimedelta;
-extern int tickadj;
+extern int tickadj;                    /* "standard" clock skew, us./tick */
+int    tickdelta;                      /* current clock skew, us. per tick */
+long   timedelta;                      /* unapplied time correction, us. */
+long   bigadj = 1000000;               /* use 10x skew above bigadj us. */
 
 adjtime()
 {
 
 adjtime()
 {
@@ -88,6 +90,7 @@ adjtime()
                struct timeval *olddelta;
        } *uap = (struct a *)u.u_ap;
        struct timeval atv, oatv;
                struct timeval *olddelta;
        } *uap = (struct a *)u.u_ap;
        struct timeval atv, oatv;
+       register long ndelta;
        int s;
 
        if (!suser()) 
        int s;
 
        if (!suser()) 
@@ -96,17 +99,26 @@ adjtime()
                sizeof (struct timeval));
        if (u.u_error)
                return;
                sizeof (struct timeval));
        if (u.u_error)
                return;
+       ndelta = atv.tv_sec * 1000000 + atv.tv_usec;
+       if (timedelta == 0)
+               if (ndelta > bigadj)
+                       tickdelta = 10 * tickadj;
+               else
+                       tickdelta = tickadj;
+       if (ndelta % tickdelta)
+               ndelta = ndelta / tickadj * tickadj;
+
        s = splclock();
        if (uap->olddelta) {
        s = splclock();
        if (uap->olddelta) {
-               oatv.tv_sec = adjtimedelta / 1000000;
-               oatv.tv_usec = adjtimedelta % 1000000;
-               (void) copyout((caddr_t)&oatv, (caddr_t)uap->olddelta,
-                       sizeof (struct timeval));
+               oatv.tv_sec = timedelta / 1000000;
+               oatv.tv_usec = timedelta % 1000000;
        }
        }
-       adjtimedelta = atv.tv_sec * 1000000 + atv.tv_usec;
-       if (adjtimedelta % tickadj)
-               adjtimedelta = adjtimedelta / tickadj * tickadj;
+       timedelta = ndelta;
        splx(s);
        splx(s);
+
+       if (uap->olddelta)
+               (void) copyout((caddr_t)&oatv, (caddr_t)uap->olddelta,
+                       sizeof (struct timeval));
 }
 
 /*
 }
 
 /*