diff -urN 2.3.48/kernel/sched.c sched-2/kernel/sched.c --- 2.3.48/kernel/sched.c Sun Feb 27 06:19:45 2000 +++ sched-2/kernel/sched.c Sun Feb 27 18:07:28 2000 @@ -232,17 +232,26 @@ * only if it's RT or if it's iteractive and the preferred * cpu won't reschedule shortly. */ - if ((p->avg_slice < cacheflush_time && cpu_curr(best_cpu)->avg_slice > cacheflush_time) || - p->policy != SCHED_OTHER) + if (p->avg_slice < cacheflush_time || + ((p->policy & ~SCHED_YIELD) != SCHED_OTHER)) { + int weight, best_weight = 0; + struct task_struct * best_tsk = NULL; + for (i = smp_num_cpus - 1; i >= 0; i--) { cpu = cpu_logical_map(i); if (cpu == best_cpu) continue; tsk = cpu_curr(cpu); - if (preemption_goodness(tsk, p, cpu) > 0) - goto send_now; + weight = preemption_goodness(tsk, p, cpu); + if (weight > best_weight) { + best_weight = weight; + best_tsk = tsk; + } } + + if ((tsk = best_tsk)) + goto send_now; } spin_unlock_irqrestore(&runqueue_lock, flags);