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?
- A. P1 13, P2 17, P3 19
- B. P1 13, P2 19, P3 17
- C. P1 15, P2 19, P3 17
- 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
- Reference string: 2, 7, 2, 4, 1, 7, 3, 2, 4, 5, 1, 2, 7, 3, 5, 2. With 4 frames, initially empty, how many page faults do FIFO, LRU and…
- Reference string: 2, 7, 2, 4, 1, 7, 3, 2, 4, 5, 1, 2, 7, 3, 5, 2. Three frames, initially empty, are managed by the clock (second-chance)…
- Reference string: 2, 3, 4, 1, 2, 3, 1, 5, 2, 3, 4, 1, 5. How many page faults does FIFO give with 3 frames and with 4 frames, and LRU with…
- Reference string: 2, 7, 2, 4, 1, 7, 3, 2, 4, 5, 1, 2, 7, 3, 5, 2. Three frames, initially empty, use LFU replacement: the victim is the…
- Five processes P0-P4 share four resource types A, B, C, D. Allocation: P0 (0,1,0,1), P1 (2,0,0,1), P2 (1,1,1,0), P3 (0,0,2,1), P4…
- Use the same state: Allocation P0 (0,1,0,1), P1 (2,0,0,1), P2 (1,1,1,0), P3 (0,0,2,1), P4 (1,0,1,0); Max P0 (3,2,2,2), P1 (2,1,1,3), P2…