Translation Lookaside Buffer (TLB)
The translation lookaside buffer is a small (32-128 entry) fully-associative cache for the page table, that stores singular mappings between the VPN and PPN. Additionally, it also contains control metadata, similar to PTEs. During context switches, all entries to the TLB are flushed.
There are a few scenarios that could occur during a TLB access:
- A TLB hit occurs when the VPN is already mapped to a PPN inside the TLB, resulting in a single access (of the TLB).
- A TLB miss occurs when the VPN is not in the cache, thereby requiring access to the page table. It results in two accesses (of the TLB and of the page table).
- A page fault occurs when a TLB miss occurs, and the VPN-indexed page table entry has an invalid bit. Then, the disk needs to be accessed to obtain the desired page and store it at the first free physical page of RAM, updating mappings in page table, and storing in TLB.