🎓 BookMCQ
← Back to 9. Virtual Memory

📝 I/O interlock and page locking (14 MCQs)

Keeping I/O-Related Memory Pages Resident

I/O interlock and page locking are memory-management techniques that prevent selected physical pages from being reclaimed or moved while an input/output operation depends on them. Device controllers and DMA engines may access memory directly, so the operating system must ensure that the required buffers remain valid throughout the transfer. Pinning or locking pages protects their physical availability until the operation completes.

Why Device Transfers Require Stable Physical Memory

During direct memory access, a device may read from or write to physical memory without requiring the CPU to copy every data item. If the operating system reclaimed or relocated the buffer during the transfer, the device could access incorrect memory. Page locking prevents such movement or replacement and maintains the connection between the device request and its intended physical buffer.

Pinning Pages Before Starting an I/O Operation

The kernel identifies the virtual pages containing the I/O buffer and ensures that required pages are resident. It pins or locks the corresponding physical pages, prepares suitable DMA mappings, and starts the device operation. After the controller completes the transfer, the operating system releases the pinning references so that the pages can again participate in ordinary memory reclamation.

Protecting a Buffer During Direct Memory Access

Suppose a storage controller transfers 64 KB of data into an application buffer spanning 16 pages of 4 KB each. The operating system ensures those pages are resident and pinned before the DMA operation begins. After the device reports completion, the kernel unpins the pages, allowing normal memory management to reclaim them when appropriate.

Reliable Transfers and Physical Memory Pressure

Page locking prevents invalid device access during active I/O and supports reliable DMA operations. However, pinned pages cannot be reclaimed normally, reducing the memory available for other processes. Excessive or prolonged pinning can increase memory pressure and contribute to poor performance. Systems therefore restrict locking where appropriate and release pages promptly after the related transfer or operation finishes.

Clarifying Pinning and Ordinary Memory Protection

'A locked page can never be accessed by other processes' is incorrect because pinning concerns residency, not exclusive ownership. 'Pinning a page prevents all CPU access' is incorrect because it protects physical availability while permitting intended access. 'Every user buffer can safely remain pinned indefinitely' is incorrect because excessive pinning reduces reclaimable memory and can destabilise memory availability.

Exam Focus: DMA Buffers and Page-Locking Lifetime

Trace the sequence of buffer validation, page pinning, DMA setup, transfer completion, and unpinning. Calculate the number of pages covered by a buffer using its size and page size, accounting for page-boundary alignment when necessary. Explain why the device requires stable physical addresses and how excessive pinned memory affects system performance.

Key Terms of I/O Interlock and Page Locking

  • Page locking - Prevents page reclamation.
  • Pinning - Keeps pages physically resident.
  • DMA - Direct memory access transfer.
  • I/O buffer - Memory used for device transfer.
  • Unpinning - Releases the residency restriction.
  • Page frame - Physical memory block.
3
Easy
5
Medium
6
Hard

📝 All I/O interlock and page locking MCQs

Q1. When a system reserves a fixed percentage of memory for I/O buffers and a user process triggers a page fault while all frames are occupied, which mechanism is typically employed to continue execution?

A.Terminate the process immediately
B.Swap out the entire process
C.Perform page replacement on a non‑I/O page ✅
D.Increase the size of the I/O buffer pool
💡 Difficulty: easy | ✅ Correct: C

📖 Explanation: The correct choice is to perform page replacement on a non‑I/O page because the operating system can free a frame by writing its contents to swap and updating the page table, letting the faulting process obtain a frame. Terminating the process would break the transparency goal of demand paging, swapping the whole process reduces multiprogramming unnecessarily, and expanding the I/O buffer pool does not create free frames for user pages. Page replacement directly resolves the shortage while preserving overall system throughput.

Q2. What is the primary purpose of a page‑replacement algorithm in a demand‑paging system?

A.To write all pages to disk before shutting down ✅
B.To free a frame by moving its contents to swap space
C.To increase the size of physical memory
D.To prevent any page faults from occurring
💡 Difficulty: easy | ✅ Correct: A

📖 Explanation: The algorithm’s main role is to free a frame by moving the page’s contents to swap space and marking the page as not resident, which supplies a frame for the newly demanded page. Increasing physical memory is a hardware concern, preventing all page faults is impossible, and writing all pages to disk is unnecessary overhead. By swapping out a selected page, the system maintains the illusion of a larger memory space, enabling continued execution of processes.

