diff options
author | Poul-Henning Kamp <phk@FreeBSD.org> | 1998-03-26 20:54:05 +0000 |
---|---|---|
committer | Poul-Henning Kamp <phk@FreeBSD.org> | 1998-03-26 20:54:05 +0000 |
commit | a0502b19d4c8889075e4aac302172f73a27a8cc9 (patch) | |
tree | 24e68c90a0a06f3cc6e198ae1db71c7fabc03914 /sys/kern/kern_tc.c | |
parent | 9de765d73bee599c2baae7a4c024ee937281ef39 (diff) | |
download | src-a0502b19d4c8889075e4aac302172f73a27a8cc9.tar.gz src-a0502b19d4c8889075e4aac302172f73a27a8cc9.zip |
Add two new functions, get{micro|nano}time.
They are atomic, but return in essence what is in the "time" variable.
gettime() is now a macro front for getmicrotime().
Various patches to use the two new functions instead of the various
hacks used in their absence.
Some puntuation and grammer patches from Bruce.
A couple of XXX comments.
Notes
Notes:
svn path=/head/; revision=34901
Diffstat (limited to 'sys/kern/kern_tc.c')
-rw-r--r-- | sys/kern/kern_tc.c | 42 |
1 files changed, 30 insertions, 12 deletions
diff --git a/sys/kern/kern_tc.c b/sys/kern/kern_tc.c index 927e5f650be8..84b9875faaf8 100644 --- a/sys/kern/kern_tc.c +++ b/sys/kern/kern_tc.c @@ -39,7 +39,7 @@ static volatile int print_tci = 1; * SUCH DAMAGE. * * @(#)kern_clock.c 8.5 (Berkeley) 1/21/94 - * $Id: kern_clock.c,v 1.57 1998/02/20 16:35:49 phk Exp $ + * $Id: kern_clock.c,v 1.58 1998/03/16 10:19:12 phk Exp $ */ #include <sys/param.h> @@ -222,17 +222,6 @@ hardclock(frame) ++softticks; } -void -gettime(struct timeval *tvp) -{ - int s; - - s = splclock(); - /* XXX should use microtime() iff tv_usec is used. */ - *tvp = time; - splx(s); -} - /* * Compute number of hz until specified time. Used to * compute third argument to timeout() from an absolute time. @@ -495,6 +484,35 @@ sysctl_kern_clockrate SYSCTL_HANDLER_ARGS SYSCTL_PROC(_kern, KERN_CLOCKRATE, clockrate, CTLTYPE_STRUCT|CTLFLAG_RD, 0, 0, sysctl_kern_clockrate, "S,clockinfo",""); + +/* + * We have four functions for looking at the clock, two for microseconds + * and two for nanoseconds. For each there is fast but less precise + * version "get{nano|micro}time" which will return a time which is up + * to 1/HZ previous to the call, whereas the raw version "{nano|micro}time" + * will return a timestamp which is as precise as possible. + */ + +void +getmicrotime(struct timeval *tvp) +{ + struct timecounter *tc; + + tc = timecounter; + tvp->tv_sec = tc->offset_sec; + tvp->tv_usec = tc->offset_micro; +} + +void +getnanotime(struct timespec *tsp) +{ + struct timecounter *tc; + + tc = timecounter; + tsp->tv_sec = tc->offset_sec; + tsp->tv_nsec = tc->offset_nano; +} + void microtime(struct timeval *tv) { |