16.2.7 Worked Examples Virtual Memory
Virtual memory allows programs to behave as if they have a larger memory than they actually do. The way this works is by using virtual addresses, which refer to addresses on disk, in our programs. The virtual addresses are translated into physical addresses using the page map which is a lookup table that has one entry per virtual page. The page map knows whether the virtual page is in physical memory and if so it immediately returns the physical page number. If the page is not in physical memory, then this causes a fault which means that the virtual page must be brought in from disk to physical memory before it can be accessed. To do this the least recently used (LRU) page in the physical memory is removed to make room for the address that is currently being requested. The page map is also updated with the new mapping of virtual to physical pages. Since bringing data to and from disk is an expensive operation, data is moved in chunks. This makes sense because of the conce...