diff options
author | bde <bde@FreeBSD.org> | 1997-03-22 06:53:45 +0000 |
---|---|---|
committer | bde <bde@FreeBSD.org> | 1997-03-22 06:53:45 +0000 |
commit | 0bc178170104cff1e818e849d08a50c6a4ee0851 (patch) | |
tree | 1a4787be89dc6587f785bb211bf92dd0ce277648 /sys/kern | |
parent | 5610d80b6231f85421e587a175ddd4d4b0c735c5 (diff) | |
download | FreeBSD-src-0bc178170104cff1e818e849d08a50c6a4ee0851.zip FreeBSD-src-0bc178170104cff1e818e849d08a50c6a4ee0851.tar.gz |
Fixed some invalid (non-atomic) accesses to `time', mostly ones of the
form `tv = time'. Use a new function gettime(). The current version
just forces atomicicity without fixing precision or efficiency bugs.
Simplified some related valid accesses by using the central function.
Diffstat (limited to 'sys/kern')
-rw-r--r-- | sys/kern/init_main.c | 5 | ||||
-rw-r--r-- | sys/kern/kern_clock.c | 13 | ||||
-rw-r--r-- | sys/kern/kern_tc.c | 13 | ||||
-rw-r--r-- | sys/kern/kern_timeout.c | 13 | ||||
-rw-r--r-- | sys/kern/sys_pipe.c | 25 | ||||
-rw-r--r-- | sys/kern/tty.c | 10 |
6 files changed, 51 insertions, 28 deletions
diff --git a/sys/kern/init_main.c b/sys/kern/init_main.c index 57fa5dd..f108547 100644 --- a/sys/kern/init_main.c +++ b/sys/kern/init_main.c @@ -39,7 +39,7 @@ * SUCH DAMAGE. * * @(#)init_main.c 8.9 (Berkeley) 1/21/94 - * $Id: init_main.c,v 1.57 1997/02/22 09:38:59 peter Exp $ + * $Id: init_main.c,v 1.58 1997/03/01 17:49:09 wosch Exp $ */ #include "opt_rlimit.h" @@ -413,7 +413,8 @@ proc0_post(dummy) * from the file system. Reset p->p_rtime as it may have been * munched in mi_switch() after the time got set. */ - proc0.p_stats->p_start = runtime = mono_time = boottime = time; + gettime(&boottime); + proc0.p_stats->p_start = runtime = mono_time = boottime; proc0.p_rtime.tv_sec = proc0.p_rtime.tv_usec = 0; /* diff --git a/sys/kern/kern_clock.c b/sys/kern/kern_clock.c index 341c00e..e5fa539 100644 --- a/sys/kern/kern_clock.c +++ b/sys/kern/kern_clock.c @@ -36,7 +36,7 @@ * SUCH DAMAGE. * * @(#)kern_clock.c 8.5 (Berkeley) 1/21/94 - * $Id$ + * $Id: kern_clock.c,v 1.32 1997/02/22 09:39:02 peter Exp $ */ /* Portions of this software are covered by the following: */ @@ -799,6 +799,17 @@ untimeout(ftn, arg) splx(s); } +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. diff --git a/sys/kern/kern_tc.c b/sys/kern/kern_tc.c index 341c00e..e5fa539 100644 --- a/sys/kern/kern_tc.c +++ b/sys/kern/kern_tc.c @@ -36,7 +36,7 @@ * SUCH DAMAGE. * * @(#)kern_clock.c 8.5 (Berkeley) 1/21/94 - * $Id$ + * $Id: kern_clock.c,v 1.32 1997/02/22 09:39:02 peter Exp $ */ /* Portions of this software are covered by the following: */ @@ -799,6 +799,17 @@ untimeout(ftn, arg) splx(s); } +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. diff --git a/sys/kern/kern_timeout.c b/sys/kern/kern_timeout.c index 341c00e..e5fa539 100644 --- a/sys/kern/kern_timeout.c +++ b/sys/kern/kern_timeout.c @@ -36,7 +36,7 @@ * SUCH DAMAGE. * * @(#)kern_clock.c 8.5 (Berkeley) 1/21/94 - * $Id$ + * $Id: kern_clock.c,v 1.32 1997/02/22 09:39:02 peter Exp $ */ /* Portions of this software are covered by the following: */ @@ -799,6 +799,17 @@ untimeout(ftn, arg) splx(s); } +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. diff --git a/sys/kern/sys_pipe.c b/sys/kern/sys_pipe.c index 8be483b..66b0ac7 100644 --- a/sys/kern/sys_pipe.c +++ b/sys/kern/sys_pipe.c @@ -16,7 +16,7 @@ * 4. Modifications may be freely made to this file if the above conditions * are met. * - * $Id$ + * $Id: sys_pipe.c,v 1.24 1997/02/22 09:39:19 peter Exp $ */ #ifndef OLD_PIPE @@ -253,11 +253,9 @@ pipeinit(cpipe) cpipe->pipe_state = 0; cpipe->pipe_peer = NULL; cpipe->pipe_busy = 0; - s = splhigh(); - cpipe->pipe_ctime = time; - cpipe->pipe_atime = time; - cpipe->pipe_mtime = time; - splx(s); + gettime(&cpipe->pipe_ctime); + cpipe->pipe_atime = cpipe->pipe_ctime; + cpipe->pipe_mtime = cpipe->pipe_ctime; bzero(&cpipe->pipe_sel, sizeof cpipe->pipe_sel); cpipe->pipe_pgid = NO_PID; @@ -439,11 +437,8 @@ pipe_read(fp, uio, cred) } } - if (error == 0) { - int s = splhigh(); - rpipe->pipe_atime = time; - splx(s); - } + if (error == 0) + gettime(&rpipe->pipe_atime); --rpipe->pipe_busy; if ((rpipe->pipe_busy == 0) && (rpipe->pipe_state & PIPE_WANT)) { @@ -914,11 +909,9 @@ pipe_write(fp, uio, cred) (error == EPIPE)) error = 0; - if (error == 0) { - int s = splhigh(); - wpipe->pipe_mtime = time; - splx(s); - } + if (error == 0) + gettime(&wpipe->pipe_mtime); + /* * We have something to offer, * wake up select. diff --git a/sys/kern/tty.c b/sys/kern/tty.c index 8d91223..a1e516d 100644 --- a/sys/kern/tty.c +++ b/sys/kern/tty.c @@ -36,7 +36,7 @@ * SUCH DAMAGE. * * @(#)tty.c 8.8 (Berkeley) 1/21/94 - * $Id$ + * $Id: tty.c,v 1.91 1997/02/22 09:39:23 peter Exp $ */ /*- @@ -1513,9 +1513,7 @@ loop: goto sleep; if (qp->c_cc >= m) goto read; - x = splclock(); - timecopy = time; - splx(x); + gettime(&timecopy); if (!has_stime) { /* first character, start timer */ has_stime = 1; @@ -1535,9 +1533,7 @@ loop: } else { /* m == 0 */ if (qp->c_cc > 0) goto read; - x = splclock(); - timecopy = time; - splx(x); + gettime(&timecopy); if (!has_stime) { has_stime = 1; stime = timecopy; |