summaryrefslogtreecommitdiffstats
path: root/sys/kern/kern_tc.c
diff options
context:
space:
mode:
authorphk <phk@FreeBSD.org>1998-03-26 20:54:05 +0000
committerphk <phk@FreeBSD.org>1998-03-26 20:54:05 +0000
commit00475b662ad28e7f09931eb67a642ba1ee36db99 (patch)
tree12dd2aed1e3b8ecf5eb4152bf06ffa8c3ede0d7e /sys/kern/kern_tc.c
parentff4953fbcc9f747429234d5971a802bb653e451a (diff)
downloadFreeBSD-src-00475b662ad28e7f09931eb67a642ba1ee36db99.zip
FreeBSD-src-00475b662ad28e7f09931eb67a642ba1ee36db99.tar.gz
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.
Diffstat (limited to 'sys/kern/kern_tc.c')
-rw-r--r--sys/kern/kern_tc.c42
1 files changed, 30 insertions, 12 deletions
diff --git a/sys/kern/kern_tc.c b/sys/kern/kern_tc.c
index 927e5f6..84b9875 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)
{
OpenPOWER on IntegriCloud