--- linux-2.6-npiggin/kernel/sched.c | 12 ++++++++++-- 1 files changed, 10 insertions(+), 2 deletions(-) diff -puN kernel/sched.c~sched-fixup-races kernel/sched.c --- linux-2.6/kernel/sched.c~sched-fixup-races 2005-02-06 14:03:53.000000000 +1100 +++ linux-2.6-npiggin/kernel/sched.c 2005-02-06 14:06:43.000000000 +1100 @@ -298,6 +298,14 @@ static DEFINE_PER_CPU(struct runqueue, r #endif /* + * Is the task currently running or on the runqueue + */ +static int task_onqueue(runqueue_t *rq, task_t *p) +{ + return (p->array || task_running(rq, p)); +} + +/* * task_rq_lock - lock the runqueue a given task resides on and disable * interrupts. Note the ordering: we can safely lookup the task_rq without * explicitly disabling preemption. @@ -836,7 +844,7 @@ static int migrate_task(task_t *p, int d * If the task is not on a runqueue (and not running), then * it is sufficient to simply update the task's cpu field. */ - if (!p->array && !task_running(rq, p)) { + if (!task_onqueue(rq, p)) { set_task_cpu(p, dest_cpu); return 0; } @@ -867,7 +875,7 @@ void wait_task_inactive(task_t * p) repeat: rq = task_rq_lock(p, &flags); /* Must be off runqueue entirely, not preempted. */ - if (unlikely(p->array)) { + if (unlikely(task_onqueue(rq, p))) { /* If it's preempted, we yield. It could be a while. */ preempted = !task_running(rq, p); task_rq_unlock(rq, &flags); _