diff options
author | tanimura <tanimura@FreeBSD.org> | 2002-02-23 11:12:57 +0000 |
---|---|---|
committer | tanimura <tanimura@FreeBSD.org> | 2002-02-23 11:12:57 +0000 |
commit | a09da298590e8c11ebafa37f79e0046814665237 (patch) | |
tree | 2289c653c0f7aa23498f82b603c33107952652ec /sys/kern/kern_resource.c | |
parent | 33e8ee5265ca2838260ab581a9cebdedb1e1e29b (diff) | |
download | FreeBSD-src-a09da298590e8c11ebafa37f79e0046814665237.zip FreeBSD-src-a09da298590e8c11ebafa37f79e0046814665237.tar.gz |
Lock struct pgrp, session and sigio.
New locks are:
- pgrpsess_lock which locks the whole pgrps and sessions,
- pg_mtx which protects the pgrp members, and
- s_mtx which protects the session members.
Please refer to sys/proc.h for the coverage of these locks.
Changes on the pgrp/session interface:
- pgfind() needs the pgrpsess_lock held.
- The caller of enterpgrp() is responsible to allocate a new pgrp and
session.
- Call enterthispgrp() in order to enter an existing pgrp.
- pgsignal() requires a pgrp lock held.
Reviewed by: jhb, alfred
Tested on: cvsup.jp.FreeBSD.org
(which is a quad-CPU machine running -current)
Diffstat (limited to 'sys/kern/kern_resource.c')
-rw-r--r-- | sys/kern/kern_resource.c | 34 |
1 files changed, 28 insertions, 6 deletions
diff --git a/sys/kern/kern_resource.c b/sys/kern/kern_resource.c index ffcd488..c15c631 100644 --- a/sys/kern/kern_resource.c +++ b/sys/kern/kern_resource.c @@ -111,14 +111,25 @@ getpriority(td, uap) case PRIO_PGRP: { register struct pgrp *pg; - if (uap->who == 0) + PGRPSESS_SLOCK(); + if (uap->who == 0) { pg = curp->p_pgrp; - else if ((pg = pgfind(uap->who)) == NULL) - break; + PGRP_LOCK(pg); + } else { + pg = pgfind(uap->who); + if (pg == NULL) { + PGRPSESS_SUNLOCK(); + break; + } + } + PGRPSESS_SUNLOCK(); LIST_FOREACH(p, &pg->pg_members, p_pglist) { + PROC_LOCK(p); if (!p_cansee(curp, p) && p->p_ksegrp.kg_nice /* XXXKSE */ < low) low = p->p_ksegrp.kg_nice /* XXXKSE */ ; + PROC_UNLOCK(p); } + PGRP_UNLOCK(pg); break; } @@ -185,16 +196,27 @@ setpriority(td, uap) case PRIO_PGRP: { register struct pgrp *pg; - if (uap->who == 0) + PGRPSESS_SLOCK(); + if (uap->who == 0) { pg = curp->p_pgrp; - else if ((pg = pgfind(uap->who)) == NULL) - break; + PGRP_LOCK(pg); + } else { + pg = pgfind(uap->who); + if (pg == NULL) { + PGRPSESS_SUNLOCK(); + break; + } + } + PGRPSESS_SUNLOCK(); LIST_FOREACH(p, &pg->pg_members, p_pglist) { + PROC_LOCK(p); if (!p_cansee(curp, p)) { error = donice(curp, p, uap->prio); found++; } + PROC_UNLOCK(p); } + PGRP_UNLOCK(pg); break; } |