Page Fautls

How does the OS handle a page fault?

On fault, an interrupt causes the CPU to jump to the page fault handler:

Finding the page on disk

Find or create a page frame

Issues with Page Faults

Memory reference overhead

There are 2 references to memory for every memory access: one to the page table, and one to the actual memory. This can be mitigated by using a TLB (Translation Lookaside Buffer), which is essentially a cache for the page table.

Memory required to hold a page table can be large

Old Solution: Paging the page table

Can be solved by paging the page table! (ie. have a page table for the page table). Keep the "system" page table in physical memory, and the "user" page table in virtual memory. This is no longer done in practice.

New Solution: Multi-level page tables

Simply add another level of indirection. Instead of having a single page table, have a page table of page tables. This works well because the page table is sparsely populated in practice, so it is a waste to have a PTE mapped for every page in the address space.

This is the solution used in modern operating systems.

Two-level page table

Other Alternatives