CS FundamentalsVery hardProduct company interview · GATE level
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 Optimal replacement cause, respectively?
- A. FIFO 8, LRU 10, Optimal 7
- B. FIFO 12, LRU 8, Optimal 7
- C. FIFO 8, LRU 12, Optimal 7
- D. FIFO 8, LRU 12, Optimal 6
Correct answer: C. FIFO 8, LRU 12, Optimal 7
Simulate each policy. FIFO: faults on 2, 7, 4, 1 (fill), 3 (evicts 2), 2 (evicts 7), 5 (evicts 4), 7 (evicts 1) - all other references hit, total 8. LRU keeps evicting exactly the page that comes back next on this string: the first 3 evicts 2, which is the very next reference; that 2 evicts 4, which is needed immediately after - 12 faults in all. Optimal faults 7 times: the 6 distinct pages each cost one compulsory miss, plus one re-load of 7. The trap is to assume LRU always beats FIFO; it is a stack algorithm, so it never shows Belady's anomaly, but it can lose to FIFO on a particular string.
More Operating Systems questions
- 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…
- A system with resource types A, B, C (several instances each) runs the deadlock-detection algorithm. Allocation: P0 (0,1,0), P1 (2,0,0)…