Uniprocessor Scheduling III Solution CPSC 410 Operating Systems

  • Slides: 19
Download presentation
Uniprocessor Scheduling III (Solution) CPSC 410 Operating Systems Department of Physics, Computer Science and

Uniprocessor Scheduling III (Solution) CPSC 410 Operating Systems Department of Physics, Computer Science and Engineering Christopher Newport University

Question (1) z Consider the following set of processes: Process Name Arrival Time Processing

Question (1) z Consider the following set of processes: Process Name Arrival Time Processing Time 1 0 2 2 1 4 3 2 8 4 3 6 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 3 FCFS 00000111112 01234567890 P 1 P 2 P 3 P

Solution of Question 3 FCFS 00000111112 01234567890 P 1 P 2 P 3 P 4 Arrive time 0 1 2 3 1122223333444444 (2)

Solution of Question 3 - FCFS (3) 0 0 0 0 0 1 1

Solution of Question 3 - 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 2 2 3 3 3 3 4 4 4 * Each square represents one time unit. The number refers to the running process First Come First Served (FCFS) Process Pi 1 2 3 4 Arrival Time Ta 0 1 2 3 Service Time Ts 2 4 8 6 Finish Time Tf 2 6 14 20 Turnaround Time Tq 2 5 12 17 Tq = Tf - Ta Normalized Tq/Ts 1. 0 1. 25 1. 5 2. 8 Turnaround Time Average 9. 00 1. 64

Solution of Question 3 Round Robin q=1 (4) 00000111112 01234567890 P 1 P 2

Solution of Question 3 Round Robin q=1 (4) 00000111112 01234567890 P 1 P 2 P 3 P 4 0 Next Ready Time 1 1 2 5 2 8 4 3 7 6 10 9 13 12 15 14 1719 16 1213243243243433

Solution of Question 3 - RR (q=1) RR q=1 (5) 0 0 0 0

Solution of Question 3 - RR (q=1) RR q=1 (5) 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 4 3 4 3 3 * Each square represents one time unit. The number refers to the running process Round Robin (RR q=1) Process Pi 1 2 3 Arrival Time Ta 0 1 2 Service Time Ts 2 4 8 Finish Time Tf 3 11 20 Turnaround Time Tq 3 10 18 Tq = Tf - Ta Normalized Tq/Ts 1. 5 2. 25 Turnaround Time 4 3 6 18 15 2. 5 Average 11. 5 2. 19

Solution of Question 3 Round Robin q=4 (6) 00000111112 01234567890 P 1 P 2

Solution of Question 3 Round Robin q=4 (6) 00000111112 01234567890 P 1 P 2 P 3 P 4 Next Ready Time 0 1 2 10 3 14 11222233334444333344

Solution of Question 3 - RR (q=4) RR q=4 (7) 0 0 0 0

Solution of Question 3 - RR (q=4) RR q=4 (7) 0 0 0 0 0 1 1 1 1 1 2 0 1 2 3 4 5 6 7 8 9 0 1 1 2 2 3 3 4 4 * 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 2 Service Time Ts 2 4 8 Finish Time Tf 2 6 18 Turnaround Time Tq 2 5 16 Tq = Tf - Ta Normalized Tq/Ts 1. 0 1. 3 2. 0 Turnaround Time 4 3 6 20 17 2. 8 Average 10 1. 8

Solution of Question 3 SPN 00000111112 01234567890 P 1 P 2 P 3 P

Solution of Question 3 SPN 00000111112 01234567890 P 1 P 2 P 3 P 4 Shortest Process Time 2 4 8 6 1122224444443333 (8)

Solution of Question 3 - SPN (9) 0 0 0 0 0 1 1

Solution of Question 3 - SPN (9) 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 2 2 4 4 4 3 3 3 3 * 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 2 3 Service Time Ts 2 4 8 6 Finish Time Tf 2 6 20 12 Turnaround Time Tq 2 5 18 9 Tq = Tf - Ta Normalized Tq/Ts 1. 0 1. 25 2. 25 1. 5 Turnaround Time Average 8. 5 1. 5

