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. Three frames, initially empty, use LFU replacement: the victim is the resident page with the smallest total reference count so far (counts include references made while the page was not resident), and ties go to the page that was loaded earliest. How many page faults occur?
- A. 14
- B. 12
- C. 11
- D. 15
Correct answer: B. 12
Keep a running count per page. After 2, 7, 2, 4 the frames hold 2 (count 2), 7 and 4. On 1, the tie between 7 and 4 (count 1) is broken by load time, so 7 goes; then 7 itself faults and replaces 4 (count 1, oldest among the lowest). Continuing, page 2 gathers the highest count and is never evicted, which gives 2 fewer faults than FIFO's 14. Total 12. Resetting counts on eviction (a different LFU variant) changes the victims, which is why the rule is stated.
More Operating Systems questions
- 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)…
- Shared int x = 1. Thread T1 executes x = x + 1; twice; thread T2 executes x = x 2; once. Each statement compiles to a load of x into a…
- Semaphores a = 0 and b = 0. Three processes run concurrently: P: print('A'); signal(a); wait(b); print('B'); Q: wait(a); print('C')…
- Two processes (i = 0, 1; j = 1 - i) share bool flag[2] = {false, false} and int turn, and each runs entry code, then its critical section…