Q3. Which data structure holds frames that are currently not assigned to any page?

A.Page table
B.Swap space ✅
C.Free‑frame list
D.Buffer pool
💡 Difficulty: easy | ✅ Correct: B

📖 Explanation: The free‑frame list is the structure that contains frames not currently used by any page, making them available for allocation when a page fault occurs. The page table maps virtual pages to physical frames, swap space stores pages that have been moved out of memory, and the buffer pool manages I/O buffers. Recognizing the free‑frame list is essential because it is the first place the OS looks for an available frame before considering replacement or swapping.

Q4. A system allows both user processes and the I/O subsystem to compete for all available memory. When a page fault occurs and no free frames exist, which approach most effectively maintains multiprogramming while minimizing disruption?

A.Allocate additional memory to the I/O subsystem
B.Terminate the requesting process
C.Swap out the entire requesting process
D.Apply a page‑replacement policy to select a victim frame ✅
💡 Difficulty: medium | ✅ Correct: D

📖 Explanation: Applying a page‑replacement policy lets the OS choose a victim frame, free it, and satisfy the fault without killing the process or drastically reducing the degree of multiprogramming. Terminating the process would violate demand‑paging transparency, swapping the whole process would free many frames but at a high cost, and allocating more memory to I/O does not solve the immediate shortage. Page replacement balances resource usage and system responsiveness.

Q5. Why does demand paging aim to be logically transparent to the user?

A.So users can manually manage memory allocation
B.To hide the complexity of swapping pages in and out ✅
C.Because the operating system cannot detect page faults
D.To reduce CPU cache misses
💡 Difficulty: medium | ✅ Correct: B

📖 Explanation: Demand paging is designed to be transparent so that users are unaware when pages are moved between memory and disk, preserving the illusion of a large, contiguous memory space. If users had to manage memory manually, program design would become far more complex. The OS can detect page faults automatically, and while caching concerns are related, they are not the primary reason for transparency. Maintaining this abstraction improves usability and allows applications to run without modification regardless of underlying paging activity.

Q6. In a system with eight physical frames, three are occupied by I/O buffers and five by user processes. A page fault occurs and no free frame exists. Which algorithm is most appropriate if the OS must avoid replacing an I/O buffer page?

A.First‑In‑First‑Out (FIFO)
B.Least‑Recently‑Used (LRU)
C.Modified Clock that skips locked pages ✅
D.Random replacement
💡 Difficulty: medium | ✅ Correct: C

📖 Explanation: The Modified Clock algorithm that skips pages locked for I/O is appropriate because it respects the I/O interlock, ensuring that buffer pages are not swapped out while an I/O operation is pending. FIFO and LRU may select an I/O buffer page, leading to I/O failures, while random replacement ignores the special status of I/O pages. By bypassing locked pages, the algorithm maintains I/O correctness and still provides a victim for replacement.

Q7. How does page locking relate to I/O interlock mechanisms in an operating system?

A.They are unrelated concepts
B.Page locking prevents a page involved in an I/O operation from being swapped out ✅
C.I/O interlock forces all pages to be locked permanently
D.Page locking speeds up CPU execution of I/O requests
💡 Difficulty: medium | ✅ Correct: B

📖 Explanation: Page locking directly supports I/O interlock by ensuring that any page currently participating in an I/O transfer cannot be evicted from memory, thereby protecting the integrity of the I/O operation. The two mechanisms are tightly coupled; without locking, a page could be swapped out mid‑transfer, causing data corruption. They do not permanently lock all pages, and while they may affect execution speed indirectly, their primary purpose is to safeguard active I/O.

Q8. If a system over‑allocates memory to I/O buffers such that no free frames remain and page replacement is disabled, what is the most likely immediate consequence for a newly faulting process?

A.The process will be terminated by the OS ✅
B.The system will automatically increase physical memory
C.All I/O operations will be paused until memory is freed
D.The OS will swap out the entire process to create free frames
💡 Difficulty: medium | ✅ Correct: A

📖 Explanation: When page replacement is disabled and no free frames exist, the operating system has no mechanism to provide a frame for the faulting process, so it must abort the process to preserve system stability. Automatically increasing physical memory is not feasible at runtime, pausing I/O does not free frames, and swapping the entire process is effectively a form of page replacement, which the premise states is unavailable. Termination is therefore the immediate fallback.

Q9. Under what circumstances is swapping out an entire process preferable to performing individual page replacements?

