L6 CPU Scheduling
L6 CPU Scheduling
CPU Scheduling
• CPU Scheduling
• Goals of Scheduling (objectives)
• Preemptive Vs Nonpreemptive Scheduling
• CPU Scheduling Algorithms
• First-Come, First-Served (FCFS) Scheduling
• Shortest-Job-Next (SJN) Scheduling
• Priority Scheduling
• Shortest Remaining Time
• Round Robin(RR) Scheduling
• Multiple-Level Queues Scheduling
2
CPU Scheduling
3
Context Switch
4
CPU scheduling decisions may take place under the following four
circumstances:
1. When a process switches from the running state to the waiting state
(for. example, I/O request, or invocation of wait for the termination of
one of the child processes).
2. When a process switches from the running state to the ready state
(for example, when an interrupt occurs).
3. When a process switches from the waiting state to the ready state
(for example, completion of I/O).
4. When a process terminates.
5
Criteria used for CPU scheduling algorithms are:
• CPU utilization.
• Throughput.
• Arrival Time
• Burst Time
• Turnaround time= Exit time - Arrival Time
• Waiting time.
• Response time.
• Exit time
6
Goals of Scheduling
• Fairness
• Policy Enforcement
• Efficiency
• Response Time
• Turnaround Time
• Throughput
7
Preemptive/ Non-preemptive Scheduling
8
CPU Scheduling Algorithms
9
First Come First Serve (FCFS)
10
FCFS
11
Shortest Job Next (SJN)
• This is also known as shortest job first, or SJF
• This is a non-preemptive scheduling algorithm.
• Best approach to minimize waiting time.
• Easy to implement in Batch systems where required CPU time is
known in advance.
• Impossible to implement in interactive systems where required CPU
time is not known.
• The processer should know in advance how much time process will
take.
• Given: Table of processes, and their Arrival time, Execution time
12
Shortest Job Next (SJN)
13
Priority Based Scheduling
14
Priority Based Scheduling
15
Shortest Remaining Time
16
Round Robin Scheduling
17
Round Robin Scheduling
18
Conclusion
Learning this topic will enable you to understand various types of CPU
scheduling algorithm. To compare the performance of various
Scheduling algorithms you need to implement these algorithms in OS
Labs.
19
References
https://www.includehelp.com/c-programming-questions/
https://www.studytonight.com/operating-system/
https://computing.llnl.gov/tutorials/
https://www.tutorialspoint.com/operating_system/index.htm#:~:text=An%20operating%20system%20(OS)%20is,software%20in%20a%
20computer%20system.
https://www.javatpoint.com/os-tutorial
https://www.guru99.com/operating-system-tutorial.html
https://www.geeksforgeeks.org/operating-systems/