From da98a74234d770fbe15d09a3a0f51778cb9d9974 Mon Sep 17 00:00:00 2001 From: jeff Date: Thu, 11 Dec 2003 04:00:49 +0000 Subject: - In sched_switch(), if a thread has been assigned, don't touch the runqueues or load. These things have already been taken care of in sched_bind() which should be the only place that we're switching in an assigned thread. --- sys/kern/sched_ule.c | 36 +++++++++++++++++++++--------------- 1 file changed, 21 insertions(+), 15 deletions(-) diff --git a/sys/kern/sched_ule.c b/sys/kern/sched_ule.c index 1c47384..f7a9636 100644 --- a/sys/kern/sched_ule.c +++ b/sys/kern/sched_ule.c @@ -1062,21 +1062,27 @@ sched_switch(struct thread *td) td->td_oncpu = NOCPU; td->td_flags &= ~TDF_NEEDRESCHED; - if (TD_IS_RUNNING(td)) { - if (td->td_proc->p_flag & P_SA) { - kseq_load_rem(KSEQ_CPU(ke->ke_cpu), ke); - setrunqueue(td); - } else - kseq_runq_add(KSEQ_SELF(), ke); - } else { - if (ke->ke_runq) - kseq_load_rem(KSEQ_CPU(ke->ke_cpu), ke); - /* - * We will not be on the run queue. So we must be - * sleeping or similar. - */ - if (td->td_proc->p_flag & P_SA) - kse_reassign(ke); + /* + * If the KSE has been assigned it may be in the process of switching + * to the new cpu. This is the case in sched_bind(). + */ + if ((ke->ke_flags & KEF_ASSIGNED) == 0) { + if (TD_IS_RUNNING(td)) { + if (td->td_proc->p_flag & P_SA) { + kseq_load_rem(KSEQ_CPU(ke->ke_cpu), ke); + setrunqueue(td); + } else + kseq_runq_add(KSEQ_SELF(), ke); + } else { + if (ke->ke_runq) + kseq_load_rem(KSEQ_CPU(ke->ke_cpu), ke); + /* + * We will not be on the run queue. So we must be + * sleeping or similar. + */ + if (td->td_proc->p_flag & P_SA) + kse_reassign(ke); + } } newtd = choosethread(); if (td != newtd) -- cgit v1.1