From 1f9f5df61da5a93f75136c4c3b192c61cd834474 Mon Sep 17 00:00:00 2001 From: Julian Elischer Date: Mon, 13 Sep 2004 23:06:39 +0000 Subject: Commit a fix for some panics we've been seeing with preemption. MFC after: 2 days --- sys/kern/kern_switch.c | 12 ++++++++++-- 1 file changed, 10 insertions(+), 2 deletions(-) (limited to 'sys/kern') diff --git a/sys/kern/kern_switch.c b/sys/kern/kern_switch.c index b937f8a91955..786c22bff0a1 100644 --- a/sys/kern/kern_switch.c +++ b/sys/kern/kern_switch.c @@ -224,7 +224,6 @@ slot_fill(struct ksegrp *kg) } } -#ifdef SCHED_4BSD /* * Remove a thread from its KSEGRP's run queue. * This in turn may remove it from a KSE if it was already assigned @@ -274,7 +273,6 @@ remrunqueue(struct thread *td) /* slot_fill(kg); */ /* will replace it with another */ } } -#endif /* * Change the priority of a thread that is on the run queue. @@ -528,8 +526,18 @@ maybe_preempt(struct thread *td) /* * Our thread state says that we are already on a run queue, so * update our state as if we had been dequeued by choosethread(). + * However we must not actually be on the system run queue yet. */ MPASS(TD_ON_RUNQ(td)); + MPASS(td->td_sched->ke_state != KES_ONRUNQ); + if (td->td_proc->p_flag & P_HADTHREADS) { + /* + * If this is a threaded process we actually ARE on the + * ksegrp run queue so take it off that first. + */ + remrunqueue(td); /* maybe use a simpler version */ + } + TD_SET_RUNNING(td); CTR3(KTR_PROC, "preempting to thread %p (pid %d, %s)\n", td, td->td_proc->p_pid, td->td_proc->p_comm); -- cgit v1.2.3