Re: Scheduling bug for SCHED_FIFO and SCHED_RR

From: Nigel Gamble (nigel@nrg.org)
Date: Tue Apr 24 2001 - 20:58:12 EST


On Fri, 20 Apr 2001, Nigel Gamble wrote:
> 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.

This bug is also in the SMP version of reschedule_idle(). The
corresponding fix (against 2.4.3-ac14) is:

--- 2.4.3-ac14/kernel/sched.c Tue Apr 24 18:40:15 2001
+++ linux/kernel/sched.c Tue Apr 24 18:41:32 2001
@@ -246,7 +246,7 @@
          */
         oldest_idle = (cycles_t) -1;
         target_tsk = NULL;
- max_prio = 1;
+ max_prio = 0;
 
         for (i = 0; i < smp_num_cpus; i++) {
                 cpu = cpu_logical_map(i);

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/



This archive was generated by hypermail 2b29 : Mon Apr 30 2001 - 21:00:13 EST