A program's view of memory
A program's address need not identify the physical memory location bearing the same number. Virtual memory provides a process with an address space in which instructions, stacks, dynamically allocated data, and other contents are organized. The operating system and hardware translate accesses into physical locations, allowing several processes to use the same machine's memory without exposing its complete layout to each program.
This is an abstraction of addressing and management, not merely a remedy for insufficient capacity. Translation and protection remain useful when all active pages fit in physical memory. Conversely, a large virtual address space does not imply that every possible address is valid or that physical storage has been allocated for every location.
Pages, frames, and translation
Paging divides an address space into fixed-size pages and physical memory into corresponding page frames. Adjacent virtual pages need not occupy adjacent frames. A process therefore does not require one contiguous physical region for all its contents. Page tables record the mappings and associated state.
For translation, a virtual address is separated into a virtual page number and an offset within that page. The mapping supplies a physical frame number; combining it with the unchanged offset identifies the physical location. Page tables themselves consume memory, and looking them up adds work. A translation lookaside buffer, or TLB, caches translations so that repeated accesses can avoid repeatedly consulting the page table.
Address mappings and isolation
Two processes can use the same numerical virtual address while reaching different physical contents through their respective mappings. Access permissions also constrain operations such as reading, writing, and executing. A program cannot simply choose another address and thereby acquire unrestricted access to another process or the operating system. Deliberately arranged shared mappings remain compatible with this protection goal.
An invalid address, a permissions violation, and a valid page that is not currently resident are different conditions. Each can require operating-system intervention, but bringing data into memory does not make an unauthorized access legitimate. Hardware encodes these distinctions differently; the operating system may need additional records to interpret a fault.
Demand paging and its limits
Demand paging brings contents into memory when they are needed rather than requiring everything to be resident in advance. Accessing a valid but nonresident page triggers fault handling. If its contents are stored externally, the operating system retrieves them, updates the mapping, and resumes the interrupted instruction. The backing contents may come from swap space or from a program file, so a page fault is not synonymous with reading a swap file.
Separating residency from addressability permits larger working environments, but it does not create unlimited resources. External-storage access is much slower than ordinary memory access, and frequent page transfers can impose substantial costs. Virtual memory is therefore a managed addressing and storage abstraction, not a promise that disk behaves like equally fast RAM.
References: [3]