From a09da298590e8c11ebafa37f79e0046814665237 Mon Sep 17 00:00:00 2001 From: tanimura Date: Sat, 23 Feb 2002 11:12:57 +0000 Subject: 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) --- sys/fs/procfs/procfs_ctl.c | 4 +++- sys/fs/procfs/procfs_status.c | 6 +++++- 2 files changed, 8 insertions(+), 2 deletions(-) (limited to 'sys/fs/procfs') diff --git a/sys/fs/procfs/procfs_ctl.c b/sys/fs/procfs/procfs_ctl.c index 154eaa6..3a73980 100644 --- a/sys/fs/procfs/procfs_ctl.c +++ b/sys/fs/procfs/procfs_ctl.c @@ -230,8 +230,10 @@ out: pp = pfind(p->p_oppid); PROC_LOCK(p); - if (pp) + if (pp) { + PROC_UNLOCK(pp); proc_reparent(p, pp); + } } else PROC_LOCK(p); p->p_oppid = 0; diff --git a/sys/fs/procfs/procfs_status.c b/sys/fs/procfs/procfs_status.c index 0f8e343..9238dfe 100644 --- a/sys/fs/procfs/procfs_status.c +++ b/sys/fs/procfs/procfs_status.c @@ -48,6 +48,8 @@ #include #include #include +#include +#include #include #include #include @@ -75,9 +77,9 @@ procfs_doprocstatus(PFS_FILL_ARGS) pid = p->p_pid; PROC_LOCK(p); ppid = p->p_pptr ? p->p_pptr->p_pid : 0; - PROC_UNLOCK(p); pgid = p->p_pgrp->pg_id; sess = p->p_pgrp->pg_session; + SESS_LOCK(sess); sid = sess->s_leader ? sess->s_leader->p_pid : 0; /* comm pid ppid pgid sid maj,min ctty,sldr start ut st wmsg @@ -106,6 +108,8 @@ procfs_doprocstatus(PFS_FILL_ARGS) sbuf_printf(sb, "%ssldr", sep); sep = ","; } + SESS_UNLOCK(sess); + PROC_UNLOCK(p); if (*sep != ',') { sbuf_printf(sb, "noflags"); } -- cgit v1.1