Uniprocessor Scheduling II Chapter 9 Shortest Process Next























- Slides: 23
Uniprocessor Scheduling II Chapter 9
Shortest Process Next 0 5 10 15 20 1 2 3 4 5 P 3: 4 time units P 4: 5 time units P 5 2 time units z Nonpreemptive policy z Process with shortest expected processing time is selected next z Short process jumps ahead of longer processes
Shortest Process Next z Predictability of longer processes is reduced z If estimated time for process not correct, the operating system may abort it z Possibility of starvation for longer processes
Shortest Remaining Time 0 5 10 15 20 1 2 3 4 5 P 2 Remaining 5 time units P 3 Remaining 4 time units P 2 Remaining 5 time units P 4 Remaining 5 time units P 5 Remaining 2 time units z SRT is a preemptive version of shortest process next (SPN) policy z Must estimate processing time
Highest Response Ratio Next (HRRN) 0 5 15 20 P 5 RR =3. 5 1 2 3 4 5 10 P 4 RR = 2. 4 P 3 RR=2. 25 P 4 RR = 1. 6 P 5 RR = 1. 5 z Choose next process with the greatest value of RR z No Preemptive RR =(w+s)/s =time spent waiting+expected service time P 5 RR=( (13 -8) + 2)/2 = 3. 5 // P 5 has been chosen at 13 P 4 RR=( (13 -6) + 5)/5 = 2. 4
Feedback z Scheduling is done on a preemptive basis, and a dynamic priority mechanisms is used. z When s process first enters the system, it is placed in RQ 0. After its first execution, when it returns to the Ready state, it is placed in RQ 1.
Feedback (q = 1) 5 0 1 2 3 4 5 0 0 1 RQ 0 0 10 15 2 3 1 0 1 1 2 20 3 4 2 3 RQ 1 RQ 2 5 4 RQ 5 RQ 4 RQ 3 z Penalize jobs that have been running longer. Focus on the time spent in execution so far. z Don’t know remaining time process needs to execute
Feedback q=2 i 5 0 1 2 3 4 5 0 0 1 10 15 20 RQ 1, 2 time units RQ 2, 4 time units 1(2) 2(4) 0 1(2) 2 0 1 z When a process first enters the system, it is placed in RQ 0. After its first execution, when it returns to the Ready state, it is placed in RQ 1 …… z In general, a process scheduled from RQi is allowed to execute 2 i time units (1, 2, 4, 8, …. . . ) before preemption.
Question - Case Study (1) z Consider the following set of processes: Process Name Arrival Time Processing Time 1 0 3 2 1 5 3 3 2 4 9 5 5 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 1 1 1 1 1 2 0 1 2 3 4 5 6 7 8 9 0 FCFS 1 1 1 2 2 2 3 3 4 4 4 5 5 5 RR 1 2 3 2 4 5 4 5 4 5 5 RR 1 1 1 2 2 3 3 2 4 4 5 5 4 5 q=1 q=4 SPN 1 1 1 3 3 2 2 2 4 4 4 5 5 5 SRT 1 1 1 3 3 2 2 2 4 4 4 5 5 5 HRRN 1 1 1 2 2 2 3 3 4 4 4 5 5 5 FB 1 2 1 3 2 3 1 2 2 4 5 4 5 4 5 5 FB 1 2 1 1 3 2 2 4 4 5 5 q=1 q=2 i * Each square represents one time unit. The number refers to the running process
Solution of Question - FCFS (3) 0 0 0 0 0 1 1 1 1 1 2 0 1 2 3 4 5 6 7 8 9 0 FCFS 1 1 1 2 2 2 3 3 4 4 4 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 Average Arrival Time Ta 0 1 3 9 12 Service Time Ts 3 5 2 5 5 Finish Time Tf 3 8 10 15 20 Turnaround Time Tq 3. 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. 74 Turnaround Time
Solution of Question Round Robin q=1 00000111112 01234567890 P 1 P 2 P 3 P 4 P 5 1 0 1 Ready Time 3 2 4 3 7 9 5 9 10 12 12 14 13 16 15 17 1212312324245455
Solution of Question - RR (q=1) RR q=1 (4) 0 0 0 0 0 1 1 1 1 1 2 0 1 2 3 4 5 6 7 8 9 0 1 2 3 2 4 5 4 5 4 5 5 * Each square represents one time unit. The number refers to the running process Round Robin (RR q=1) Process Pi 1 2 3 4 Arrival Time Ta 0 1 3 9 Service Time Ts 3 5 2 5 Finish Time Tf 6 11 8 18 Turnaround Time Tq 6 10 5 9 Tq = Tf - Ta Normalized Tq/Ts 2. 0 2. 5 1. 8 Turnaround Time 5 12 5 20 8 Average 1. 6 1. 98 7. 6
Solution of Question Round Robin q=4 00000111112 01234567890 P 1 P 2 P 3 P 4 P 5 Ready Time 0 1 7 3 9 14 12 18 11122223324444555545
Solution of Question - RR (q=4) RR q=4 (5) 0 0 0 0 0 1 1 1 1 1 2 0 1 2 3 4 5 6 7 8 9 0 1 1 1 2 2 3 3 2 4 4 5 5 4 5 * Each square represents one time unit. The number refers to the running process Round Robin (RR q=4) Process Pi 1 2 3 Arrival Time Ta 0 1 3 Service Time Ts 3 5 2 Finish Time Tf 3 10 9 Turnaround Time Tq 3 9 6 Tq = Tf - Ta Normalized Tq/Ts 1. 0 1. 8 3. 0 Turnaround Time 4 5 9 12 5 5 19 20 10 8 Average 2. 0 1. 6 1. 88 7. 20
Solution of Question - SPN (6) 0 0 0 0 0 1 1 1 1 1 2 0 1 2 3 4 5 6 7 8 9 0 SPN 1 1 1 3 3 2 2 2 4 4 4 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 Arrival Time Ta 0 1 3 9 Service Time Ts 3 5 2 5 Finish Time Tf 3 10 5 15 Turnaround Time Tq 3 9 2 6 Tq = Tf - Ta Normalized Tq/Ts 1. 0 1. 8 1. 0 1. 2 Turnaround Time 5 12 5 20 8 Average 1. 6 1. 32 5. 60
Solution of Question - SRT (7) 0 0 0 0 0 1 1 1 1 1 2 0 1 2 3 4 5 6 7 8 9 0 SRT 1 1 1 3 3 2 2 2 4 4 4 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 Average Arrival Time Ta 0 1 3 9 12 Service Time Ts 3 5 2 5 5 Finish Time Tf 3 10 5 15 20 Turnaround 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. 32 Turnaround Time
Solution of Question - HRRN (8) 0 0 0 0 0 1 1 1 1 1 2 0 1 2 3 4 5 6 7 8 9 0 HRRN 1 1 1 2 2 2 3 3 4 4 4 5 5 5 * Each square represents one time unit. The number refers to the running process * At time 3: P 2 RR (2+5)/5 = 1. 4; P 3 RR= (0+2)/2 = 1. So Choose P 2 Highest Response Ratio Next (HRRN) Process Pi 1 2 3 4 5 Average Arrival Time Ta 0 1 3 9 12 Service Time Ts 3 5 2 5 5 Finish Time Tf 3 8 10 15 20 Turnaround 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. 74 Turnaround Time
Solution of Question Feedback q=1 00000111112 01234567890 RQ 1 P 2 P 3 P 4 P 5 1 0 2 1 0 0 RQ 2 2 3 RQ 3 1 3 0 1 2 4 3 RQ 4 4 12132312244455524545
Solution of Question FB q=1 (9) 0 0 0 0 0 1 1 1 1 1 2 0 1 2 3 4 5 6 7 8 9 0 1 2 1 3 2 3 1 2 2 4 4 4 5 5 5 2 4 5 * Each square represents one time unit. The number refers to the running process Feedback (FB q=1) Process Pi 1 2 Arrival Time Ta 0 1 Service Time Ts 3 5 Finish Time Tf 7 16 Turnaround Time Tq 7 15 Tq = Tf - Ta Normalized Tq/Ts 2. 3 3. 0 Turnaround Time 3 3 2 6 3 4 5 9 12 5 5 19 20 10 8 Average 1. 5 2. 0 1. 6 2. 08 8. 6
Solution of Question Feedback q= 2 i 00000111112 01234567890 P 1 P 2 P 3 P 4 P 5 RQ 1 1 0 0 RQ 2 2 1 0 2 12113223224454455455
Solution of Question FB q=2 i FB q= 2 i (10) 0 0 0 0 0 1 1 1 1 1 2 0 1 2 3 4 5 6 7 8 9 0 1 2 1 1 3 2 2 4 4 5 5 * Each square represents one time unit. The number refers to the running process Feedback (FB q = 2 i) Process Pi 1 2 3 Arrival Time Ta 0 1 3 Service Time Ts 3 5 2 Finish Time Tf 4 10 8 Turnaround Time Tq 4 9 5 Tq = Tf - Ta Normalized Tq/Ts 1. 3 1. 8 2. 5 Turnaround Time 4 5 9 12 5 5 18 20 9 8 Average 1. 8 1. 6 1. 81 7. 00
Question 1 - Exercise/Home Work (1) z Consider the following set of processes: Process Name Arrival Time Processing Time 1 0 1 2 1 9 3 2 1 4 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) )