It is a busy Thursday afternoon and your office laptop has 8 GB of RAM. Chrome is open with thirty tabs, Excel holds last month's ledger, a video call is running in a corner, and the reconciliation tool your manager asked for has just been launched. Add up what these programs want and the total is well beyond 8 GB. Yet nothing crashes. Each program behaves as if it owned a large, quiet room: its first byte sits at address 0, nobody else's data is anywhere near it, and if the spreadsheet has a bug and scribbles over its own memory, the browser never notices.
How can that be? The memory your programs see is not the memory in the chips. Every address a program uses is a kind of promise, and a piece of hardware between the CPU and the RAM turns each promise into a real place, billions of times a second. That arrangement is virtual memory, and the usual way of building it is paging. It is one of the topics the IT exams return to again and again, as one-line MCQs (what a TLB does, where virtual memory lives), as written notes (virtual memory against cache, why virtual memory is needed) and as arithmetic (page-table size, TLB tag bits, access time, page faults under FIFO and LRU).
By the end of this chapter you will be able to split a virtual address into page number and offset and translate it to a physical address. You will count the bits and the memory of a page table, flat and two-level, and say why x86-64 uses four levels. You will explain the TLB, work out its tag size and calculate the effective access time. You will follow a page fault from the hardware to the disk and back, and put a number on what it costs. You will tell the replacement rules FIFO, LRU and Optimal apart, say why only FIFO of the three can show Belady's anomaly, and explain thrashing. And you will compare virtual memory with a cache point by point.