Related Readings
- Process Scheduling in Linus
- A complete guide to Linux process scheduling
- The Linux Kernel - CFS Scheduler
What is CPU virtualization?
By CPU virtualization, we mean the illusion created by the OS that there are multiple CPUs but in reality there may be only one physical processor on the machine.
Virtualizing CPUs
- time shareing
- space sharing
Switching Between Processes
- Cooperative Approach
- wait for system calls
- trap instruction
- explicit yield system call
- Gain control without cooperation
- timer interrupt and interrupt handler
- A timer can be turned off
context switch
- This is about OS switches running processes.
policies -> scheduling policy
- historical info
- workload knowledge
- performance metrics
process -> machine state
- memory
- registers
- Many instructions explicitly read or update registers
- special
- program counter (instruction pointer)
- stack pointer
- frame pointer
- I/O info
- persistent storage info
General APIs
- create
- destroy
- wait
- status
- miscellanuous control
- fork
- exec
- wait
Process States
- Init
- Running
- Ready
- Blocked
- Final

Limited Direct Execution
- time sharing & control
- trap instruction

Three concepts
- register
- kernel stack
- proc_t
Scheduling
Metrics
Definition. Turnaround Time
\( T_{turnaround} = T_{completion} - T_{arrival}\)
Definition. Resposne Time
\( T_{response} = T_{first run} - T_{arrival} \)
There is a fundamental tradeoff: performance vs fairness
- If you are willing to be unfair, you can run shorter jobs to completion, but at the cost of response time.
Algorithms
- FIFO
- Shortest Job First
- Shortest-Time-to-Comletion-First (STCF)
- Round Robin
- Multi-Level Feedback Queue (MLFQ)
- Proportional Share
- Ticket Assignment
- The Linux Comletely Fair Schedule (CFS)
Notion of time slice
- time slice: short period of time to run a process
- timer-interrupt period
Note that time slice should be a multiple of the timer-interrupt period.
Read a paper of latest scheudling algorithm ?
------------------------------------------------------------------------------------------
Note:
- Obtaining high performance while maintaining control is one of the central challenges in building an operating system.
----- END -----
©2019 - 2024 all rights reserved