summaryrefslogtreecommitdiff
path: root/sys/kern
diff options
context:
space:
mode:
authorArtur Grabowski <art@cvs.openbsd.org>2004-07-22 15:42:12 +0000
committerArtur Grabowski <art@cvs.openbsd.org>2004-07-22 15:42:12 +0000
commit9b0b5e19d5838a0b76981b51bd903a5cf5f338d2 (patch)
treef7bcf9e72cb6ab44e2491325e08ff96f46687f93 /sys/kern
parent0d602f6a3212ceac34dab1f8ccbdf5561dc7541a (diff)
SIMPLELOCK -> mutex for the lock around deadproc list.
Also move the whole deadproc infrastructure to kern_exit, it's only used there. miod@ ok
Diffstat (limited to 'sys/kern')
-rw-r--r--sys/kern/kern_exit.c33
-rw-r--r--sys/kern/kern_proc.c15
2 files changed, 22 insertions, 26 deletions
diff --git a/sys/kern/kern_exit.c b/sys/kern/kern_exit.c
index 1587724bc08..53bb4326ad8 100644
--- a/sys/kern/kern_exit.c
+++ b/sys/kern/kern_exit.c
@@ -1,4 +1,4 @@
-/* $OpenBSD: kern_exit.c,v 1.51 2004/06/13 21:49:26 niklas Exp $ */
+/* $OpenBSD: kern_exit.c,v 1.52 2004/07/22 15:42:11 art Exp $ */
/* $NetBSD: kern_exit.c,v 1.39 1996/04/22 01:38:25 christos Exp $ */
/*
@@ -59,6 +59,7 @@
#include <sys/sched.h>
#include <sys/ktrace.h>
#include <sys/pool.h>
+#include <sys/mutex.h>
#ifdef SYSVSHM
#include <sys/shm.h>
#endif
@@ -308,6 +309,16 @@ exit1(p, rv)
}
/*
+ * Locking of this proclist is special; it's accessed in a
+ * critical section of process exit, and thus locking it can't
+ * modify interrupt state. We use a simple spin lock for this
+ * proclist. Processes on this proclist are also on zombproc;
+ * we use the p_hash member to linkup to deadproc.
+ */
+struct mutex deadproc_mutex = MUTEX_INITIALIZER(IPL_NONE);
+struct proclist deadproc = LIST_HEAD_INITIALIZER(deadproc);
+
+/*
* We are called from cpu_exit() once it is safe to schedule the
* dead process's resources to be freed.
*
@@ -315,18 +326,17 @@ exit1(p, rv)
* called from a critical section in machine-dependent code, so
* we should refrain from changing any interrupt state.
*
- * We lock the deadproc list (a spin lock), place the proc on that
- * list (using the p_hash member), and wake up the reaper.
+ * We lock the deadproc list, place the proc on that list (using
+ * the p_hash member), and wake up the reaper.
*/
void
-exit2(p)
- struct proc *p;
+exit2(struct proc *p)
{
int s;
- SIMPLE_LOCK(&deadproc_slock);
+ mtx_enter(&deadproc_mutex);
LIST_INSERT_HEAD(&deadproc, p, p_hash);
- SIMPLE_UNLOCK(&deadproc_slock);
+ mtx_leave(&deadproc_mutex);
wakeup(&deadproc);
@@ -346,18 +356,18 @@ reaper(void)
KERNEL_PROC_UNLOCK(curproc);
for (;;) {
- SIMPLE_LOCK(&deadproc_slock);
+ mtx_enter(&deadproc_mutex);
p = LIST_FIRST(&deadproc);
if (p == NULL) {
/* No work for us; go to sleep until someone exits. */
- SIMPLE_UNLOCK(&deadproc_slock);
+ mtx_leave(&deadproc_mutex);
(void) tsleep(&deadproc, PVM, "reaper", 0);
continue;
}
/* Remove us from the deadproc list. */
LIST_REMOVE(p, p_hash);
- SIMPLE_UNLOCK(&deadproc_slock);
+ mtx_leave(&deadproc_mutex);
KERNEL_PROC_LOCK(curproc);
/*
@@ -386,8 +396,7 @@ reaper(void)
/* Noone will wait for us. Just zap the process now */
proc_zap(p);
}
- /* XXXNJW where should this be with respect to
- * the wakeup() above? */
+
KERNEL_PROC_UNLOCK(curproc);
}
}
diff --git a/sys/kern/kern_proc.c b/sys/kern/kern_proc.c
index aa7ec306c56..e92946e351d 100644
--- a/sys/kern/kern_proc.c
+++ b/sys/kern/kern_proc.c
@@ -1,4 +1,4 @@
-/* $OpenBSD: kern_proc.c,v 1.19 2004/06/13 21:49:26 niklas Exp $ */
+/* $OpenBSD: kern_proc.c,v 1.20 2004/07/22 15:42:11 art Exp $ */
/* $NetBSD: kern_proc.c,v 1.14 1996/02/09 18:59:41 christos Exp $ */
/*
@@ -78,16 +78,6 @@ struct pool pgrp_pool;
struct pool session_pool;
struct pool pcred_pool;
-/*
- * Locking of this proclist is special; it's accessed in a
- * critical section of process exit, and thus locking it can't
- * modify interrupt state. We use a simple spin lock for this
- * proclist. Processes on this proclist are also on zombproc;
- * we use the p_hash member to linkup to deadproc.
- */
-struct SIMPLELOCK deadproc_slock;
-struct proclist deadproc; /* dead, but not yet undead */
-
static void orphanpg(struct pgrp *);
#ifdef DEBUG
void pgrpdump(void);
@@ -103,9 +93,6 @@ procinit()
LIST_INIT(&allproc);
LIST_INIT(&zombproc);
- LIST_INIT(&deadproc);
- SIMPLE_LOCK_INIT(&deadproc_slock);
-
pidhashtbl = hashinit(maxproc / 4, M_PROC, M_WAITOK, &pidhash);
pgrphashtbl = hashinit(maxproc / 4, M_PROC, M_WAITOK, &pgrphash);
uihashtbl = hashinit(maxproc / 16, M_PROC, M_WAITOK, &uihash);