summaryrefslogtreecommitdiffstats
path: root/sys/kern/kern_tc.c
diff options
context:
space:
mode:
authorphk <phk@FreeBSD.org>1998-03-30 09:56:58 +0000
committerphk <phk@FreeBSD.org>1998-03-30 09:56:58 +0000
commit9b703b14551addf9806978973e2ddc427d4908b4 (patch)
tree91f2de8432f719153d0de9465a9ebeee33c29077 /sys/kern/kern_tc.c
parentadd2782c4ec0d7c4447da2b33d1413a2754f8a3e (diff)
downloadFreeBSD-src-9b703b14551addf9806978973e2ddc427d4908b4.zip
FreeBSD-src-9b703b14551addf9806978973e2ddc427d4908b4.tar.gz
Eradicate the variable "time" from the kernel, using various measures.
"time" wasn't a atomic variable, so splfoo() protection were needed around any access to it, unless you just wanted the seconds part. Most uses of time.tv_sec now uses the new variable time_second instead. gettime() changed to getmicrotime(0. Remove a couple of unneeded splfoo() protections, the new getmicrotime() is atomic, (until Bruce sets a breakpoint in it). A couple of places needed random data, so use read_random() instead of mucking about with time which isn't random. Add a new nfs_curusec() function. Mark a couple of bogosities involving the now disappeard time variable. Update ffs_update() to avoid the weird "== &time" checks, by fixing the one remaining call that passwd &time as args. Change profiling in ncr.c to use ticks instead of time. Resolution is the same. Add new function "tvtohz()" to avoid the bogus "splfoo(), add time, call hzto() which subtracts time" sequences. Reviewed by: bde
Diffstat (limited to 'sys/kern/kern_tc.c')
-rw-r--r--sys/kern/kern_tc.c45
1 files changed, 28 insertions, 17 deletions
diff --git a/sys/kern/kern_tc.c b/sys/kern/kern_tc.c
index 84b9875..35d95bf 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.58 1998/03/16 10:19:12 phk Exp $
+ * $Id: kern_clock.c,v 1.59 1998/03/26 20:51:31 phk Exp $
*/
#include <sys/param.h>
@@ -97,6 +97,8 @@ long tk_rawcc;
struct timecounter *timecounter;
+time_t time_second;
+
/*
* Clock handling routines.
*
@@ -136,7 +138,6 @@ int ticks;
static int psdiv, pscnt; /* prof => stat divider */
int psratio; /* ratio: prof / stat */
-struct timeval time;
volatile struct timeval mono_time;
/*
@@ -223,14 +224,10 @@ hardclock(frame)
}
/*
- * Compute number of hz until specified time. Used to
- * compute third argument to timeout() from an absolute time.
- * XXX this interface is often inconvenient. We often just need the
- * number of ticks in a timeval, but to use hzto() for that we have
- * to add `time' to the timeval and do everything at splclock().
+ * Compute number of ticks in the specified amount of time.
*/
int
-hzto(tv)
+tvtohz(tv)
struct timeval *tv;
{
register unsigned long ticks;
@@ -257,10 +254,8 @@ hzto(tv)
* If ints have 32 bits, then the maximum value for any timeout in
* 10ms ticks is 248 days.
*/
- s = splclock();
- sec = tv->tv_sec - time.tv_sec;
- usec = tv->tv_usec - time.tv_usec;
- splx(s);
+ sec = tv->tv_sec;
+ usec = tv->tv_usec;
if (usec < 0) {
sec--;
usec += 1000000;
@@ -271,7 +266,7 @@ hzto(tv)
sec++;
usec -= 1000000;
}
- printf("hzto: negative time difference %ld sec %ld usec\n",
+ printf("tvotohz: negative time difference %ld sec %ld usec\n",
sec, usec);
#endif
ticks = 1;
@@ -288,6 +283,24 @@ hzto(tv)
return (ticks);
}
+
+/*
+ * Compute number of hz until specified time. Used to
+ * compute third argument to timeout() from an absolute time.
+ */
+int
+hzto(tv)
+ struct timeval *tv;
+{
+ register long sec, usec;
+ struct timeval t2;
+
+ getmicrotime(&t2);
+ t2.tv_sec = tv->tv_sec - t2.tv_sec;
+ t2.tv_usec = tv->tv_usec - t2.tv_usec;
+ return (tvtohz(&t2));
+}
+
/*
* Start profiling on a process.
*
@@ -637,8 +650,7 @@ set_timecounter(struct timespec *ts)
tc->offset_nano = (u_int64_t)ts->tv_nsec << 32;
tc->offset_micro = ts->tv_nsec / 1000;
tc->offset_count = tc->get_timecount();
- time.tv_sec = tc->offset_sec;
- time.tv_usec = tc->offset_micro;
+ time_second = tc->offset_sec;
timecounter = tc;
splx(s);
}
@@ -711,8 +723,7 @@ tco_forward(void)
tc->offset_micro = (tc->offset_nano / 1000) >> 32;
- time.tv_usec = tc->offset_micro;
- time.tv_sec = tc->offset_sec;
+ time_second = tc->offset_sec;
timecounter = tc;
}
OpenPOWER on IntegriCloud