Consider the page-reference string: 0 1 2 3 0 1 4 0 1 2 3 4. If the FIFO page-replacement algorithm is used, find the number of page faults for (a) 3 page frames and (b) 4 page frames, respectively.
Pick an option to check yourself, or open the answer below.
Show answer & explanation
Correct answer: D. 9, 10
Explanation
With 3 frames (FIFO queue, oldest evicted first): 0,1,2 fault and fill the frames [0,1,2]; 3 faults, evicting 0 → [1,2,3]; 0 faults, evicting 1 → [2,3,0]; 1 faults, evicting 2 → [3,0,1]; 4 faults, evicting 3 → [0,1,4]; the next 0 and 1 are hits; 2 faults, evicting 0 → [1,4,2]; 3 faults, evicting 1 → [4,2,3]; the final 4 is a hit — giving 9 faults in total. With 4 frames: 0,1,2,3 fault and fill [0,1,2,3]; the next 0 and 1 are hits; 4 faults, evicting 0 → [1,2,3,4]; 0 faults, evicting 1 → [2,3,4,0]; 1 faults, evicting 2 → [3,4,0,1]; 2 faults, evicting 3 → [4,0,1,2]; 3 faults, evicting 4 → [0,1,2,3]; the final 4 faults, evicting 0 — giving 10 faults in total. So the answer is 9, 10, option (iv) — a textbook example of Belady's anomaly, where adding a frame under FIFO actually increased the fault count.More Programming Languages and Computer Graphics questions
- What would be the equivalent pointer expression for referring the array element ar[ m ][ n ][0]
- Which of the following technique is used for Clipping?
- Match List I with List II
- Match List I with List II
- Only legal pointer operations: → A. pointer + number pointer → B. pointer - number number → C. pointer + pointer pointer → D. pointer - poi…
- Consider the conditional statement if (m == 20 − 10 || n > 10). The order of execution of the following operations is: A. == B. − C. || D. >