summaryrefslogtreecommitdiffstats
path: root/sys/kern/kern_time.c
diff options
context:
space:
mode:
authorphk <phk@FreeBSD.org>1998-02-20 16:36:17 +0000
committerphk <phk@FreeBSD.org>1998-02-20 16:36:17 +0000
commit044e1e629691b102791a17fc6db270846b71b01c (patch)
tree73eeeac34c8a9254ecd3686eaa03c76379171a5c /sys/kern/kern_time.c
parentfba9e5d6630c11aef2f66bef4dd7fbf45179be87 (diff)
downloadFreeBSD-src-044e1e629691b102791a17fc6db270846b71b01c.zip
FreeBSD-src-044e1e629691b102791a17fc6db270846b71b01c.tar.gz
Replace TOD clock code with more systematic approach.
Highlights: * Simple model for underlying hardware. * Hardware basis for timekeeping can be changed on the fly. * Only one hardware clock responsible for TOD keeping. * Provides a real nanotime() function. * Time granularity: .232E-18 seconds. * Frequency granularity: .238E-12 s/s * Frequency adjustment is continuous in time. * Less overhead for frequency adjustment. * Improves xntpd performance. Reviewed by: bde, bde, bde
Diffstat (limited to 'sys/kern/kern_time.c')
-rw-r--r--sys/kern/kern_time.c13
1 files changed, 7 insertions, 6 deletions
diff --git a/sys/kern/kern_time.c b/sys/kern/kern_time.c
index 8060c15..fb78ffc 100644
--- a/sys/kern/kern_time.c
+++ b/sys/kern/kern_time.c
@@ -31,7 +31,7 @@
* SUCH DAMAGE.
*
* @(#)kern_time.c 8.1 (Berkeley) 6/10/93
- * $Id: kern_time.c,v 1.39 1997/11/06 19:29:16 phk Exp $
+ * $Id: kern_time.c,v 1.40 1997/11/07 08:52:58 phk Exp $
*/
#include <sys/param.h>
@@ -78,6 +78,7 @@ settime(tv)
struct timeval *tv;
{
struct timeval delta;
+ struct timespec ts;
struct proc *p;
int s;
@@ -99,7 +100,9 @@ settime(tv)
*/
delta.tv_sec = tv->tv_sec - time.tv_sec;
delta.tv_usec = tv->tv_usec - time.tv_usec;
- time = *tv;
+ ts.tv_sec = tv->tv_sec;
+ ts.tv_nsec = tv->tv_usec * 1000;
+ set_timecounter(&ts);
/*
* XXX should arrange for microtime() to agree with *tv if
* it is called now. As it is, it may add up to about
@@ -138,13 +141,11 @@ clock_gettime(p, uap)
struct proc *p;
struct clock_gettime_args *uap;
{
- struct timeval atv;
struct timespec ats;
if (SCARG(uap, clock_id) != CLOCK_REALTIME)
return (EINVAL);
- microtime(&atv);
- TIMEVAL_TO_TIMESPEC(&atv, &ats);
+ nanotime(&ats);
return (copyout(&ats, SCARG(uap, tp), sizeof(ats)));
}
@@ -199,7 +200,7 @@ clock_getres(p, uap)
error = 0;
if (SCARG(uap, tp)) {
ts.tv_sec = 0;
- ts.tv_nsec = 1000000000 / hz;
+ ts.tv_nsec = 1000000000 / timecounter->frequency;
error = copyout(&ts, SCARG(uap, tp), sizeof(ts));
}
return (error);
OpenPOWER on IntegriCloud