summaryrefslogtreecommitdiffstats
path: root/sys/kern/kern_time.c
diff options
context:
space:
mode:
authorattilio <attilio@FreeBSD.org>2007-06-09 21:48:44 +0000
committerattilio <attilio@FreeBSD.org>2007-06-09 21:48:44 +0000
commit12d804e413f2c44d9e10f25ee1b546f2b48c598b (patch)
tree7fca182049d1ed6ecc1c3b117e1d77c681c922c3 /sys/kern/kern_time.c
parent82a09af23776643f85a5e710a09bef3be83823d9 (diff)
downloadFreeBSD-src-12d804e413f2c44d9e10f25ee1b546f2b48c598b.zip
FreeBSD-src-12d804e413f2c44d9e10f25ee1b546f2b48c598b.tar.gz
rufetch and calcru sometimes should be called atomically together.
This patch fixes places where they should be called atomically changing their locking requirements (both assume per-proc spinlock held) and introducing rufetchcalc which wrappers both calls to be performed in atomic way. Reviewed by: jeff Approved by: jeff (mentor)
Diffstat (limited to 'sys/kern/kern_time.c')
-rw-r--r--sys/kern/kern_time.c4
1 files changed, 4 insertions, 0 deletions
diff --git a/sys/kern/kern_time.c b/sys/kern/kern_time.c
index 8634c8a..e220cd6 100644
--- a/sys/kern/kern_time.c
+++ b/sys/kern/kern_time.c
@@ -213,13 +213,17 @@ kern_clock_gettime(struct thread *td, clockid_t clock_id, struct timespec *ats)
break;
case CLOCK_VIRTUAL:
PROC_LOCK(p);
+ PROC_SLOCK(p);
calcru(p, &user, &sys);
+ PROC_SUNLOCK(p);
PROC_UNLOCK(p);
TIMEVAL_TO_TIMESPEC(&user, ats);
break;
case CLOCK_PROF:
PROC_LOCK(p);
+ PROC_SLOCK(p);
calcru(p, &user, &sys);
+ PROC_SUNLOCK(p);
PROC_UNLOCK(p);
timevaladd(&user, &sys);
TIMEVAL_TO_TIMESPEC(&user, ats);
OpenPOWER on IntegriCloud