Consider a computer system with ten physical page frames. The system is…
2016
Consider a computer system with ten physical page frames. The system is provided with an access sequence \( (a_1,a_2,...,a_{20,} a_1,a_2,...,a_{20})\), where each ai is a distinct virtual page number. The difference in the number of page faults between the last-in-first-out page replacement policy and the optimal page replacement policy is __________ .
Answer: 1 — Answer: 1 (The last-in-first-out policy incurs one more page fault than the optimal policy.) Key facts: there are 20 distinct pages and only 10 physical…
Attempted by 56 students.
Show answer & explanation
Correct answer: 1
Answer: 1 (The last-in-first-out policy incurs one more page fault than the optimal policy.)
Key facts: there are 20 distinct pages and only 10 physical frames; the access sequence is the 20 distinct pages repeated twice.
Optimal replacement (minimizes future faults):
During the first pass over the 20 distinct pages, every page is seen first time -> 20 faults.
Optimal evictions during the first pass lead to frames containing nine of the earliest pages and the last page (specifically pages a1..a9 and a20).
On the second pass, accesses a1..a9 hit, and accesses a10..a19 miss (10 faults), while a20 hits. So the second pass has 10 faults.
Total optimal faults = 20 + 10 = 30.
Last-In-First-Out replacement:
First pass: each of the 20 distinct pages is first-time accessed -> 20 faults. LIFO evictions during the first pass leave frames a1..a9 and a20 (same final set as in the optimal case).
Second pass: a1..a9 hit, but a10 is not in memory and on that fault LIFO evicts the most recently loaded page (a20), causing a10 to be loaded. Then a11 evicts a10, a12 evicts a11, and so on. Every access from a10 through a20 in the second pass causes a fault (11 faults).
Total LIFO faults = 20 + 11 = 31.
Conclusion: The difference in the number of page faults (LIFO minus optimal) is 31 - 30 = 1.
A video solution is available for this question — log in and enroll to watch it.