RE: Question about sched_yield()

mgix@mgix.com
Tue, 18 Jun 2002 13:12:35 -0700


Let's do a little thought experiment with 2
naive scheduling algorithms and see what happens:

Algorithm 1: the FIFO (favours those that haven't had it yet over those who already had it)
- All ready to run processes are in a FIFO queue.
- The top of the queue is the yielder
- It's given a slice of CPU time to run on
- It gives it back right away.
- It's sent to back to the queue.
- The next in line is a task that does real work.
- It gets a time slice and fully uses it.
- etc ...

Algorithm 1 will have the expected behaviour: yielders
won't consume anything, workers get it all.

Algorithm 2: the Monte-Carlo scheduler (favours no one, schedules blindly)
- All ready to run processes are are kept in a black bag
- The scheduler randomly grabs one out of the bag
- It's given a slice of CPU time to run on
- If it's a yielder, it gives the CPU right back
- If it's an actual worker, it makes full use of the slice.
- etc ...

Lo and behold, Algorithm 2 exhibits the same behaviour as well:
yielders get nothing since they give it all away, and workers
get it all.

Now, if I understand you well enough David, you'd like an
algorithm where the less you want the CPU, the more you get
it. I'd love if you could actually give us an outlook of
your ideal scheduler so I can try my thought experiment on it,
because from what I've understood so far, your hypothetical
scheduler would allocate all of the CPU to the yielders.

Also, since it seems to worry you: no I'm not using sched_yield
to implement pseudo-blocking behaviour.

- Mgix

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