Virtual Memory and Page Faults In operating systems that implement virtual memory, what best describes a page fault event when a running program accesses memory?

Difficulty: Easy

Correct Answer: It is an access to a page that is not currently resident in physical memory (RAM)

Explanation:


Introduction / Context:
A page fault is a fundamental concept in virtual memory systems used by modern operating systems. Understanding what triggers a page fault clarifies how the OS transparently extends memory using disk-backed pages and on-demand loading.


Given Data / Assumptions:

  • Virtual memory is enabled and pages are the unit of memory management.
  • Processes reference virtual addresses that must be translated to physical frames.
  • The OS maintains page tables with presence/valid bits.


Concept / Approach:
When a process references a virtual address, the memory management unit (MMU) checks the corresponding page table entry. If the valid/present bit indicates the page is not in RAM, the MMU raises a page-fault exception. The OS then services the fault by bringing the needed page into a free frame (possibly evicting another page) and resumes the faulting instruction.


Step-by-Step Solution:
Step 1: Process issues a load/store to a virtual address.Step 2: MMU consults the page table entry (PTE) for that page.Step 3: If PTE.present = 0, a page-fault trap is generated.Step 4: OS page-fault handler locates the page on disk (swap or file), selects a free/eviction frame, and schedules I/O.Step 5: After I/O completes, OS updates the PTE (present = 1, frame number set), then restarts the faulting instruction.


Verification / Alternative check:
A minor (soft) page fault occurs when the page is already in memory (e.g., in page cache) but not mapped; a major (hard) page fault requires disk I/O. In both cases, the trigger is that the page was not currently resident or mapped for the requesting process.


Why Other Options Are Wrong:
Option A: A page fault is not inherently an error or data corruption; it is a normal control-flow event.Option B: Not every access causes a fault—only accesses to non-resident or unmapped pages.Option D: Accessing another process’s memory would normally cause a protection fault, not a page fault.Option E: Not applicable because Option C is correct.


Common Pitfalls:

  • Confusing page faults with segmentation/protection faults.
  • Assuming all page faults indicate performance problems; many are expected during normal execution.
  • Believing a page fault always implies disk access; soft faults do not.


Final Answer:
It is an access to a page that is not currently resident in physical memory (RAM).

Discussion & Comments

No comments yet. Be the first to comment!
Join Discussion