CS FundamentalsVery hardProduct company interview · GATE level

Processes (arrival, burst) in ms: P1 (0, 6), P2 (2, 5), P3 (4, 2), P4 (5, 8), P5 (7, 3). They are scheduled by non-preemptive Highest Response Ratio Next, where response ratio = (waiting time + burst) / burst. In what order do they run, and what is the average waiting time?

  1. A. P1, P3, P2, P5, P4; 6.2 ms
  2. B. P1, P3, P5, P2, P4; 4.6 ms
  3. C. P1, P2, P3, P5, P4; 5.8 ms
  4. D. P1, P3, P2, P5, P4; 5 ms

Correct answer: D. P1, P3, P2, P5, P4; 5 ms

At 6: ratios P2 (4 + 5)/5 = 1.8, P3 (2 + 2)/2 = 2, P4 (1 + 8)/8 = 1.125, so P3 runs 6-8. At 8: P2 (6 + 5)/5 = 2.2, P4 (3 + 8)/8 = 1.375, P5 (1 + 3)/3 = 1.33, so P2 runs 8-13. At 13: P4 (8 + 8)/8 = 2, P5 (6 + 3)/3 = 3, so P5 runs 13-16 and P4 16-24. Waits 0, 6, 2, 11, 6: average 5 ms. Plain SJF would pick P5 over P2 at time 8 and give 4.6 ms; HRRN chooses P2 because it has already waited 6 ms, which is the aging HRRN is designed for.

More Operating Systems questions

Exams that ask this topic