SCCS-vsn: sys/kern/kern_clock.c 6.16
SCCS-vsn: sys/kern/kern_time.c 6.10
* 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"
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;
- delta = tick + tickadj;
- adjtimedelta -= tickadj;
+ delta = tick + tickdelta;
+ timedelta -= tickdelta;
}
BUMPTIME(&time, delta);
}
}
BUMPTIME(&time, delta);
}
* 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"
-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. */
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;
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;
+
+ if (uap->olddelta)
+ (void) copyout((caddr_t)&oatv, (caddr_t)uap->olddelta,
+ sizeof (struct timeval));