🎓 BookMCQ
← Back to 9. Virtual Memory

📝 Virtual Memory examples in Windows (8 MCQs)

Demand Paging and Virtual Address Spaces in Windows

Microsoft Windows uses virtual memory to provide each process with a separate address space while mapping virtual pages onto physical memory. The memory manager coordinates demand paging, page-table translations, working sets, and page-file-backed storage. Processes can reserve virtual address ranges, commit memory, and access pages as execution proceeds. Hardware translation and kernel memory-management structures enforce isolation and manage resident physical pages.

Why Windows Separates Reserved Address Space from Physical RAM

Applications need flexible address ranges without requiring every requested byte to occupy physical memory immediately. Windows distinguishes virtual address reservation from commitment, which represents a system-backed promise to provide storage for committed memory. Not every committed page must be resident in RAM. This separation supports large address spaces and allows memory to be allocated according to actual access patterns.

Commitment, Demand-Zero Pages and Working-Set Management

An application can reserve virtual address space and commit suitable regions through Windows memory-management interfaces. A demand-zero page is supplied with zero-initialised contents when first required, while file-backed pages can be read from their mapped files. The memory manager maintains process working sets and adjusts their resident pages according to availability, memory pressure, and system policies.

Accessing a Committed Page for the First Time

Suppose an application commits a 16 KB region using 4 KB pages. The region can require four pages of backing commitment, although none needs to occupy a physical frame immediately. When the application first accesses one page, the memory manager handles the resulting fault and provides zero-initialised contents or retrieves applicable backing data. Other pages may remain nonresident.

Working Sets, Page Files and Memory Pressure

Windows manages resident process pages through working-set policies and can reclaim pages under memory pressure. Modified private pages may require page-file backing, while clean file-backed pages can often be retrieved from their original files. Page files provide backing for applicable committed memory but are not equivalent to physical RAM. Excessive memory pressure increases faults, storage traffic, and application delays.

Common Misconceptions About Windows Virtual Memory

'Reserved memory is immediately resident in RAM' is incorrect because reservation concerns virtual address-space availability. 'Every committed page must remain in the working set' is incorrect because commitment does not guarantee residency. 'The page file contains every process page at all times' is incorrect because clean file-backed pages can be recovered from their original files and resident pages remain in RAM.

Exam Focus: Reservation, Commitment and Working Sets

Distinguish virtual address reservation, memory commitment, and physical residency. Explain how demand-zero and file-backed pages are handled on first access. Identify the role of working sets and page-file backing under memory pressure. Questions may also compare private committed memory with mapped files and test why allocated virtual memory does not automatically consume an equal amount of resident RAM.

Key Terms of Windows Virtual Memory

  • Virtual address space - Process-specific address range.
  • Reservation - Reserves virtual address space.
  • Commitment - Promises memory backing.
  • Working set - Process pages resident in RAM.
  • Demand-zero page - Page supplied with zero contents.
  • Page file - Backing storage for applicable memory.
2
Easy
4
Medium
2
Hard

📝 All Virtual Memory examples in Windows MCQs

Q1. What is the purpose of the modify (dirty) bit in a page frame?

A.Indicates the page is free
B.Shows whether the page has been written to ✅
C.Marks the page as read‑only
D.Signals a page fault
💡 Difficulty: easy | ✅ Correct: B

📖 Explanation: The modify bit is set by hardware whenever a write occurs to any byte in the page, so it tells the OS that the page's contents have changed. Choice B matches this definition. Choice A is wrong because free status is tracked by the frame‑allocation table, not the modify bit. Choice C describes a read‑only flag, not the dirty status. Choice D confuses the bit with a fault signal. In practice, the OS checks this bit before deciding whether to write a victim page back to disk, saving I/O when the bit is clear.

Q2. Why does checking the modify bit before writing a victim page reduce overall page‑fault service time?

A.It eliminates unnecessary disk writes ✅
B.It speeds up CPU registers
C.It frees up RAM instantly
D.It prevents page‑faults
💡 Difficulty: medium | ✅ Correct: A

📖 Explanation: When the modify bit is clear, the page has not been altered since it was loaded, so writing it back would be redundant. Skipping that write saves the I/O latency of a disk transfer, directly shortening the service time. Choice A captures this benefit. Choice B is unrelated to disk I/O. Choice C misstates the effect on memory availability. Choice D is incorrect because the bit does not stop page faults; it only influences the write step. Real systems use this check to keep response times low.

Q3. During page replacement, how does the algorithm treat a victim frame whose modify bit is set versus one whose bit is clear?

A.Both are written to disk before replacement
B.Only the clear one is written to disk
C.Only the set one is written to disk
D.Neither is written; the page is discarded ✅
💡 Difficulty: medium | ✅ Correct: D

