Acquire the process mutex and spin locks before calling thread_exit() in

kthread_exit() to fix panics when using INVARIANTS.
This commit is contained in:
jhb 2007-11-15 21:45:17 +00:00
parent c54a45c99c
commit b113160d81

View File

@ -317,14 +317,21 @@ kthread_add(void (*func)(void *), void *arg, struct proc *p,
void
kthread_exit(void)
{
/* a module may be waiting for us to exit */
struct proc *p;
/* A module may be waiting for us to exit. */
wakeup(curthread);
/*
* We could rely on thread_exit to call exit1() but
* there is extra work that needs to be done
*/
if (curthread->td_proc->p_numthreads == 1)
kproc_exit(0); /* never returns */
p = curthread->td_proc;
PROC_LOCK(p);
PROC_SLOCK(p);
thread_exit();
}