Paging
Address Spaces and Virtual Memory
Multi-Level Page Tables
In the lectures, we imagined page tables as a single array of entries, like the page table shown below:
We can make two (other) observations about this page table:
- It's sparse. Many of the entries are empty.
- Pages are allocated in contiguous regions, so the page table tends to have long runs of unused entries.
Which suggests a way we could shorten our page table—and use less memory!
Notice that the page table has a blue line every eight entries, dividing the table into blocks of eight pages.
If we look at each block of pages, we can see that some blocks have pages in use (darker colors), and some do not. Since we only care about the memory that's in use, we can drop the empty blocks, which leaves us with three separate eight-slot page tables with pointers to physical memory frames.
Now we add a new eight-slot upper-level page table whose in-use slots point to the appropriate subtable, giving us a hierarchical or multi-level page table.
(Notice that when there is no memory allocated in a block, we can simply have the upper-level page table entry point not point anywhere instead of a to subtable. This is how we can save memory by not allocating subtables for blocks of pages that are not in use.)
(When logged in, completion status appears here.)