Red Hat Bugzilla – Bug 8529
SCHED_RR policy does not seem to work properly
Last modified: 2008-05-01 11:37:53 EDT
Appearance: tasks with SCHED_RR policy are not preempted by other SCHED_RR
tasks of the same static priority over the time quantum. SCHED_RR works
exactly like SCHED_FIFO.
Possible explanation: looking at the schedule() function, it becomes clear
that although an exhausted SCHED_RR task is moved to be last in the
runqueue, it is chosen to run anyway. Indeed, if prev->state was
TASK_RUNNING (as it is when a task is about to be preempted because its
time quantum has expired), the code at "still_running" will set the
initial search pointer ("next") to the exhausted task itself:
if (prev->state == TASK_RUNNING)
c = prev_goodness(prev, prev, this_cpu);
next = prev;
Thus, the search will start from the exhausted task itself and it will be
chosen to run next, resulting in no preemption.
Possible fix: the above "if" statement, if changed to the following:
if (prev->policy != SCHED_RR && prev->state == TASK_RUNNING)
fixes the problem.
Please, correct me if I'm wrong, but I think that's the way SCHED_RR should