Virtual Memory and Paging
Virtual memory gives each program its own large, contiguous address space that the hardware and operating system map onto physical memory in fixed-size pages, providing isolation, protection, and the illusion of more memory than physically exists.
Definition
Virtual memory is a memory-management technique that maps the virtual addresses used by a program to physical memory addresses via page tables, dividing memory into fixed-size pages and allowing pages to reside in physical memory or on backing store as needed.
Scope
This topic covers address translation through page tables, the translation lookaside buffer (TLB) that caches translations, page faults and demand paging, page replacement and the working-set principle, and the protection that virtual memory provides. It sits at the boundary of architecture and operating systems. It excludes file storage of paged-out data (file systems) and on-chip data caching (cache organization and policies), though it interacts with both.
Core questions
- How are virtual addresses translated to physical addresses through page tables?
- How does the TLB accelerate translation, and what happens on a TLB miss?
- What occurs on a page fault, and how is demand paging handled?
- How does the working-set concept guide page replacement and prevent thrashing?
Key concepts
- virtual and physical address spaces
- pages and page frames
- page tables
- translation lookaside buffer (TLB)
- page faults and demand paging
- page replacement
- working set and thrashing
- memory protection
Key theories
- Working-set model
- The working set is the set of pages a process references over a recent time window; keeping each active process's working set resident in physical memory avoids thrashing, in which excessive paging collapses performance, and informs replacement and admission decisions.
Mechanisms
A program's virtual address is split into a page number and an offset. The page number indexes page tables (often multi-level) to find the physical frame; the TLB caches recent translations to avoid walking the tables every access. If a referenced page is not resident, a page fault transfers control to the operating system, which fetches the page from backing store and may evict another according to a replacement policy guided by locality and working-set behavior.
Clinical relevance
Virtual memory is fundamental to modern operating systems: it isolates processes from one another for security and stability, lets many programs share physical memory, and allows programs larger than physical RAM to run. TLB and page-fault behavior significantly affect performance, and address-space layout underpins protection and memory-safety defenses.
History
Virtual memory originated with the Atlas computer at Manchester in the early 1960s, introducing paging and the page-fault mechanism. Denning's 1968 working-set model gave a principled account of locality and thrashing. Hardware support via TLBs and multi-level page tables, and later features such as large pages, made virtual memory ubiquitous in general-purpose systems.
Key figures
- Peter J. Denning
- Maurice Wilkes
- John L. Hennessy
- Abraham Silberschatz
Related topics
Seminal works
- denning1968
- hennessy2019
- silberschatz2018
Frequently asked questions
- What happens on a page fault?
- A page fault occurs when a program accesses a virtual page not currently in physical memory. The hardware traps to the operating system, which locates the page on backing store, brings it into a free or evicted frame, updates the page tables, and resumes the program as if nothing had happened.
- What is thrashing?
- Thrashing is a collapse in performance when the active processes' combined working sets exceed physical memory, so the system spends most of its time paging data in and out rather than doing useful work. Keeping working sets resident, or reducing the load, avoids it.