Demand paging loads a page into memory only when it is first accessed.
Page fault sequence: the CPU raises a fault when the page table marks the page invalid; the OS checks that the address is legal (otherwise it sends a segmentation fault); finds a free frame (or evicts a victim page, writing it back if dirty); reads the page from disk; updates the page table and TLB; and restarts the faulting instruction.
A minor fault finds the page already in memory and just maps it (for example a shared library or first-touch zero page); a major fault needs disk I/O.
Loading…