🎓 BookMCQ
← Back to 9. Virtual Memory

📝 Prepaging in Virtual Memory (8 MCQs)

Loading Anticipated Pages Before Their First Reference

Prepaging is a virtual-memory optimisation in which the operating system loads pages into physical memory before a process explicitly references them. It attempts to reduce future page faults by predicting which pages will soon be needed. Predictions may use previous access patterns, process information, or known sequential relationships. Unlike ordinary demand paging, prepaging deliberately brings in additional pages ahead of immediate demand.

Why Loading Related Pages Together Can Reduce Faults

Programs often access neighbouring pages sequentially or follow predictable execution paths. Loading only the first requested page can cause several closely spaced page faults as execution progresses. Prepaging attempts to retrieve related pages together, reducing repeated storage operations and fault-handling overhead. However, predicting future references is imperfect, and unnecessary loading consumes frames and storage bandwidth.

Predicting Page Requirements and Performing Early Loading

The operating system examines available locality information or known process behaviour to identify likely future pages. It obtains available frames and transfers the predicted page contents before their first references occur. The mappings are updated so that subsequent accesses can use resident pages. Effective prepaging depends on prediction accuracy, storage transfer efficiency, and sufficient physical memory.

Loading Consecutive Pages Before Sequential Access

Suppose a process is reading a file sequentially across pages 10, 11, 12, and 13. When page 10 is requested, the operating system may also bring pages 11 and 12 into memory. If the process continues sequentially, those pages may be accessed without separate storage-backed faults. If execution changes direction, the additional pages may have been loaded unnecessarily.

Reducing Fault Bursts and Avoiding Unnecessary I/O

Prepaging can reduce fault frequency and improve performance for workloads with predictable sequential access or strong locality. Its disadvantages include wasted frame capacity, unnecessary storage transfers, and possible displacement of useful resident pages. It works best when predictions are accurate and transfer costs benefit from larger reads. It is less effective for unpredictable workloads with random memory references.

Distinguishing Prepaging from Demand Paging

'Prepaging waits until every page is referenced' is incorrect because it loads predicted pages in advance. 'Every prefetched page will eventually be used' is incorrect because predictions can fail. 'Prepaging eliminates all future page faults' is incorrect because applications may reference pages outside the predicted set or encounter later memory-allocation events.

Exam Focus: Predictive Loading and I/O Trade-Offs

Compare prepaging with demand paging by examining when pages enter memory. Identify workloads where sequential access makes prediction useful and calculate the number of additional pages loaded. Evaluate the consequences of inaccurate predictions, including wasted frames and storage traffic. Distinguish reduced future fault frequency from guaranteed elimination of page faults.

Key Terms of Prepaging

  • Prepaging - Loads predicted pages in advance.
  • Prefetching - Retrieves data before demand.
  • Prediction - Estimate of future page references.
  • Sequential access - Consecutive location references.
  • Page fault - Exception for a missing page.
  • Prefetched page - Page loaded before reference.
2
Easy
4
Medium
2
Hard

📝 All Prepaging in Virtual Memory MCQs

Q1. What is the main purpose of page replacement in an operating system?

A.To increase disk space
B.To free a frame for a needed page ✅
C.To terminate processes
D.To allocate more memory to I/O buffers
💡 Difficulty: easy | ✅ Correct: B

📖 Explanation: The correct answer is B because page replacement exists to reclaim a frame that is currently occupied so a newly requested page can be loaded. Option A is wrong; page replacement does not affect disk capacity. Option C is incorrect since terminating processes is a drastic measure, not the routine purpose. Option D misrepresents the goal; page replacement concerns RAM frames, not I/O buffer allocation. In real systems, freeing a frame enables continued execution without user‑visible delays.

Q2. Why does over‑allocation of memory to I/O buffers increase the likelihood of page faults for user processes?

A.It reduces the number of free frames ✅
B.It speeds up disk I/O
C.It increases CPU cache size
D.It eliminates need for swapping
💡 Difficulty: easy | ✅ Correct: A

📖 Explanation: Answer A is correct because allocating too much memory to I/O buffers consumes frames that could otherwise hold user pages, leaving fewer free frames and causing more page faults when a process accesses a page not in memory. Option B describes a benefit of larger buffers but does not cause faults. Option C is unrelated to buffer allocation. Option D is false; swapping may still be required. In practice, a balanced buffer size reduces fault frequency.

Q3. How does demand paging aim to keep paging transparent to the user?

A.By exposing page‑fault events
B.By handling page faults entirely within the kernel ✅
C.By requiring users to manage page tables
D.By disabling swapping
💡 Difficulty: medium | ✅ Correct: B

