When does a page fault occur?

2025

When does a page fault occur?

Answer: C. The page is not present in memory.Concept. Demand paging divides a process’s virtual address space into fixed-size pages and gives a page a physical frame in main memory only when that page is…

  1. A.

    The page is present in memory.

  2. B.

    A deadlock occurs.

  3. C.

    The page is not present in memory.

  4. D.

    Buffering occurs.

Attempted by 552 students.

Show answer & explanation

Correct answer: C

Concept. Demand paging divides a process’s virtual address space into fixed-size pages and gives a page a physical frame in main memory only when that page is actually referenced. Every page-table entry therefore carries a valid (present) bit that records whether the page currently has a frame, and the memory-management unit (MMU) consults this bit on every address translation.

Application. Trace one memory reference through that mechanism:

  1. The CPU issues a virtual address; the MMU splits it into a page number and an offset within the page.

  2. The MMU reads the page-table entry for that page number and inspects its valid bit.

  3. With the valid bit set to 1, the entry supplies a frame number, the MMU forms the physical address, and the access completes entirely in hardware.

  4. With the valid bit set to 0, no frame holds the page, so the translation cannot be completed and the hardware raises a trap to the operating system. That trap is the page fault.

  5. The operating system’s page-fault handler locates the page in backing store, loads it into a free frame (evicting a victim page first if no frame is free), updates the page-table entry and its valid bit, and restarts the interrupted instruction.

Contrast. The other conditions named in the choices sit outside this translation path:

  • A page that is already in memory — its valid bit is 1, the MMU completes the translation in hardware, and no trap reaches the operating system.

  • A deadlock — a circular wait among processes holding resources; it stops progress, but it arises from resource allocation rather than from address translation.

  • Buffering — a staging area that absorbs speed differences during an I/O transfer; it never involves a page-table valid bit.

Cross-check. A page fault is raised by the MMU during address translation, not by the scheduler or the I/O subsystem, so only a reference to a page with no frame can produce one. Note also that a page fault is not an error: under demand paging it is the normal mechanism that brings a page in on first use, and only a reference to an unmapped or protection-violating address escalates into a segmentation fault reported to the process.

Result. A page fault occurs when the referenced page is not present in physical memory.

Explore the full course: Cdac C Cat Complete Preparation

Loading lesson…