CS FundamentalsVery hardProduct company interview · GATE level

Three processes each run CPU burst, I/O burst, CPU burst (in ms): P1 arrives at 0 with 5, 4, 3; P2 arrives at 2 with 3, 6, 2; P3 arrives at 3 with 2, 2, 4. The CPU uses non-preemptive SJF on the length of the next CPU burst (ties go to whoever became ready first, then lower number). Every process has its own I/O device, so I/O never waits. When does each process finish?

  1. A. P1 13, P2 17, P3 19
  2. B. P1 13, P2 19, P3 17
  3. C. P1 15, P2 19, P3 17
  4. D. P1 13, P2 18, P3 17

Correct answer: B. P1 13, P2 19, P3 17

P1 runs 0-5, then does I/O until 9. At 5, P3 (2) beats P2 (3): P3 runs 5-7 and does I/O until 9. P2 runs 7-10 and does I/O until 16. At 10, P1 (3 left) and P3 (4 left) are both ready since 9; SJF picks P1, 10-13, done. P3 runs 13-17, done. P2 becomes ready at 16 and runs 17-19, done. The CPU is never idle. Taking P2 first at time 5 because it arrived earlier is the FCFS habit that SJF overrides.

More Operating Systems questions

Exams that ask this topic