5. Operating systemsVirtual memory
Virtual memory
Virtual memory gives every program the illusion of a large, private memory all to itself. The addresses a program uses aren’t real hardware locations: the CPU’s memory management unit translates each one, page by page (usually 4 KB chunks), into a physical location using tables the operating system keeps for each process. A small cache of recent translations, the TLB, makes most lookups nearly free. This indirection means programs can’t see each other’s memory, pages can be loaded only when first touched, idle ones can be pushed to disk, and a shared library can be mapped into many processes at once. Touching a page that isn’t mapped triggers a page fault, and the kernel either loads it or kills the program.
In this lesson: A 3D page-table walk: a virtual address splits into bits that index each level and end at a frame. TLB hits and misses, and page faults.