Re: [PATCH] scheduler cleanup

Andrea Arcangeli (andrea@suse.de)
Wed, 13 Oct 1999 03:59:11 +0200 (CEST)


On Wed, 13 Oct 1999, Artur Skawina wrote:

>Due to popular demand i've extracted just the scheduler fixes. ;)

I had a fast look at the patch and one thing looks obviously wrong:

+/*
+ * A thread calling sched_yield() wants to give up its timeslice and let
+ * other equal priority threads to run.
+ * We optimize by ignoring the request completely when the number of
+ * currently runnable processes is <= the number of available CPUs.
+ * IOW on UP sched_yield() does nothing if this is the only process; on
+ * MP we don't reschedule if there are no processes waiting for a CPU.
+ * [note 'nr_running' is accessed w/o proper locking, but that's ok
+ * -- an application can not use yield() as a synchronization mechanism
+ * anyway -- if we sometimes miss or do an extra reschedule that's fine]
+ */
+ if ( nr_running>smp_num_cpus )
+ {

You can't expect the other running tasks to reschedule idle CPUs as they
may be very fast tasks that needs to run on your CPU as they don't want to
trash the CPU cache. So you must _always_ reschedule if SCHED_YIELD is
asked.

Andrea

-
To unsubscribe from this list: send the line "unsubscribe linux-kernel" in
the body of a message to majordomo@vger.rutgers.edu
Please read the FAQ at http://www.tux.org/lkml/