Re: [RFC] 2.5 TASK_INTERRUPTIBLE preemption race

Robert Love (rml@tech9.net)
14 Apr 2003 18:00:42 -0400


On Mon, 2003-04-14 at 17:54, Joe Korty wrote:

> Is this analysis correct? If it is, perhaps there is an alternative
> to fixing these cases individually: make the TASK_INTERRUPTIBLE/
> TASK_UNINTERRUPTIBLE states block preemption. In which case the
> 'set_current_state(TASK_RUNNING)' macro would need to include the
> same preemption check as 'preemption_enable'.

Thankfully you are wrong or we would have some serious problems :)

See kernel/sched.c :: preempt_schedule() where we set p->preempt_count
to PREEMPT_ACTIVE.

Then see kernel/sched.c :: schedule() where we short-circuit the
remove-from-runqueue code if PREEMPT_ACTIVE is set.

Thus, it is safe to preempt regardless of the task's state. It will
eventually reschedule.

Robert Love

-
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/