📖 Explanation: If the modify bit is set, the page has been changed and must be written back to preserve those changes; if it is clear, the page matches the copy on disk and can be discarded without a write. Choice D correctly states that the decision depends on the bit’s state. Choices A and B reverse the logic, and Choice C ignores the need to write modified pages. This distinction is crucial for minimizing unnecessary I/O while ensuring data integrity.

Q4. A process faults and no free frame exists. The selected victim’s modify bit is 0. Which sequence correctly describes the OS actions?

A.Write victim to disk, then read desired page, update tables
B.Read desired page into victim frame, then write victim, update tables
C.Read desired page, update tables, continue execution ✅
D.Write victim, update tables, read desired page, then continue
💡 Difficulty: medium | ✅ Correct: C

📖 Explanation: Because the modify bit is clear, the victim does not need to be written back. The OS can directly read the needed page into the freed frame, adjust the page and frame tables, and resume the process. Choice C follows this efficient path. Choice A adds an unnecessary write step. Choice B reads before freeing the frame, which is impossible without a destination. Choice D mixes steps incorrectly. This scenario shows how the dirty bit saves work when the victim is unchanged.

Q5. Given three frames with LRU order: Frame 1 (modify = 1), Frame 2 (modify = 0), Frame 3 (modify = 1). The LRU algorithm selects the least‑recently‑used frame. Which frame will be written to disk as part of the replacement?

A.Frame 1
B.Frame 2
C.Frame 3
D.None will be written ✅
💡 Difficulty: hard | ✅ Correct: D

📖 Explanation: The LRU policy picks the page that has not been used for the longest time, which is Frame 2 in this scenario. Because its modify bit is 0, the page matches the copy already on disk, so the OS does not need to write it back; it can simply replace it. Therefore no write operation occurs, making choice D correct. Choice A and C would cause unnecessary disk writes despite the modify bit being 0 for Frame 2. Choice B suggests writing a page that does not require it, which is inefficient.

Q6. If a page fault takes 100 µs when a free frame is available and 200 µs when no free frame exists, and the fault probability is 0.01, what is the effective memory access time?

A.(0.99×10)+(0.01×100)=10.9(0.99 \times 10) + (0.01 \times 100) = 10.9 µs
B.(0.99×10)+(0.01×200)=11.9(0.99 \times 10) + (0.01 \times 200) = 11.9 µs ✅
C.(0.99×10)+(0.01×300)=12.9(0.99 \times 10) + (0.01 \times 300) = 12.9 µs
D.(0.99×10)+(0.01×200)=12.0(0.99 \times 10) + (0.01 \times 200) = 12.0 µs
💡 Difficulty: hard | ✅ Correct: B

📖 Explanation: The effective access time formula is EAT=(1−p)×ma+p×pfEAT = (1-p) \times ma + p \times pf, where mama is base memory access (10 µs), pp is fault rate (0.01), and pfpf is the fault service time when no free frame (200 µs). Plugging the numbers gives EAT=0.99×10+0.01×200=9.9+2=11.9EAT = 0.99 \times 10 + 0.01 \times 200 = 9.9 + 2 = 11.9 µs, matching choice B. Choice A uses the shorter service time, which applies only when a free frame exists. Choice C adds an extra 100 µs incorrectly. Choice D mis‑calculates the sum. This calculation shows how extra I/O when frames are scarce raises overall latency.

Q7. What role does the valid‑invalid bit play when a page is replaced and a new page is loaded?

A.It indicates whether the frame is dirty
B.It signals whether the page table entry points to a current frame ✅
C.It determines the page‑replacement algorithm used
D.It marks the page as read‑only
💡 Difficulty: medium | ✅ Correct: B

📖 Explanation: When a page is swapped out, its entry in the page table is marked invalid, meaning the virtual address no longer maps to a physical frame. When the new page is brought in, the entry is set to valid and points to the newly allocated frame. Choice B captures this behavior. Choice A confuses the dirty bit with validity. Choice C incorrectly suggests the bit selects an algorithm. Choice D mixes up protection flags. Understanding the valid‑invalid flag helps the OS know when a page fault must trigger a replacement.

Q8. A read‑only code page is chosen as the victim during replacement. What action does the OS take?

A.Write the page to disk because it may have been modified
B.Discard the page without writing because it cannot be altered ✅
C.Mark the page as invalid and keep it in memory
D.Swap it with a free frame
💡 Difficulty: easy | ✅ Correct: B

📖 Explanation: Read‑only code pages cannot be changed, so their modify bit is always clear. When such a page is selected for replacement, the OS knows there is no need to write it back; it can simply discard the page and update the page table. Choice B reflects this efficient handling. Choice A would cause unnecessary I/O. Choice C misstates that the page stays in memory. Choice D suggests a swap that isn’t needed. This scenario illustrates how the OS optimizes replacement for immutable pages.

🔗 Related Topics (MCQs)