A process is allocated 8 GB of virtual memory on a machine with only 4 GB of physical RAM. The program runs successfully. How is this possible?
AThe OS compresses pages in RAM to fit twice as much data
BVirtual memory allows pages not currently in use to reside on disk; the OS loads them on demand via page faults, keeping only the active working set in RAM
CThe CPU silently discards memory accesses that fall outside physical RAM
DThe program is allocated 4 GB of real memory and 4 GB of empty address space that cannot actually be used
Demand paging makes this possible: not all pages need to be in RAM simultaneously. Pages currently unused reside on disk (swap space). When the process accesses a page on disk, a page fault occurs — the OS loads that page into a free frame, possibly evicting another page, then resumes the process. As long as the program's working set (actively used pages) fits in RAM, it runs fine. Only if it tries to use all 8 GB simultaneously would performance degrade severely (thrashing).
Question 2 Multiple Choice
When a CPU instruction triggers a page fault, what is the correct sequence of events?
AThe process is terminated; the OS logs the error and notifies the user
BThe CPU retries the instruction automatically up to three times before invoking the OS
CThe hardware signals the OS; the OS finds the page on disk, loads it into a free frame, updates the page table, and restarts the faulting instruction
DThe OS immediately swaps the entire process out to disk and loads a different process
A page fault is a hardware exception that transfers control to the OS page-fault handler. The handler locates the needed page on disk (in swap space), finds or frees a physical frame (evicting another page if necessary), reads the page from disk into that frame, marks the page table entry valid, and restarts the instruction that originally triggered the fault. From the process's perspective, the access simply took longer. The process is not terminated — page faults are the normal mechanism for demand paging.
Question 3 True / False
A page fault usually signals a programming error, and the operating system is expected to terminate the faulting process.
TTrue
FFalse
Answer: False
Page faults are a normal, expected part of demand paging — not errors. Every time a process first accesses a page that hasn't been loaded yet, a page fault occurs and the OS loads it from disk. This is the designed mechanism that enables virtual address spaces larger than physical RAM. Only a specific type of page fault — accessing an invalid address (a segmentation fault) — results in process termination. The valid/invalid bit distinguishes between 'this page is on disk' (load it) and 'this address is not mapped' (terminate).
Question 4 True / False
The maximum size of a process's virtual address space is determined by the amount of physical RAM installed in the system.
TTrue
FFalse
Answer: False
Virtual address space size is bounded by the address width of the CPU, not by physical RAM. On a 64-bit system with 48-bit virtual addresses (typical x86-64), each process can have up to 2^48 = 256 TB of virtual address space — far exceeding any practical amount of RAM. Physical RAM limits how many pages can reside in memory simultaneously, which affects performance (page fault frequency), but the virtual address space itself is constrained by the hardware's addressing capability.
Question 5 Short Answer
Why does a program that causes many page faults run dramatically slower, and what is the extreme form of this condition called?
Think about your answer, then reveal below.
Model answer: Each page fault requires reading a page from disk into RAM — a disk access takes roughly 10 milliseconds, while reading from RAM takes about 100 nanoseconds, making disk roughly 100,000× slower. A program that repeatedly accesses pages not in physical memory spends most of its time waiting for disk I/O rather than executing instructions. The extreme case — where the OS spends more time swapping pages than executing code — is called thrashing, and it can reduce effective throughput to near zero.
The performance gap between RAM and disk is the fundamental constraint behind demand paging's cost. Occasional page faults are acceptable; frequent ones indicate the working set (actively used pages) no longer fits in RAM. The OS attempts to minimize this through page replacement algorithms (LRU, CLOCK, etc.) that predict which pages to keep resident. Understanding this tension — unlimited virtual address space vs. the cost of every page fault — explains why memory access patterns and working set size matter enormously for real program performance.