summaryrefslogtreecommitdiffstats
path: root/sys/compat/svr4
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/compat/svr4
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/compat/svr4')
-rw-r--r--sys/compat/svr4/svr4_misc.c8
1 files changed, 8 insertions, 0 deletions
diff --git a/sys/compat/svr4/svr4_misc.c b/sys/compat/svr4/svr4_misc.c
index 7277622..a158fd7 100644
--- a/sys/compat/svr4/svr4_misc.c
+++ b/sys/compat/svr4/svr4_misc.c
@@ -828,7 +828,9 @@ svr4_sys_times(td, uap)
p = td->td_proc;
PROC_LOCK(p);
+ PROC_SLOCK(p);
calcru(p, &utime, &stime);
+ PROC_SUNLOCK(p);
calccru(p, &cutime, &cstime);
PROC_UNLOCK(p);
@@ -1241,7 +1243,9 @@ loop:
pid = p->p_pid;
status = p->p_xstat;
ru = p->p_ru;
+ PROC_SLOCK(p);
calcru(p, &ru.ru_utime, &ru.ru_stime);
+ PROC_SUNLOCK(p);
PROC_UNLOCK(p);
sx_sunlock(&proctree_lock);
@@ -1266,7 +1270,9 @@ loop:
pid = p->p_pid;
status = W_STOPCODE(p->p_xstat);
ru = p->p_ru;
+ PROC_SLOCK(p);
calcru(p, &ru.ru_utime, &ru.ru_stime);
+ PROC_SUNLOCK(p);
PROC_UNLOCK(p);
if (((uap->options & SVR4_WNOWAIT)) == 0) {
@@ -1288,7 +1294,9 @@ loop:
pid = p->p_pid;
ru = p->p_ru;
status = SIGCONT;
+ PROC_SLOCK(p);
calcru(p, &ru.ru_utime, &ru.ru_stime);
+ PROC_SUNLOCK(p);
PROC_UNLOCK(p);
if (((uap->options & SVR4_WNOWAIT)) == 0) {
OpenPOWER on IntegriCloud