liveBook · Manning

Page fault

As explained in Rust in Action: Systems programming concepts and techniques

A page fault is a memory-access condition in which the requested address is unavailable and the required data must be fetched into memory.

A page fault occurs when the CPU receives a valid memory address whose data is not currently in physical RAM. The fault signals the operating system to fetch the required page into memory. section 6.4.1 section 12.1

A page fault is normally recoverable rather than a sign of an illegal address. It belongs to the CPU’s fault and exception terminology, while a segmentation fault indicates that the requested address is illegal. section 12.1

The surrounding memory mechanism includes:

  • Pages: fixed-size blocks of real memory, typically 4 KB on 64-bit operating systems. section 6.4.1
  • Virtual memory: the address-space view presented to a program by the operating system. section 6.4.1
  • Page tables: operating-system data structures that translate virtual addresses into real-memory addresses. section 6.4.1
  • Swapping: moving a page temporarily stored on disk back into main memory when requested. section 6.4.1

A missing but valid page

A program accesses an address within its virtual address space. If the corresponding data is unavailable in physical RAM, the CPU raises a page fault; the operating system fetches the data into memory so execution can continue. section 12.1 section 6.4.1

Figure 12.1 A visual taxonomy of how the terms interrupt, exception, trap, and fault interact within Intel’s x86 family of CPUs. Note that signals do not appear within this figure. Signals are not interrupts.

Use the taxonomy figure to distinguish faults from traps, exceptions, interrupts, and signals in Intel’s x86 terminology. section 12.1

How Rust in Action: Systems programming concepts and techniques covers it

How deep it goes
Defines the condition and relates it to swapping and address translation, but stops short of detailing the handler’s implementation.
Examples
Uses missing data in RAM, disk-backed page retrieval, and a CPU terminology taxonomy as concrete illustrations.
What it assumes
Assumes basic memory-address knowledge while defining virtual memory, real memory, pages, page tables, and swapping.
What you can do after
Evaluate whether a memory-access event is a recoverable page fault or an illegal-address segmentation fault.
How it connects
Connects page faults with virtual memory, page tables, swapping, physical memory, faults, exceptions, interrupts, and segmentation faults.

Also explained in

Compare how 2 books explain page fault →

Related concepts

This explainer was generated by Manning's knowledge graph from the text of Rust in Action: Systems programming concepts and techniques. The section links point to the parts of the book it draws on.