Why do the CFS chase fairness?

Mulyadi Santosa mulyadi.santosa at gmail.com
Mon Sep 19 10:54:18 EDT 2011

Hi :)

On Mon, Sep 19, 2011 at 21:22, Parmenides <mobile.parmenides at gmail.com> wrote:
>   Well, even with the CFS scheduler, tasks still can have different
> processor shares according to their priorities.

Correct and agree :)

> Conceptually, for
> examp, suppose that there are three tasks with priorities 1, 2, 3,
> respectively. For some fixed schedule period (targeted latency), which
> determined by the number of tasks in run queue, the three tasks obtain
> their CPU shares: 1/6, 2/6, 3/6 of the schedule period. Of course, in
> reality, CPU share of each tasks also needs its weight (determined by
> task's priority) be taken into account.

correct again. This "weighting" mechanism is the core of making
"fairness" happen...or at least approaching such situation.

>   So, I can not see the differences between traditional schedulers,
> which are based on timeslice, and the CFS scheduler, which divide some
> schedule period into shares in proportion to tasks' priorities. It
> seems that both take the same effect.

Neither do I :)

Seriously, what I consider "more fair" is Con Kolivas BFS scheduler
these days. No excessive "time slice weighting", just priority
stepping and very strict deadline.

>>>   2. Why do processes need fairness?
>> To achieve highest response time IMHO.
>   How does fairness give tasks more higher response time?
I took this chance to add: to maximize throughput too...

well, if you have processess let's say A, B, C. A and B are CPU bound,
C sleeps most of the times (let's say it's vim process running)

If a scheduler implement very fair scheduling, then whenever user
press a key in vim window, C should be kicked in ASAP and then run.
However, as C yields its time slice, A or B should back ASAP too.

If the scheduler is not really fair, then C should wait longer to be
back running. But C should not be given too much time so A and B have
more time to complete their number crunching works

Between A and B themselves should be balance somewhat, but not too
short. Too short and they would spend more time switching to each
other, too long and we would see they starve each other.

Above are my interpretation, so pls CMIIW...


Mulyadi Santosa
Freelance Linux trainer and consultant

blog: the-hydra.blogspot.com
training: mulyaditraining.blogspot.com

More information about the Kernelnewbies mailing list