A.When the system has abundant free memory
B.When the memory pressure is extreme and many pages are idle ✅
C.When only a single page is needed for I/O
D.When the process uses no I/O buffers
💡 Difficulty: hard | ✅ Correct: B

📖 Explanation: Swapping an entire process becomes advantageous when memory pressure is severe and many of the process’s pages are idle, allowing the OS to free a large number of frames at once and reduce multiprogramming overhead. If free memory is abundant, page replacement suffices; swapping a single page needed for I/O would disrupt the I/O operation, and a process without I/O buffers does not affect the decision. The wholesale swap efficiently reclaims resources in extreme conditions.

Q10. A system has 64 physical frames. The OS allocates 20 % of them to I/O buffers (rounded to the nearest whole frame). A user process currently occupies 30 frames. If a page fault occurs, how many frames are potentially available for replacement?

A.64−30=3464 - 30 = 34
B.64−13−30=2164 - 13 - 30 = 21 ✅
C.1313
D.00
💡 Difficulty: hard | ✅ Correct: B

📖 Explanation: First calculate the number of frames dedicated to I/O: 20%×64=12.820\% \times 64 = 12.8, rounded to 13 frames. The process uses 30 frames, leaving 64−13−30=2164 - 13 - 30 = 21 frames that could be reclaimed via page replacement. The option 3434 ignores the I/O allocation, 1313 represents only the I/O buffers, and 00 would imply no replaceable frames, which is inaccurate. Thus 21 frames are the correct count, illustrating how memory partitioning impacts replacement decisions.

Q11. What impact does extensive page locking have on the risk of deadlock in a memory‑constrained system?

A.It eliminates deadlock risk entirely
B.It increases the risk because locked pages reduce the pool of replaceable frames ✅
C.It has no effect on deadlock probability
D.It only affects I/O throughput, not deadlock
💡 Difficulty: hard | ✅ Correct: B

📖 Explanation: Extensive page locking reduces the number of frames that can be reclaimed, shrinking the pool of replaceable pages and making it more likely that competing processes cannot obtain the memory they need, thus raising deadlock risk. While deadlock can still occur without locking, the restriction amplifies the chance. Locking does not eliminate deadlock, nor is it neutral; it directly influences resource availability, which is a core factor in deadlock formation.

Q12. Two processes each hold a lock on a page that the other needs to complete its I/O operation. Which technique is most appropriate for resolving this situation?

A.Priority inheritance protocol
B.Page replacement of the locked pages
C.Unlocking the I/O interlock manually
D.Deadlock detection and recovery ✅
💡 Difficulty: hard | ✅ Correct: D

📖 Explanation: Deadlock detection and recovery is the correct approach because the scenario describes a classic circular wait where each process blocks the other, requiring the system to recognize the deadlock and take corrective action such as aborting one process or rolling back. Priority inheritance deals with priority inversion, not circular waiting; forcing page replacement on locked pages would violate I/O integrity, and manually unlocking I/O interlocks could corrupt ongoing transfers. Detection and recovery directly address the deadlock condition.

Q13. Why must page‑replacement policies consider the state of I/O interlocks when selecting victim pages?

A.To avoid swapping pages that are currently involved in I/O operations ✅
B.To increase the number of cache hits
C.To simplify page‑table entries
D.To reduce CPU instruction count
💡 Difficulty: hard | ✅ Correct: A

📖 Explanation: Considering I/O interlocks is essential because swapping out a page that is actively participating in an I/O transfer can corrupt data and stall the operation. While cache performance and page‑table simplicity are desirable, they are secondary to maintaining I/O correctness. Ignoring the interlock status could lead to failed I/O, making the policy unsafe. Therefore, the primary reason is to protect active I/O pages from being evicted.

Q14. If I/O demand suddenly rises and consumes 30 % of memory for buffers, what adjustment should the operating system make to preserve overall performance?

A.Increase the size of the swap area
B.Reduce the memory allocated to user processes
C.Enable a more aggressive page‑replacement algorithm ✅
D.Decrease the system’s page size
💡 Difficulty: hard | ✅ Correct: C

📖 Explanation: Enabling a more aggressive page‑replacement algorithm allows the OS to free frames more quickly, compensating for the larger portion of memory taken by I/O buffers and preventing starvation of user processes. Expanding swap space does not instantly free frames, reducing user‑process memory would hurt application performance, and changing page size is a static configuration that does not address immediate pressure. Aggressive replacement directly tackles the shortage caused by the I/O spike.

🔗 Related Topics (MCQs)