summaryrefslogtreecommitdiffstats
path: root/sys/kern/kern_time.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_time.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_time.c')
-rw-r--r--sys/kern/kern_time.c34
1 files changed, 18 insertions, 16 deletions
diff --git a/sys/kern/kern_time.c b/sys/kern/kern_time.c
index a1fb4e3..f0897d7 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.42 1998/02/25 04:10:32 bde Exp $
+ * $Id: kern_time.c,v 1.43 1998/03/26 20:51:41 phk Exp $
*/
#include <sys/param.h>
@@ -229,10 +229,7 @@ nanosleep1(p, rqt, rmt)
atv.tv_usec = 0;
}
}
- s = splclock();
- timevaladd(&atv, &time);
- timo = hzto(&atv);
- splx(s);
+ timo = tvtohz(&atv);
p->p_sleepend = &atv;
error = tsleep(&nanowait, PWAIT | PCATCH, "nanslp", timo);
@@ -257,9 +254,7 @@ nanosleep1(p, rqt, rmt)
* problem for small timeouts, but the absolute error may
* be large for large timeouts.
*/
- s = splclock();
- utv = time;
- splx(s);
+ getmicrotime(&utv);
if (i != n) {
atv.tv_sec += (n - i - 1) * 100000000;
timevaladd(&atv, &rtv);
@@ -504,12 +499,13 @@ getitimer(p, uap)
struct proc *p;
register struct getitimer_args *uap;
{
+ struct timeval ctv;
struct itimerval aitv;
int s;
if (uap->which > ITIMER_PROF)
return (EINVAL);
- s = splclock();
+ s = splclock(); /* XXX still needed ? */
if (uap->which == ITIMER_REAL) {
/*
* Convert from absoulte to relative time in .it_value
@@ -518,11 +514,13 @@ getitimer(p, uap)
* current time and time for the timer to go off.
*/
aitv = p->p_realtimer;
- if (timerisset(&aitv.it_value))
- if (timercmp(&aitv.it_value, &time, <))
+ if (timerisset(&aitv.it_value)) {
+ getmicrotime(&ctv);
+ if (timercmp(&aitv.it_value, &ctv, <))
timerclear(&aitv.it_value);
else
- timevalsub(&aitv.it_value, &time);
+ timevalsub(&aitv.it_value, &ctv);
+ }
} else
aitv = p->p_stats->p_timer[uap->which];
splx(s);
@@ -543,6 +541,7 @@ setitimer(p, uap)
register struct setitimer_args *uap;
{
struct itimerval aitv;
+ struct timeval ctv;
register struct itimerval *itvp;
int s, error;
@@ -563,12 +562,13 @@ setitimer(p, uap)
timerclear(&aitv.it_interval);
else if (itimerfix(&aitv.it_interval))
return (EINVAL);
- s = splclock();
+ s = splclock(); /* XXX: still needed ? */
if (uap->which == ITIMER_REAL) {
if (timerisset(&p->p_realtimer.it_value))
untimeout(realitexpire, (caddr_t)p, p->p_ithandle);
if (timerisset(&aitv.it_value)) {
- timevaladd(&aitv.it_value, &time);
+ getmicrotime(&ctv);
+ timevaladd(&aitv.it_value, &ctv);
p->p_ithandle = timeout(realitexpire, (caddr_t)p,
hzto(&aitv.it_value));
}
@@ -596,6 +596,7 @@ realitexpire(arg)
void *arg;
{
register struct proc *p;
+ struct timeval ctv;
int s;
p = (struct proc *)arg;
@@ -605,10 +606,11 @@ realitexpire(arg)
return;
}
for (;;) {
- s = splclock();
+ s = splclock(); /* XXX: still neeeded ? */
timevaladd(&p->p_realtimer.it_value,
&p->p_realtimer.it_interval);
- if (timercmp(&p->p_realtimer.it_value, &time, >)) {
+ getmicrotime(&ctv);
+ if (timercmp(&p->p_realtimer.it_value, &ctv, >)) {
p->p_ithandle =
timeout(realitexpire, (caddr_t)p,
hzto(&p->p_realtimer.it_value) - 1);
OpenPOWER on IntegriCloud