summaryrefslogtreecommitdiffstats
path: root/sys/kern/kern_exit.c
diff options
context:
space:
mode:
authorjulian <julian@FreeBSD.org>2002-12-10 02:33:45 +0000
committerjulian <julian@FreeBSD.org>2002-12-10 02:33:45 +0000
commit9868d96f1fab28e828ad309a400539d072e1da2d (patch)
treeb7b4d7891168c36af86fd5540478865532fe8977 /sys/kern/kern_exit.c
parent9349f701144f7b1af93f420305e9cbf99727d7ed (diff)
downloadFreeBSD-src-9868d96f1fab28e828ad309a400539d072e1da2d.zip
FreeBSD-src-9868d96f1fab28e828ad309a400539d072e1da2d.tar.gz
Unbreak the KSE code. Keep track of zobie threads using the Per-CPU storage
during the context switch. Rearrange thread cleanups to avoid problems with Giant. Clean threads when freed or when recycled. Approved by: re (jhb)
Diffstat (limited to 'sys/kern/kern_exit.c')
-rw-r--r--sys/kern/kern_exit.c30
1 files changed, 6 insertions, 24 deletions
diff --git a/sys/kern/kern_exit.c b/sys/kern/kern_exit.c
index 0ee27b7..38d8092 100644
--- a/sys/kern/kern_exit.c
+++ b/sys/kern/kern_exit.c
@@ -483,7 +483,7 @@ exit1(td, rv)
/*
* Finally, call machine-dependent code to release the remaining
- * resources including address space, the kernel stack and pcb.
+ * resources including address space.
* The address space is released by "vmspace_exitfree(p)" in
* vm_waitproc().
*/
@@ -493,6 +493,7 @@ exit1(td, rv)
PROC_LOCK(p->p_pptr);
sx_xunlock(&proctree_lock);
mtx_lock_spin(&sched_lock);
+
while (mtx_owned(&Giant))
mtx_unlock(&Giant);
@@ -512,11 +513,11 @@ exit1(td, rv)
cpu_sched_exit(td); /* XXXKSE check if this should be in thread_exit */
/*
- * Make sure this thread is discarded from the zombie.
+ * Make sure the scheduler takes this thread out of its tables etc.
* This will also release this thread's reference to the ucred.
+ * Other thread parts to release include pcb bits and such.
*/
thread_exit();
- panic("exit1");
}
#ifdef COMPAT_43
@@ -570,9 +571,6 @@ wait1(td, uap, compat)
int nfound;
struct proc *p, *q, *t;
int status, error;
- struct thread *td2;
- struct kse *ke;
- struct ksegrp *kg;
q = td->td_proc;
if (uap->pid == 0) {
@@ -717,25 +715,9 @@ loop:
}
/*
- * There should only be one
- * but do it right anyhow.
+ * do any thread-system specific cleanups
*/
- FOREACH_KSEGRP_IN_PROC(p, kg) {
- FOREACH_KSE_IN_GROUP(kg, ke) {
- /* Free the KSE spare thread. */
- if (ke->ke_tdspare != NULL) {
- thread_free(ke->ke_tdspare);
- ke->ke_tdspare = NULL;
- }
- }
- }
- FOREACH_THREAD_IN_PROC(p, td2) {
- if (td2->td_standin != NULL) {
- thread_free(td2->td_standin);
- td2->td_standin = NULL;
- }
- }
- thread_reap(); /* check for zombie threads */
+ thread_wait(p);
/*
* Give vm and machine-dependent layer a chance
OpenPOWER on IntegriCloud