Uniprocessor Scheduling II
Chapter 9
Shortest Process Next
Nonpreemptive policyProcess with shortest expected processing
time is selected nextShort process jumps ahead of longer
processes
0 5 10 15 20
1
2
3
4
5P3: 4 time unitsP4: 5 time unitsP5 2 time units
Shortest Process Next
Predictability of longer processes is reduced
If estimated time for process not correct, the operating system may abort it
Possibility of starvation for longer processes
Shortest Remaining Time
SRT is a preemptive version of shortest process next (SPN) policy
Must estimate processing time
0 5 10 15 20
1
2
3
4
5
P2 Remaining 5 time units
P3 Remaining 4 time units
P2 Remaining 5 time unitsP4 Remaining 5 time unitsP5 Remaining 2 time units
Highest Response Ratio Next (HRRN)
Choose next process with the greatest value of RR
No PreemptiveRR =(w+s)/s =time spent waiting+expected service timeexpected service timeP5 RR=( (13-8) + 2)/2 = 3.5 // P5 has been chosen at 13P4 RR=( (13-6) + 5)/5 = 2.4
1
2
3
4
5
0 5 10 15 20
P5 RR =3.5
P4 RR = 2.4P3 RR=2.25P4 RR = 1.6P5 RR = 1.5
Feedback
Scheduling is done on a preemptive basis, and a dynamic priority mechanisms is used.
When s process first enters the system, it is placed in RQ0. After its first execution, when it returns to the Ready state, it is placed in RQ1.
Feedback (q = 1)
Penalize jobs that have been running longer. Focus on the time spent in execution so far.
Don’t know remaining time process needs to execute
0 5 10 15 20
1
2
3
4
5
0 10 1
0 12
00
11
22
33
3
4
4
5
RQ4
RQ3RQ2RQ1RQ0
RQ5
When a process first enters the system, it is placed in RQ0. After its first execution, when it returns to the Ready state, it is placed in RQ1 ……
In general, a process scheduled from RQi is allowed to execute 2 i time units (1, 2, 4, 8, …...) before preemption.
Feedback q=2i
0 5 10 15 20
1
2
3
4
5
0 10 1(2) 2(4)0 1(2)
0 1(2)0 1
22
RQ2, 4 time unitsRQ1,2 time units
Question - Case Study (1)
Consider the following set of processes: Process Name Arrival Time Processing Time
1 0 32 1 53 3 24 9 55 12 5
Perform the analysis of a comparison of scheduling policies(FCFS, RR(q=1), RR(q=4), SPN, SRT, HRRN, Feedback(q=1), and Feedback(q=2 i) )
Solution of Question (2)
0 0 0 0 0 0 0 0 0 0 1 1 1 1 1 1 1 1 1 1 2 0 1 2 3 4 5 6 7 8 9 0 1 2 3 4 5 6 7 8 9 0
FCFS 1 1 1 2 2 2 2 2 3 3 4 4 4 4 4 5 5 5 5 5
RR 1 2 1 2 3 1 2 3 2 4 2 4 5 4 5 4 5 4 5 5q=1RR 1 1 1 2 2 2 2 3 3 2 4 4 4 4 5 5 5 5 4 5q=4SPN 1 1 1 3 3 2 2 2 2 2 4 4 4 4 4 5 5 5 5 5
SRT 1 1 1 3 3 2 2 2 2 2 4 4 4 4 4 5 5 5 5 5
HRRN 1 1 1 2 2 2 2 2 3 3 4 4 4 4 4 5 5 5 5 5
FB 1 2 1 3 2 3 1 2 2 4 2 4 5 4 5 4 5 4 5 5q=1FB 1 2 1 1 3 2 2 3 2 2 4 4 5 4 4 5 5 4 5 5q=2i
* Each square represents one time unit. The number refers to the running process
Solution of Question - FCFS (3)
0 0 0 0 0 0 0 0 0 0 1 1 1 1 1 1 1 1 1 1 2 0 1 2 3 4 5 6 7 8 9 0 1 2 3 4 5 6 7 8 9 0
FCFS 1 1 1 2 2 2 2 2 3 3 4 4 4 4 4 5 5 5 5 5
* Each square represents one time unit. The number refers to the running process
First Come First Served (FCFS)Process Pi 1 2 3 4 5 AverageArrival Time Ta 0 1 3 9 12Service Time Ts 3 5 2 5 5Finish Time Tf 3 8 10 15 20Turnaround Time Tq 3.0 7.0 7.0 6.0 8.0 6.20 Tq = Tf - Ta Normalized Tq/Ts 1.0 1.4 3.5 1.2 1.6 1.74Turnaround Time
Solution of Question Round Robin q=1
0 0 0 0 0 0 0 0 0 0 1 1 1 1 1 1 1 1 1 1 2 0 1 2 3 4 5 6 7 8 9 0 1 2 3 4 5 6 7 8 9 0 P1P2P3P4P5 1 2 1 2 3 1 2 3 2 4 2 4 5 4 5 4 5 4 5 5
0
1
1
3
2
5
3
4
9
9
10
12
12
13 15
14 16
17
Ready Time
7
Solution of Question - RR (q=1) (4)
0 0 0 0 0 0 0 0 0 0 1 1 1 1 1 1 1 1 1 1 2 0 1 2 3 4 5 6 7 8 9 0 1 2 3 4 5 6 7 8 9 0
RR 1 2 1 2 3 1 2 3 2 4 2 4 5 4 5 4 5 4 5 5q=1
* Each square represents one time unit. The number refers to the running process
Round Robin (RR q=1)Process Pi 1 2 3 4 5 AverageArrival Time Ta 0 1 3 9 12Service Time Ts 3 5 2 5 5Finish Time Tf 6 11 8 18 20Turnaround Time Tq 6 10 5 9 8 7.6 Tq = Tf - Ta Normalized Tq/Ts 2.0 2.0 2.5 1.8 1.6 1.98Turnaround Time
Solution of Question Round Robin q=4
0 0 0 0 0 0 0 0 0 0 1 1 1 1 1 1 1 1 1 1 2 0 1 2 3 4 5 6 7 8 9 0 1 2 3 4 5 6 7 8 9 0 P1P2P3P4P5 1 1 1 2 2 2 2 3 3 2 4 4 4 4 5 5 5 5 4 5
0
1
3
7
9
1214
18
Ready Time
Solution of Question - RR (q=4) (5)
0 0 0 0 0 0 0 0 0 0 1 1 1 1 1 1 1 1 1 1 2 0 1 2 3 4 5 6 7 8 9 0 1 2 3 4 5 6 7 8 9 0
RR 1 1 1 2 2 2 2 3 3 2 4 4 4 4 5 5 5 5 4 5q=4
* Each square represents one time unit. The number refers to the running process
Round Robin (RR q=4)Process Pi 1 2 3 4 5 AverageArrival Time Ta 0 1 3 9 12Service Time Ts 3 5 2 5 5Finish Time Tf 3 10 9 19 20Turnaround Time Tq 3 9 6 10 8 7.20 Tq = Tf - Ta Normalized Tq/Ts 1.0 1.8 3.0 2.0 1.6 1.88Turnaround Time
Solution of Question - SPN (6)
0 0 0 0 0 0 0 0 0 0 1 1 1 1 1 1 1 1 1 1 2 0 1 2 3 4 5 6 7 8 9 0 1 2 3 4 5 6 7 8 9 0
SPN 1 1 1 3 3 2 2 2 2 2 4 4 4 4 4 5 5 5 5 5
* Each square represents one time unit. The number refers to the running process
Shortest Process Next (SPN)Process Pi 1 2 3 4 5 AverageArrival Time Ta 0 1 3 9 12Service Time Ts 3 5 2 5 5Finish Time Tf 3 10 5 15 20Turnaround Time Tq 3 9 2 6 8 5.60 Tq = Tf - Ta Normalized Tq/Ts 1.0 1.8 1.0 1.2 1.6 1.32Turnaround Time
Solution of Question - SRT (7)
0 0 0 0 0 0 0 0 0 0 1 1 1 1 1 1 1 1 1 1 2 0 1 2 3 4 5 6 7 8 9 0 1 2 3 4 5 6 7 8 9 0
SRT 1 1 1 3 3 2 2 2 2 2 4 4 4 4 4 5 5 5 5 5
* Each square represents one time unit. The number refers to the running process
Shortest Remaining Time (SRT)Process Pi 1 2 3 4 5 AverageArrival Time Ta 0 1 3 9 12Service Time Ts 3 5 2 5 5Finish Time Tf 3 10 5 15 20Turnaround Time Tq 3 9 2 6 8 5.60 Tq = Tf - Ta Normalized Tq/Ts 1.0 1.8 1.0 1.2 1.6 1.32Turnaround Time
Solution of Question - HRRN (8)
0 0 0 0 0 0 0 0 0 0 1 1 1 1 1 1 1 1 1 1 2 0 1 2 3 4 5 6 7 8 9 0 1 2 3 4 5 6 7 8 9 0
HRRN 1 1 1 2 2 2 2 2 3 3 4 4 4 4 4 5 5 5 5 5
* Each square represents one time unit. The number refers to the running process
Highest Response Ratio Next (HRRN)Process Pi 1 2 3 4 5 AverageArrival Time Ta 0 1 3 9 12Service Time Ts 3 5 2 5 5Finish Time Tf 3 8 10 15 20Turnaround Time Tq 3 7 7 6 8 6.20 Tq = Tf - Ta Normalized Tq/Ts 1.0 1.4 3.5 1.2 1.6 1.74Turnaround Time
* At time 3: P2 RR (2+5)/5 = 1.4; P3 RR= (0+2)/2 = 1. So Choose P2
Solution of Question Feedback q=1
0 0 0 0 0 0 0 0 0 0 1 1 1 1 1 1 1 1 1 1 2 0 1 2 3 4 5 6 7 8 9 0 1 2 3 4 5 6 7 8 9 0 P1P2P3P4P5 1 2 1 3 2 3 1 2 2 4 4 4 5 5 5 2 4 5 4 5
0
0
1
0
1
1
2
2
0
3
1
0
2
1 2
3 4
3RQ0
RQ1
RQ3
RQ4
RQ2
4
Solution of Question - FB q=1 (9)
0 0 0 0 0 0 0 0 0 0 1 1 1 1 1 1 1 1 1 1 2 0 1 2 3 4 5 6 7 8 9 0 1 2 3 4 5 6 7 8 9 0
FB 1 2 1 3 2 3 1 2 2 4 4 4 5 5 5 2 4 5 4 5q=1
* Each square represents one time unit. The number refers to the running process
Feedback (FB q=1)Process Pi 1 2 3 4 5 AverageArrival Time Ta 0 1 3 9 12Service Time Ts 3 5 2 5 5Finish Time Tf 7 16 6 19 20Turnaround Time Tq 7 15 3 10 8 8.6 Tq = Tf - Ta Normalized Tq/Ts 2.3 3.0 1.5 2.0 1.6 2.08Turnaround Time
Solution of Question Feedback q= 2i
0 0 0 0 0 0 0 0 0 0 1 1 1 1 1 1 1 1 1 1 2 0 1 2 3 4 5 6 7 8 9 0 1 2 3 4 5 6 7 8 9 0 P1P2P3P4P5 1 2 1 1 3 2 2 3 2 2 4 4 5 4 4 5 5 4 5 5
0
0
1
0
1
1
2
0
0
1
1
2
2RQ0
RQ1RQ2
Solution of Question - FB q= 2i (10)
0 0 0 0 0 0 0 0 0 0 1 1 1 1 1 1 1 1 1 1 2 0 1 2 3 4 5 6 7 8 9 0 1 2 3 4 5 6 7 8 9 0
FB 1 2 1 1 3 2 2 3 2 2 4 4 5 4 4 5 5 4 5 5 q=2i
* Each square represents one time unit. The number refers to the running process
Feedback (FB q = 2i)Process Pi 1 2 3 4 5 AverageArrival Time Ta 0 1 3 9 12Service Time Ts 3 5 2 5 5Finish Time Tf 4 10 8 18 20Turnaround Time Tq 4 9 5 9 8 7.00 Tq = Tf - Ta Normalized Tq/Ts 1.3 1.8 2.5 1.8 1.6 1.81Turnaround Time
Question 1 - Exercise/Home Work (1)
Consider the following set of processes: Process Name Arrival Time Processing Time
1 0 12 1 93 2 14 3 9
Perform the analysis of a comparison of scheduling policies(FCFS, RR(q=1), RR(q=4), SPN, SRT, HRRN, Feedback(q=1), and Feedback(q=2 i) )
Top Related