Docsity

Solving CPU Time Problems in Operating Systems - Prof. Fenghui Yao, Assignments of Operating Systems

Toggle sidebar
bg1
1. Answer: refer to the answer of Problem 37 on page 173.
2. Answer:
Process Tickets Time Required
P1 10 40
P2 50 10
P3 40 20
(1) All three processes are active.
r1,CPU = 0.1, r2,CPU = 0.5, r3,CPU = 0.4,
Comparing the CPU time that P1, P2, and P3 need, it is clear P2 finishes first. Assume P2
finishes at x, then
1 : x = 0.5 : 10 โ†’ x = 10/0.5 = 20 sec.
P1 gets 50 x r1,CPU = 20 x 0.1 = 2 sec.
P3 gets 50 x r3,CPU = 20 x 0.4 = 8 sec.
Remaining time for P1 and P3 are:
T1,rem = 40 โ€“ 2 = 38 sec., T3,CPU = 20 โ€“ 8 = 12 sec.
(2) Two processes are active.
r1,CPU = 10/(10+40) = 0.2, r3,CPU = 40/(10+40)=0.8.
P3 will finish next. Assume system runs y seconds to finish, then
1 : y = 0.8 : 12 โ†’ y = 12 / 0.8 = 15 sec.
P3 finishes at 20+15 = 35 sec.
P1 obtained 15 x 0.2 = 3 sec.
(3) Remaining time of P1, T1,CPU = 38 โ€“ 3 = 35 sec.
P1 will run for 35 sec to finish. Thus P31will finish at 20+15+35 = 70 sec.
So, P2 will finish at 20 sec, P3 will finish at 35 sec, and P1 will finish at 70 sec.

Partial preview of the text

Download Solving CPU Time Problems in Operating Systems - Prof. Fenghui Yao and more Assignments Operating Systems in PDF only on Docsity!

  1. Answer: refer to the answer of Problem 37 on page 173.
  2. Answer: Process Tickets Time Required P1 10 40 P2 50 10 P3 40 20 (1) All three processes are active. r1,CPU = 0.1, r2,CPU = 0.5, r3,CPU = 0.4, Comparing the CPU time that P1, P2, and P3 need, it is clear P2 finishes first. Assume P finishes at x, then 1 : x = 0.5 : 10 โ†’ x = 10/0.5 = 20 sec. P1 gets 50 x r1,CPU = 20 x 0.1 = 2 sec. P3 gets 50 x r3,CPU = 20 x 0.4 = 8 sec. Remaining time for P1 and P3 are: T1,rem = 40 โ€“ 2 = 38 sec., T3,CPU = 20 โ€“ 8 = 12 sec. (2) Two processes are active. r1,CPU = 10/(10+40) = 0.2, r3,CPU = 40/(10+40)=0.8. P3 will finish next. Assume system runs y seconds to finish, then 1 : y = 0.8 : 12 โ†’ y = 12 / 0.8 = 15 sec. P3 finishes at 20+15 = 35 sec. P1 obtained 15 x 0.2 = 3 sec. (3) Remaining time of P1, T1,CPU = 38 โ€“ 3 = 35 sec. P1 will run for 35 sec to finish. Thus P31will finish at 20+15+35 = 70 sec. So, P2 will finish at 20 sec, P3 will finish at 35 sec, and P1 will finish at 70 sec.