Scheduling bug for SCHED_FIFO and SCHED_RR

Nigel Gamble (nigel@nrg.org)
Fri, 20 Apr 2001 16:50:17 -0700 (PDT)


A SCHED_FIFO or SCHED_RR task with priority n+1 will not preempt a
running task with priority n. You need to give the higher priority task
a priority of at least n+2 for it to be chosen by the scheduler.

The problem is caused by reschedule_idle(), uniprocessor version:

if (preemption_goodness(tsk, p, this_cpu) > 1)
tsk->need_resched = 1;

For real-time scheduling to work correctly, need_resched should be set
whenever preemption_goodness() is greater than 0, not 1.

Here is a patch against 2.4.3:

--- 2.4.3/kernel/sched.c Thu Apr 19 15:03:21 2001
+++ linux/kernel/sched.c Fri Apr 20 16:45:07 2001
@@ -290,7 +290,7 @@
struct task_struct *tsk;

tsk = cpu_curr(this_cpu);
- if (preemption_goodness(tsk, p, this_cpu) > 1)
+ if (preemption_goodness(tsk, p, this_cpu) > 0)
tsk->need_resched = 1;
#endif
}

Nigel Gamble nigel@nrg.org
Mountain View, CA, USA. http://www.nrg.org/

MontaVista Software nigel@mvista.com

-
To unsubscribe from this list: send the line "unsubscribe linux-kernel" in
the body of a message to majordomo@vger.kernel.org
More majordomo info at http://vger.kernel.org/majordomo-info.html
Please read the FAQ at http://www.tux.org/lkml/