📖 Explanation: The correct answer is B because demand paging hides the mechanics of loading pages by performing all fault handling inside the kernel, so the user sees no interruption. Option A is opposite; exposing faults would break transparency. Option C is inaccurate because page tables are managed by the OS, not the user. Option D is incorrect; swapping remains a tool for demand paging. This design lets applications run as if all memory were resident, improving usability.

Q4. A system has 44 frames and references pages in this order: 1,2,3,4,1,2,5,1,2,3,4,5. Using the optimal page‑replacement algorithm, which page is evicted when page 5 is requested at step 7?

A.Page 1
B.Page 2
C.Page 3
D.Page 4 ✅
💡 Difficulty: medium | ✅ Correct: D

📖 Explanation: Optimal replacement looks ahead to the farthest future use. At step 7, pages 1 and 2 will be needed soon (steps 8 and 9), while page 3 will appear at step 10 and page 4 at step 11. The farthest future reference is page 4, so it is evicted, making D correct. Options A, B, and C are wrong because those pages are needed earlier, so removing them would cause more faults. This illustrates how optimal replacement minimizes future page faults.

Q5. What is the trade‑off when a system allocates a fixed percentage of memory for I/O buffers versus allowing user processes to compete for all memory?

A.Fixed allocation guarantees no page faults
B.Dynamic competition can lead to higher throughput but more frequent page replacement ✅
C.Fixed allocation eliminates need for page tables
D.Dynamic competition reduces CPU utilization
💡 Difficulty: medium | ✅ Correct: B

📖 Explanation: Answer B captures the essential trade‑off: a fixed buffer size limits I/O performance but protects user processes from frequent page replacements, whereas letting processes compete can improve overall throughput but increase the chance of page faults as frames are reclaimed. Option A is false; fixed buffers do not prevent faults. Option C is unrelated to buffer sizing. Option D misstates the effect; competition does not inherently lower CPU use. Understanding this balance helps OS designers choose appropriate memory policies.

Q6. Two processes, P1 needing 66 frames and P2 needing 44 frames, run on a machine with 88 frames. P1 is executing and a page fault occurs. Which action generally yields higher overall throughput?

A.Swap out P1 entirely
B.Replace a single page from P1 ✅
C.Swap out P2
D.Increase I/O buffer size
💡 Difficulty: hard | ✅ Correct: B

📖 Explanation: Replacing a single page from P1 (option B) maintains both processes in memory, allowing continued progress of P1 after the fault and preserving P2’s work, thus improving throughput. Swapping out P1 (option A) would pause its execution entirely, lowering throughput. Swapping out P2 (option C) does not help the faulting page of P1. Increasing I/O buffers (option D) does not address the immediate lack of frames. This scenario shows why fine‑grained page replacement is preferred over whole‑process swapping when possible.

Q7. A system currently uses 70 % of RAM for user processes and 30 % for I/O buffers. An I/O spike requires an extra 10 % of memory. Which page‑replacement strategy best satisfies the I/O demand while minimizing impact on user processes?

A.Swap out the lowest‑priority user process
B.Use a global LRU to evict least recently used pages across all processes ✅
C.Increase the fixed I/O buffer allocation
D.Halt all user processes
💡 Difficulty: hard | ✅ Correct: B

📖 Explanation: The global LRU approach (option B) evicts the least recently used pages regardless of which process owns them, freeing memory for I/O while affecting only pages that are least likely to be needed soon, thus reducing impact on active user processes. Swapping out an entire process (option A) would cause a large disruption. Permanently raising the fixed I/O allocation (option C) ignores current usage patterns and could waste memory. Halting all user processes (option D) is extreme and unnecessary. This strategy balances responsiveness with minimal performance loss.

Q8. A database server allocates 15 % of RAM for I/O buffers. After a workload surge, free frames drop to zero. Which immediate action should the OS take to keep the database responsive?

A.Terminate the database process
B.Perform page replacement using the Clock algorithm ✅
C.Increase the I/O buffer percentage permanently
D.Reboot the server
💡 Difficulty: medium | ✅ Correct: B

📖 Explanation: The Clock algorithm (option B) provides a quick, low‑overhead method to select a victim page for replacement, allowing the system to reclaim a frame without drastic measures. Terminating the database (option A) would stop service. Permanently increasing the buffer size (option C) does not address the immediate shortage and could worsen memory pressure. Rebooting (option D) is unnecessary and disruptive. Using Clock maintains responsiveness while managing memory efficiently.

🔗 Related Topics (MCQs)