Solution of Question 3 SRT 00000111112 01234567890 P 1 P 2 P 3 P

Solution of Question 3 SRT 00000111112 01234567890 P 1 P 2 P 3 P 4 Shortest Remaining Time 2 1 4 3 2 1 87 6 5 4 3 2 1 1122224444443333 (10)

Solution of Question 3 - SRT (11) 0 0 0 0 0 1 1

Solution of Question 3 - SRT (11) 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 2 2 4 4 4 3 3 3 3 * Each square represents one time unit. The number refers to the running process Shortest Remaining Time (SRT) Process Pi 1 2 3 4 Arrival Time Ta 0 1 2 3 Service Time Ts 2 4 8 6 Finish Time Tf 2 6 20 12 Turnaround Time Tq 2 5 18 9 Tq = Tf - Ta Normalized Tq/Ts 1. 0 1. 25 2. 25 1. 5 Turnaround Time Average 8. 5 1. 5

Solution of Question 3 HRRN (12) 00000111112 01234567890 P 1 P 2 P 3

Solution of Question 3 HRRN (12) 00000111112 01234567890 P 1 P 2 P 3 P 4 P 3 RR=1. 5 P 4 RR = 1. 5 1122223333444444 P 2 RR =((2 -1) + 4)/4 = 5/4 = 1. 25; P 3 RR =((2 -2) + 8)/8 = 8/8 = 1. 0 P 3 RR =((6 -2)+8)/8 = 12/8 = 1. 5; P 4 RR =((6 -3) +6)/6 = 9/6 =1. 5

Solution of Question 3 - HRRN (13) 0 0 0 0 0 1 1

Solution of Question 3 - HRRN (13) 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 2 2 3 3 3 3 4 4 4 * Each square represents one time unit. The number refers to the running process Highest Response Ratio Next (HRRN) Process Pi 1 2 3 4 Average Arrival Time Ta 0 1 2 3 Service Time Ts 2 4 8 6 Finish Time Tf 2 6 14 20 Turnaround Time Tq 2 5 12 17 9 Tq = Tf - Ta Normalized Tq/Ts 1. 0 1. 25 1. 5 2. 83 1. 65 Turnaround Time

Solution of Question 3 FB q=1 00000111112 01234567890 PQ 1 PQ 2 PQ 3

Solution of Question 3 FB q=1 00000111112 01234567890 PQ 1 PQ 2 PQ 3 PQ 4 P 1 0 1 PQ 5 0 1 2 3 P 2 0 1 2 3 4 5 6 P 3 1 2 3 4 5 P 4 PQ 0 0 1234234234343444 (14)

Solution of Question 3 FB q=1 (15) 0 0 0 0 0 1 1

Solution of Question 3 FB q=1 (15) 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 4 3 4 3 3 * Each square represents one time unit. The number refers to the running process Feedback (FB q=1) Process Pi 1 2 3 4 Arrival Time Ta 0 1 2 3 Service Time Ts 2 4 8 6 Finish Time Tf 5 12 20 18 Turnaround Time Tq 5 11 18 15 Tq = Tf - Ta Normalized Tq/Ts 2. 5 2. 75 2. 25 2. 5 Turnaround Time Average 12. 25 2. 5

Solution of Question 3 FB q= 2 i (16) 00000111112 01234567890 PQ 1 PQ

Solution of Question 3 FB q= 2 i (16) 00000111112 01234567890 PQ 1 PQ 2 PQ 3 P 1 0 1 2 P 2 0 1 2 3 P 3 1 2 P 4 PQ 0 0 12341223344233334443

Solution of Question 3 FB q=2 i FB q= 2 i (17) 0 0

Solution of Question 3 FB q=2 i FB q= 2 i (17) 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 4 1 2 2 3 3 4 4 4 3 * 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 2 Service Time Ts 2 4 8 Finish Time Tf 5 12 20 Turnaround Time Tq 5 11 18 Tq = Tf - Ta Normalized Tq/Ts 2. 5 2. 75 2. 25 Turnaround Time 4 3 6 19 16 Average 2. 67 2. 54 12. 5