OS UNIT3 SCHEDULING EXAPLES - Goswami
OS UNIT3 SCHEDULING EXAPLES - Goswami
P1 6 2
P2 3 5
P3 8 1
P4 3 0
P5 4 4
Gantt Chart:
P4 0 3 0-0=0 3
P5 4 4 17-4=13 21-4=17
AvgWT=8 AvgTT=12.8
P3 1 8 16-1=15 15+8=23
P4 0 3 0 0+3=3
P5 4 4 12-4=8 8+4=12
P1 6 2
P2 2 5
P3 8 1
P4 3 0
P5 4 4
P2 5 2 5-5=0 0+2=2
P3 1 8 15-1=14 14+8=22
P4 0 3 0 0+3=3
P5 4 4 7-1-4=2 2+4=6
Round Robin
No issues of starvation or convoy effect. Every job gets a fair
allocation of CPU. No priority scheduling is involved. Total
number of processes on the run queue helps assume the worst-case
response time for a process.
Every process gets an equal share of the CPU.
P1 4
P2 3
Gantt Chart:
EXAMPLE:
Process Arrival Burst WT WT WT TT TT TT
id time time SRTF RR RR
A 0 4 0
B 2 7 8-2=6
C 3 2 4-3=1
D 3 2 6-3=3
WT(A)=4-2-0=2 TT(A)=2+4=6
WT(B)=10-2-2=6 TT(B)=6+7=13
WT(C)=6-3=3 TT(C)=3+2=5
WT(D)=8-3=5 TT(D)=10-3=7 OR (5+2)
P1 0 5
P2 1 3
P3 2 1
P4 3 2
P5 4 3
If the CPU scheduling policy is Round Robin with time
quantum = 2 unit, calculate the average waiting time and
average turn around time.
13 – 5 = 8
P1 13 13 – 0 = 13
OR (12-2-2-0)
11 – 3 = 8
P2 12 12 – 1 = 11
(11-2-1)
P3 5 5–2=3 3–1=2
P4 9 9–3=6 6–2=4
P5 14 14 – 4 = 10 10 – 3 = 7
Disadvantages –
If high priority processes use up a lot of CPU time, lower
priority processes may starve and be postponed indefinitely.
The situation where a process never gets scheduled to run is
called starvation.
Another problem is deciding which process gets which priority
level assigned to it.
Example: consider 4 processes with their burst times and
priorities. (Lower Number Represents Higher Priority. In
This Example).
P1 0 4 2
P2 1 3 3
P3 2 1 4
P4 3 5 5
P5 4 2 5
P1 4–0=4 4–4=0
14 – 3 = 11
P2 15 – 1 = 14
(12-1)
P3 12 – 2 = 10 10 – 1 = 9
P4 9–3=6 6–5=1
P5 11 – 4 = 7 7–2=5
P1 0 4 2
P2 1 3 3
P3 2 1 4
P4 3 5 5
P5 4 2 5
15 – 4 = 11
P1 15 15 – 0 = 15
(12-1-0)=11
P2 12 12 – 1 = 11 11 – 3 = 8
P3 3 3–2=1 1–1=0
P4 8 8–3=5 5–5=0
P5 10 10 – 4 = 6 6–2=4
With the help of this scheduling we can apply various kind of scheduling
for different kind of processes:
For System Processes: First Come First Serve(FCFS) Scheduling.
For Interactive Processes: Shortest Job First (SJF) Scheduling.
For Batch Processes: Round Robin(RR) Scheduling
For Student Processes: Priority Scheduling
P1 136 53 136-53=83
P2 34 17 34-17=17
P3 162 68 162-68=94
125-
P4 125 24
24=101
Gantt chart: