summaryrefslogtreecommitdiff
path: root/sys
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
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')
-rw-r--r--sys/kern/kern_exit.c33
-rw-r--r--sys/kern/kern_proc.c15
-rw-r--r--sys/sys/mplock.h5
-rw-r--r--sys/sys/proc.h4
4 files changed, 24 insertions, 33 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);
diff --git a/sys/sys/mplock.h b/sys/sys/mplock.h
index 01a04a369cd..247d3f06fa9 100644
--- a/sys/sys/mplock.h
+++ b/sys/sys/mplock.h
@@ -1,4 +1,4 @@
-/* $OpenBSD: mplock.h,v 1.3 2004/06/20 17:46:11 pedro Exp $ */
+/* $OpenBSD: mplock.h,v 1.4 2004/07/22 15:42:11 art Exp $ */
/*
* Copyright (c) 2004 Niklas Hallqvist. All rights reserved.
@@ -165,7 +165,4 @@ __mp_lock_held(struct __mp_lock *lock) {
extern struct __mp_lock kernel_lock;
-/* XXX Should really be in proc.h but then __mp_lock is not defined. */
-extern struct SIMPLELOCK deadproc_slock;
-
#endif /* !_MPLOCK_H */
diff --git a/sys/sys/proc.h b/sys/sys/proc.h
index 11049171027..4ab6cfe9c9c 100644
--- a/sys/sys/proc.h
+++ b/sys/sys/proc.h
@@ -1,4 +1,4 @@
-/* $OpenBSD: proc.h,v 1.74 2004/06/21 23:12:14 art Exp $ */
+/* $OpenBSD: proc.h,v 1.75 2004/07/22 15:42:11 art Exp $ */
/* $NetBSD: proc.h,v 1.44 1996/04/22 01:23:21 christos Exp $ */
/*-
@@ -367,8 +367,6 @@ LIST_HEAD(proclist, proc);
extern struct proclist allproc; /* List of all processes. */
extern struct proclist zombproc; /* List of zombie processes. */
-extern struct proclist deadproc; /* List of dead processes. */
-
extern struct proc *initproc; /* Process slots for init, pager. */
extern struct proc *syncerproc; /* filesystem syncer daemon */