Virtual Memory and Page Faults
Explain virtual memory at a high level. What happens on a page fault?
Answers use simple, clear English.
Quick interview answer
Virtual memory maps process virtual addresses to physical frames via page tables. On an access to an unmapped/absent page, the CPU raises a page fault; the OS loads from disk/swap or allocates a frame, or signals SIGSEGV if illegal. This enables isolation, sparse address spaces, and overcommit (with risk).
Detailed answer
Virtual memory maps process virtual addresses to physical frames via page tables. On an access to an unmapped/absent page, the CPU raises a page fault; the OS loads from disk/swap or allocates a frame, or signals SIGSEGV if illegal. This enables isolation, sparse address spaces, and overcommit (with risk). Thrashing occurs when working sets exceed RAM and paging dominates.
Full explanation
Thrashing occurs when working sets exceed RAM and paging dominates.
Real example & use case
Diagnosing a service spike in major page faults when the working set no longer fits in the node RAM.
Pros & cons
Pros: isolation + larger than RAM illusion. Cons: TLB misses and swap latency under pressure.