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:
John Baldwin 2007-11-15 21:45:17 +00:00
parent 9be53ee86b
commit cd808cec50
Notes: svn2git 2020-12-20 02:59:44 +00:00
svn path=/head/; revision=173658

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();
}