diff options
author | phk <phk@FreeBSD.org> | 1998-03-30 09:56:58 +0000 |
---|---|---|
committer | phk <phk@FreeBSD.org> | 1998-03-30 09:56:58 +0000 |
commit | 9b703b14551addf9806978973e2ddc427d4908b4 (patch) | |
tree | 91f2de8432f719153d0de9465a9ebeee33c29077 /sys/kern/sys_generic.c | |
parent | add2782c4ec0d7c4447da2b33d1413a2754f8a3e (diff) | |
download | FreeBSD-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/sys_generic.c')
-rw-r--r-- | sys/kern/sys_generic.c | 28 |
1 files changed, 12 insertions, 16 deletions
diff --git a/sys/kern/sys_generic.c b/sys/kern/sys_generic.c index 54dc0a8..c0cb690 100644 --- a/sys/kern/sys_generic.c +++ b/sys/kern/sys_generic.c @@ -36,7 +36,7 @@ * SUCH DAMAGE. * * @(#)sys_generic.c 8.5 (Berkeley) 1/21/94 - * $Id: sys_generic.c,v 1.32 1997/11/06 19:29:20 phk Exp $ + * $Id: sys_generic.c,v 1.33 1997/11/23 10:30:50 bde Exp $ */ #include "opt_ktrace.h" @@ -539,7 +539,7 @@ select(p, uap) fd_mask s_selbits[howmany(2048, NFDBITS)]; fd_mask *ibits[3], *obits[3], *selbits, *sbp; struct timeval atv; - int s, ncoll, error, timo; + int s, ncoll, error, timo, term; u_int nbufbytes, ncpbytes, nfdbits; if (uap->nd < 0) @@ -600,12 +600,11 @@ select(p, uap) error = EINVAL; goto done; } - s = splclock(); - timevaladd(&atv, &time); - timo = hzto(&atv); - splx(s); + timo = tvtohz(&atv); } else timo = 0; + if (timo) + term = timo + ticks; retry: ncoll = nselcoll; p->p_flag |= P_SELECT; @@ -613,9 +612,7 @@ retry: if (error || p->p_retval[0]) goto done; s = splhigh(); - /* this should be timercmp(&time, &atv, >=) */ - if (uap->tv && (time.tv_sec > atv.tv_sec || - (time.tv_sec == atv.tv_sec && time.tv_usec >= atv.tv_usec))) { + if (timo && term <= ticks) { splx(s); goto done; } @@ -706,7 +703,7 @@ poll(p, uap) caddr_t bits; char smallbits[32 * sizeof(struct pollfd)]; struct timeval atv; - int s, ncoll, error = 0, timo; + int s, ncoll, error = 0, timo, term; size_t ni; if (SCARG(uap, nfds) > p->p_fd->fd_nfiles) { @@ -728,20 +725,19 @@ poll(p, uap) error = EINVAL; goto done; } - s = splclock(); - timevaladd(&atv, &time); - timo = hzto(&atv); - splx(s); + timo = tvtohz(&atv); } else timo = 0; + if (timo) + term = timo + ticks; retry: ncoll = nselcoll; p->p_flag |= P_SELECT; error = pollscan(p, (struct pollfd *)bits, SCARG(uap, nfds)); if (error || p->p_retval[0]) goto done; - s = splhigh(); - if (timo && timercmp(&time, &atv, >=)) { + s = splhigh(); + if (timo && term <= ticks) { splx(s); goto done; } |