diff options
author | phk <phk@FreeBSD.org> | 1998-04-04 13:26:20 +0000 |
---|---|---|
committer | phk <phk@FreeBSD.org> | 1998-04-04 13:26:20 +0000 |
commit | 5e9a131f20894d1df9e8c1768be6eb1cc29a3cf4 (patch) | |
tree | 76909c92c472744745de10e5dacc307ea5f7af45 /sys/kern/sys_generic.c | |
parent | ddcbf85eb29fd2d50ce1afa0243be370d4893370 (diff) | |
download | FreeBSD-src-5e9a131f20894d1df9e8c1768be6eb1cc29a3cf4.zip FreeBSD-src-5e9a131f20894d1df9e8c1768be6eb1cc29a3cf4.tar.gz |
Time changes mark 2:
* Figure out UTC relative to boottime. Four new functions provide
time relative to boottime.
* move "runtime" into struct proc. This helps fix the calcru()
problem in SMP.
* kill mono_time.
* add timespec{add|sub|cmp} macros to time.h. (XXX: These may change!)
* nanosleep, select & poll takes long sleeps one day at a time
Reviewed by: bde
Tested by: ache and others
Diffstat (limited to 'sys/kern/sys_generic.c')
-rw-r--r-- | sys/kern/sys_generic.c | 58 |
1 files changed, 37 insertions, 21 deletions
diff --git a/sys/kern/sys_generic.c b/sys/kern/sys_generic.c index fb0034f..ee056f0 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.34 1998/03/30 09:50:29 phk Exp $ + * $Id: sys_generic.c,v 1.35 1998/04/02 07:22:17 phk Exp $ */ #include "opt_ktrace.h" @@ -538,8 +538,8 @@ 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, term; + struct timeval atv, rtv, ttv; + int s, ncoll, error, timo; u_int nbufbytes, ncpbytes, nfdbits; if (uap->nd < 0) @@ -600,21 +600,29 @@ select(p, uap) error = EINVAL; goto done; } - term = ticks + tvtohz(&atv); - } else - term = 0; + getmicroruntime(&rtv); + timevaladd(&atv, &rtv); + } else { + atv.tv_sec = 0; + atv.tv_usec = 0; + } + timo = 0; retry: ncoll = nselcoll; p->p_flag |= P_SELECT; error = selscan(p, ibits, obits, uap->nd); if (error || p->p_retval[0]) goto done; - s = splhigh(); - if (term && term <= ticks) { - splx(s); - goto done; + if (atv.tv_sec) { + getmicroruntime(&rtv); + if (timevalcmp(&rtv, &atv, >=)) + goto done; + ttv = atv; + timevalsub(&ttv, &rtv); + timo = ttv.tv_sec > 24 * 60 * 60 ? + 24 * 60 * 60 * hz : tvtohz(&ttv); } - timo = term ? term - ticks : 0; + s = splhigh(); if ((p->p_flag & P_SELECT) == 0 || nselcoll != ncoll) { splx(s); goto retry; @@ -701,8 +709,8 @@ poll(p, uap) { caddr_t bits; char smallbits[32 * sizeof(struct pollfd)]; - struct timeval atv; - int s, ncoll, error = 0, timo, term; + struct timeval atv, rtv, ttv; + int s, ncoll, error = 0, timo; size_t ni; if (SCARG(uap, nfds) > p->p_fd->fd_nfiles) { @@ -724,21 +732,29 @@ poll(p, uap) error = EINVAL; goto done; } - term = ticks + tvtohz(&atv); - } else - term = 0; + getmicroruntime(&rtv); + timevaladd(&atv, &rtv); + } else { + atv.tv_sec = 0; + atv.tv_usec = 0; + } + timo = 0; 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; + if (atv.tv_sec) { + getmicroruntime(&rtv); + if (timevalcmp(&rtv, &atv, >=)) + goto done; + ttv = atv; + timevalsub(&ttv, &rtv); + timo = ttv.tv_sec > 24 * 60 * 60 ? + 24 * 60 * 60 * hz : tvtohz(&ttv); + } s = splhigh(); - if (term && term <= ticks) { - splx(s); - goto done; - } - timo = term ? term - ticks : 0; if ((p->p_flag & P_SELECT) == 0 || nselcoll != ncoll) { splx(s); goto retry; |