summaryrefslogtreecommitdiffstats
path: root/sys/kern/kern_exit.c
diff options
context:
space:
mode:
authorpeter <peter@FreeBSD.org>2001-09-10 04:28:58 +0000
committerpeter <peter@FreeBSD.org>2001-09-10 04:28:58 +0000
commit96b9a12bd20f300ee8fcf003538e8aa560536c2c (patch)
treefc0a72b711cffb263f307a3b8d70ec96d56e263b /sys/kern/kern_exit.c
parent86ba2579206ed1037ff3581eaaf5854b2821fae9 (diff)
downloadFreeBSD-src-96b9a12bd20f300ee8fcf003538e8aa560536c2c.zip
FreeBSD-src-96b9a12bd20f300ee8fcf003538e8aa560536c2c.tar.gz
Rip some well duplicated code out of cpu_wait() and cpu_exit() and move
it to the MI area. KSE touched cpu_wait() which had the same change replicated five ways for each platform. Now it can just do it once. The only MD parts seemed to be dealing with fpu state cleanup and things like vm86 cleanup on x86. The rest was identical. XXX: ia64 and powerpc did not have cpu_throw(), so I've put a functional stub in place. Reviewed by: jake, tmm, dillon
Diffstat (limited to 'sys/kern/kern_exit.c')
-rw-r--r--sys/kern/kern_exit.c33
1 files changed, 26 insertions, 7 deletions
diff --git a/sys/kern/kern_exit.c b/sys/kern/kern_exit.c
index 8022cb5..812b20e 100644
--- a/sys/kern/kern_exit.c
+++ b/sys/kern/kern_exit.c
@@ -54,6 +54,7 @@
#include <sys/tty.h>
#include <sys/wait.h>
#include <sys/vnode.h>
+#include <sys/vmmeter.h>
#include <sys/resourcevar.h>
#include <sys/signalvar.h>
#include <sys/sx.h>
@@ -67,6 +68,7 @@
#include <vm/vm.h>
#include <vm/vm_param.h>
+#include <vm/vm_extern.h>
#include <vm/pmap.h>
#include <vm/vm_map.h>
#include <vm/vm_zone.h>
@@ -380,13 +382,30 @@ exit1(p, rv)
/*
* Finally, call machine-dependent code to release the remaining
* resources including address space, the kernel stack and pcb.
- * The address space is released by "vmspace_free(p->p_vmspace)";
- * This is machine-dependent, as we may have to change stacks
- * or ensure that the current one isn't reallocated before we
- * finish. cpu_exit will end with a call to cpu_switch(), finishing
- * our execution (pun intended).
+ * The address space is released by "vmspace_free(p->p_vmspace)"
+ * in vm_waitproc();
*/
cpu_exit(p);
+
+ PROC_LOCK(p);
+ mtx_lock_spin(&sched_lock);
+ while (mtx_owned(&Giant))
+ mtx_unlock_flags(&Giant, MTX_NOSWITCH);
+
+ /*
+ * We have to wait until after releasing all locks before
+ * changing p_stat. If we block on a mutex then we will be
+ * back at SRUN when we resume and our parent will never
+ * harvest us.
+ */
+ p->p_stat = SZOMB;
+
+ wakeup(p->p_pptr);
+ PROC_UNLOCK_NOSWITCH(p);
+
+ cnt.v_swtch++;
+ cpu_throw();
+ panic("exit1");
}
#ifdef COMPAT_43
@@ -571,11 +590,11 @@ loop:
}
/*
- * Give machine-dependent layer a chance
+ * Give vm and machine-dependent layer a chance
* to free anything that cpu_exit couldn't
* release while still running in process context.
*/
- cpu_wait(p);
+ vm_waitproc(p);
mtx_destroy(&p->p_mtx);
zfree(proc_zone, p);
nprocs--;
OpenPOWER on IntegriCloud