operating-systems

Definition

Page Fault

A page fault is an exception raised by the MMU when a process accesses a page mapped in its virtual address space but not currently resident in physical RAM.

Handling

Page Fault Handler

The OS intervenes to bring the required page into memory:

  1. Trap to Kernel: Hardware generates a trap, transferring control to the OS
  2. Locate Page: OS determines page location on secondary storage
  3. Find Free Frame: OS searches for an available frame; if none free, invokes replacement policy
  4. I/O Operation: Page read from disk into allocated frame
  5. Update Page Table: Page table updated (present bit set to 1)
  6. Restart Instruction: CPU restarts the faulting instruction

Thrashing

Performance Impact

Frequent page faults lead to thrashing, where the system spends more time performing I/O than executing user code.