Uploaded by Lina dona

Linux's Scheduler Presentation

advertisement
The Linux's Scheduler
A case study
What is Linux?
Linux is a group of open-source
operating systems built around the
Linux kernel that was first introduced
by Linux Trovalds.
The Linux package comes with many
software components and libraries,
mostly provided by the GNU project.
One of the key components in the
kernel is the scheduler.
Tasks are the schedulable
units
Linux uses the same internal representation for processes and threads,
it also refers to both as tasks.
Tasks are the smallest units of work that can be scheduled by the
Linux Scheduler
Schedulers before Linux
2.6.23
O(n) scheduler (2.4 to 2.6)
O(1) scheduler (2.6 to 2.6.22)
Schedulers classes
Real time scheduler class
Normal class scheduler
Real time scheduler class
SCHED_RR
using Round-Robin
algorithm
SCHED_FIFO
using First-In-First-Out
algorithm
SCHED_DEADLINE
using Earliest Deadline
First algorithm
Normal scheduler class
SCHED_NORMAL (a.k.a SCHED_OTHER)
using Completely Fair scheduler algorithm
Completely Fair Scheduler (CFS)
CFS uses a red black tree to maintain its ready-to-run tasks
A runnable task is chosen according to its virtual run-time (key in
the tree)
CFS favors tasks with minimum virtual runtime
Completely Fair Scheduler (CFS)
Virtual run-time
It is a measure that depends on: actual running time and the nice value.
CFS uses the nice value of a task in weighing its virtual run-time
Tasks with smaller virtual run-times are favored by the algorithm and chosen
to run on the CPU.
Completely Fair Scheduler (CFS)
how does it work?
CFS allocates CPU time proportions for the tasks with minimal virtual runtime.
It first sets a configurable variable target latency from which it allocates the
proportions of every task. (all tasks must run once during target latency).
Whenever a context switch happens, CFS picks the task with min_vruntime
(A cached value) and gives it the CPU. This task is either inserted back into
the tree or removed after execution.
Completely Fair Scheduler (CFS)
Download