0% found this document useful (0 votes)
8 views

Vacation Study 4th CFS Code

The document summarizes key elements of the Completely Fair Scheduler (CFS) introduced in the Linux 2.6.23 kernel. CFS aims to maintain fairness by tracking each task's virtual runtime in a red-black tree and always scheduling the task with the least runtime first. It achieves fairness across both running and sleeping tasks by accounting for their virtual runtime even when not running. CFS does not use priorities directly but decays their effect on runtime to determine scheduling order. Tasks belong to scheduling classes like SCHED_OTHER that define how they are scheduled.

Uploaded by

Changmin Lee
Copyright
© Attribution Non-Commercial (BY-NC)
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PPTX, PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
8 views

Vacation Study 4th CFS Code

The document summarizes key elements of the Completely Fair Scheduler (CFS) introduced in the Linux 2.6.23 kernel. CFS aims to maintain fairness by tracking each task's virtual runtime in a red-black tree and always scheduling the task with the least runtime first. It achieves fairness across both running and sleeping tasks by accounting for their virtual runtime even when not running. CFS does not use priorities directly but decays their effect on runtime to determine scheduling order. Tasks belong to scheduling classes like SCHED_OTHER that define how they are scheduled.

Uploaded by

Changmin Lee
Copyright
© Attribution Non-Commercial (BY-NC)
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PPTX, PDF, TXT or read online on Scribd
You are on page 1/ 7

STUDY GROUP

CFS Analysis Based on Source Code


Changmin, Lee
Jan. 18, 2011
CFS Elements
• Niceness (or Nice):
• Weight
• Total weight
• Scale factor
• Period
• Virtual runtime
• Delta_exec
An Overview of CFS
• In kernel 2.6.23, the CFS was introduced

• Main idea: maintaining fairness


• No run queues, but uses a red-black tree
• Determine the fairness
• Virtual runtime:
the smaller amount of time a task has been permitted access to the proc
essor, the higher its need for the processor)
• Sleeper fairness:
to ensure that tasks that are not currently runnable receive a comparabl
e share of the processor when they eventually need it
Virtual Runtime
• Scheduler picks the left-most node of the r-b tree to sched
ule next to maintain fairness

• The task with the CPU adds


its execution time to the virtual
runtime and is then inserted
back into the tree if runnable

• So, the contents of the tree migrate from the right to the le
ft to maintain fairness
• Each runnable task chases the other
CFS Internals
• Priority and CFS
• CFS doesn’t use priorities directly but instead uses them as a deca
y factor for the time a task
• Group scheduling
• Share their virtual runtimes across the group
• e.g. HTTP server; parallelizing incoming connections
• Scheduling Classes
• rt_sched_class ; SCHED_FIFO/RR
• fair_sched_class ; SCHED_OTHER
• idle_sched_class
Scheduling Classes
• How a task will be scheduled?
• Each task belongs to a scheduling class

static inline void check_preempt( struct rq *rq, struct task_struct *p )


{
rq->curr->sched_class->check_preempt_curr( rq, p );
}

If this task were using the fair scheduling class, check_preempt_curr() would resolve to check_preempt_wakeup()
APPENDIX
• Structure hierarchy for tasks and the red-black tree

You might also like