From 02ee911318102761d419034939e0020bd7adb601 Mon Sep 17 00:00:00 2001 From: ups Date: Wed, 13 Oct 2004 22:07:04 +0000 Subject: Fix maybe_preempt_in_ksegrp for !SMP. Tested by: tegge Reviewed by: julian Approved by: sam (mentor) MFC after: 3 days --- sys/kern/kern_switch.c | 40 +++++++++++++++++++++++++++++++++------- 1 file changed, 33 insertions(+), 7 deletions(-) (limited to 'sys/kern/kern_switch.c') diff --git a/sys/kern/kern_switch.c b/sys/kern/kern_switch.c index d6a89bc..68b6bc2 100644 --- a/sys/kern/kern_switch.c +++ b/sys/kern/kern_switch.c @@ -328,9 +328,39 @@ adjustrunqueue( struct thread *td, int newpri) static void maybe_preempt_in_ksegrp(struct thread *td) +#if !defined(SMP) +{ + struct thread *running_thread; + +#ifndef FULL_PREEMPTION + int pri; + pri = td->td_priority; + if (!(pri >= PRI_MIN_ITHD && pri <= PRI_MAX_ITHD)) + return; +#endif + mtx_assert(&sched_lock, MA_OWNED); + running_thread = curthread; + + if (running_thread->td_ksegrp != td->td_ksegrp) + return; + + if (td->td_priority > running_thread->td_priority) + return; +#ifdef PREEMPTION + if (running_thread->td_critnest > 1) + running_thread->td_pflags |= TDP_OWEPREEMPT; + else + mi_switch(SW_INVOL, NULL); + +#else + running_thread->td_flags |= TDF_NEEDRESCHED; +#endif + return; +} + +#else /* SMP */ { struct thread *running_thread; -#if defined(SMP) int worst_pri; struct ksegrp *kg; cpumask_t cpumask,dontuse; @@ -403,12 +433,6 @@ maybe_preempt_in_ksegrp(struct thread *td) } #endif -#else - running_thread = curthread; - KASSERT(running_thread->td_ksegrp == td->td_ksegrp, - ("maybe_preempt_in_ksegrp: No chance to run thread")); -#endif - if (td->td_priority > running_thread->td_priority) return; #ifdef PREEMPTION @@ -422,6 +446,8 @@ maybe_preempt_in_ksegrp(struct thread *td) #endif return; } +#endif /* !SMP */ + int limitcount; void -- cgit v1.1