Ensuring Technical Readiness For Copilot in Microsoft 365
Scheduling Algorithms
1. Nov 2nd 2012
Julian Ilham
Dept. of Electronic Engineering
Pukyong National University
Email: ilham.julian@gmail.com
1
2. Introduction
Preemptive vs Non-Preemptive
First Come First Served (FCFS)
Shortest Job First (SJF)
Priority Based Scheduling
Round Robin (RR)
2
3. What is scheduling?
Choosing which task to run and for how long
Why do we need it?
- Improve the system performance
- Support multitasking
3
4. Running task can be forced to release even
Preemptive
though it is neither completed
Each running task keeps processing until it
Non - Preemptive
completed
4
5. Only available in Non-Preemptive mode
Example:
Tasks Arrival Times (ms) Burst Time (ms)
P2 0.0 12
P3 3.0 8
P4 5.0 4
P1 10.0 10
P5 12.0 6
Gantt chart
P2 P3 P4 P1 P5
0 20 24 34 40 (ms)
3 5 10 12
5
6. Time Calculation
P1 : 24 – 10 = 12 ms
P2 : 0 ms
P3 : 12 – 3 = 9 ms
P4 : 20 – 5 = 15 ms
P5 : 34 – 12 = 22 ms
Total waiting time : P1 + P2 + P3 + P4 + P5 = 58 ms
Average waiting time : 58 ms / 5 = 11.6 ms
6
7. Advantage: Very simple code and structure
Disadvantage: Large average waiting time
7
8. Available in Preemptive and Non-Preemptive mode
Example (Preemptive)
Tasks Arrival Times (ms) Burst Time (ms)
P2 0.0 12
P3 3.0 8
P4 5.0 4
P1 10.0 10
P5 12.0 6
Gantt chart
P2 P3 P4 P3 P5 P2 P1
0 9 15 21 30 40 (ms)
3 5 10 12
8
9. Time Calculation (Preemptive)
P1 : 30 – 10 = 20 ms
P2 : 0 + (21 – 3) = 18 ms
P3 : (3 – 3) + (9 – 5) = 4 ms
P4 : 5 – 5 = 0 ms
P5 : 15 – 12 = 3 ms
Total waiting time : P1 + P2 + P3 + P4 + P5 = 45 ms
Average waiting time : 45 ms / 5 = 9 ms
9
11. Time Calculation (Non-Preemptive)
P1 : 30 – 10 = 20 ms
P2 : 0 ms
P3 : 22 – 3 = 19 ms
P4 : 12 – 5 = 7 ms
P5 : 16 – 12 = 4 ms
Total waiting time : P1 + P2 + P3 + P4 + P5 = 50 ms
Average waiting time : 50 ms / 5 = 10 ms
11
12. Advantage: Minimum average waiting time for a given set of
process
Disadvantage: Difficult to estimate burst time, starvation
(indefinite blocking)
12
13. Available in Preemptive and Non-Preemptive mode
Example (Preemptive)
Tasks Arrival Times (ms) Burst Time (ms) Priority
P2 0.0 12 2
P3 3.0 8 5
P4 5.0 4 1
P1 10.0 10 4
P5 12.0 6 3
Gantt chart
P2 P4 P2 P5 P1 P3
0 9 16 22 32 40 (ms)
3 5 10 12
13
14. Time Calculation (Preemptive)
P1 : 22 – 10 = 12 ms
P2 : 9 – 5 = 4 ms
P3 : 32 – 3 = 29 ms
P4 : 5 – 5 = 0 ms
P5 : 16 – 12 = 4 ms
Total waiting time : P1 + P2 + P3 + P4 + P5 = 49 ms
Average waiting time : 49 ms / 5 = 9.8 ms
14
16. Time Calculation (Non-Preemptive)
P1 : 22 – 10 = 12 ms
P2 : 0 ms
P3 : 32 – 3 = 29 ms
P4 : 12 – 5 = 7 ms
P5 : 16 – 12 = 4 ms
Total waiting time : P1 + P2 + P3 + P4 + P5 = 52 ms
Average waiting time : 52 ms / 5 = 10.4 ms
16
17. Advantage: Easier than SJF
Disadvantage: Can cause indefinite blocking
17
18. Only available in Non-Preemptive mode
FCFS is used in sequencing policy
Need to determine time slice/ quantum as a unit of time for
each process
Then continue to the next process after reaching maximum of
quantum
- Too small time quantum -> too many tasks switched
- Too large time quantum -> inherits the problem of FCFS
18
Today, I am going to present about scheduling algoritmScheduling algorithm is method inside the operating system in order to manage many tasks
There are two types of scheduling methodPreemptive = can be interruptedNon-Preemptive = New task can be run after the current task is finished (can not be interrupted)