Shortest job first (preemptive) scheduling
Click here to load reader
-
Upload
baljitsaini28 -
Category
Engineering
-
view
1.191 -
download
4
Transcript of Shortest job first (preemptive) scheduling
SJF(Shortest Job First)Pre-emptive
Baljit Singh Saini
Key points
• Also called Shortest Remaining Time First• Suffers from starvation problem
process Burst time Arrival time
P1 6 2
P2 2 5
P3 8 1
P4 3 0
P5 4 4
P40
0
Baljit Singh Saini
process Burst time Arrival time
P1 6 2
P2 2 5
P3 8 1
P4 3/2 0
P5 4 4
P4
1
0
P3
Baljit Singh Saini
process Burst time Arrival time
P1 6 2
P2 2 5
P3 8 1
P4 3/1 0
P5 4 4
P4
2
0
P3 P1
Baljit Singh Saini
process Burst time Arrival time
P1 6 2
P2 2 5
P3 8 1
P4 3 0
P5 4 4
P4
3
0
P3 P1
3
Baljit Singh Saini
process Burst time Arrival time
P1 6 2
P2 2 5
P3 8 1
P4 3 0
P5 4 4
P4
3
0
P3 P1
3
Baljit Singh Saini
Which is Smaller Job:P3 or P1 ?
process Burst time Arrival time
P1 6/5 2
P2 2 5
P3 8 1
P4 3 0
P5 4 4
P4
4
0
P1
P3
3
P5
Baljit Singh Saini
Which is Smaller Job:P3, P5 or P1 ?
4
process Burst time Arrival time
P1 6/5 2
P2 2 5
P3 8 1
P4 3 0
P5 4/3 4
P4
5
0
P1
P3
3
P5
Baljit Singh Saini
4
P2
Which is Smaller Job:P3, P5 or P2 ?
5
P1
process Burst time Arrival time
P1 6/5 2
P2 2 5
P3 8 1
P4 3 0
P5 4/3 4
P4
6
0
P1
P3
3
P5
Baljit Singh Saini
4
P2
5
P1 P5
process Burst time Arrival time
P1 6/5 2
P2 2 5
P3 8 1
P4 3 0
P5 4/3 4
P4
7
0
P1
P3
3
P5
Baljit Singh Saini
4
P2
5 7
P1 P5
process Burst time Arrival time
P1 6/5 2
P2 2 5
P3 8 1
P4 3 0
P5 4/3 4
P4
7
0
P1
P3
3
P5
Baljit Singh Saini
4
P2
5 7
P1 P5
Which is Smaller Job:P3, P5 or P1 ?
process Burst time Arrival time
P1 6/5 2
P2 2 5
P3 8 1
P4 3 0
P5 4/2 4
P4
8
0
P1
P3
3
P5
Baljit Singh Saini
4
P2
5 7
P1
P5
process Burst time Arrival time
P1 6/5 2
P2 2 5
P3 8 1
P4 3 0
P5 4/1 4
P4
9
0
P1
P3
3
P5
Baljit Singh Saini
4
P2
5 7
P1
P5
process Burst time Arrival time
P1 6/5 2
P2 2 5
P3 8 1
P4 3 0
P5 4 4
P4
10
0
P1
P3
3
P5
Baljit Singh Saini
4
P2
5 7
P1
P5
10
process Burst time Arrival time
P1 6/5 2
P2 2 5
P3 8 1
P4 3 0
P5 4 4
P4
10
0
P1
P3
3
P5
Baljit Singh Saini
4
P2
5 7
P1
P5
10
process Burst time Arrival time
P1 6/4 2
P2 2 5
P3 8 1
P4 3 0
P5 4 4
P4
11
0
P1
P3
3
P5
Baljit Singh Saini
4
P2
5 7
P1P5
10
process Burst time Arrival time
P1 6/../0 2
P2 2 5
P3 8 1
P4 3 0
P5 4 4
P4
15
0
P1
P3
3
P5
Baljit Singh Saini
4
P2
5 7
P1P5
10 15
process Burst time Arrival time
P1 6 2
P2 2 5
P3 8 1
P4 3 0
P5 4 4
P4
23
0
P1 P3
3
P5
Baljit Singh Saini
4
P2
5 7
P1P5
10 15 23
process Burst time Arrival time
P1 6 2
P2 2 5
P3 8 1
P4 3 0
P5 4 4
P4
23
0
P1 P3
3
P5
Baljit Singh Saini
4
P2
5 7
P1P5
10 15 23
process Burst time Arrival time
P1 6 2
P2 2 5
P3 8 1
P4 3 0
P5 4 4
P4
0
P1 P3
3
P5
Baljit Singh Saini
4
P2
5 7
P1P5
10 15 23
Waiting time = Start time – Arrival time + wait time for next burstP4 = 0 - 0 = 0
P1 = (3 - 2 ) +
P2 = 5 - 5 = 0P5 = 4 – 4+2 = 2P3 = 15 - 1 = 14
Av. Waiting Time = 6 = 7
P1 waited for next burst