19. Paging: TLBs Flashcards
What is TLB? Where is it located?
TLB (translation-lookaside buffer) is located on memory-management unit (MMU) and is simply hardware cache of popular virtual-to-physical address translations
What is basic algorithm for TLB?
- Extract VPN
- Check if TLB holds translation for this VPN
- If it does, it’s a cache hit
- If it does not, consult the page table and put the translation in TLB
- Retry instruction
How does TLB achieve high hit rate?
Due to spatial locality, when several memory references can be in the same page. In this case if page was loaded for element n, the element n+1 will be a hit (if in the same page). TLB also relies on temporal locality.
Who handles TLB miss?
It can be either hardware (CISC systems) or OS (RISC systems)
What should be considered when OS handles the TLB miss?
Hardware should alter the PC so when return-from-trap instruction is executed, the original instruction is retried. Also OS has to make sure not to cause an infinite loop of TLB misses
What is inside TLB?
Usually, 32, 64 or 128 entries. Each entry consists of VPN, PFN and other bits such valid, protection, dirty bit and an address-space identifier
How is situation handled when TLB has duplicate VPNs each from different process mapping to different PFNs?
One option is just to flush TLB on each context switch. Another option is to store ASID in TLB and also in CPU register (to know what ASID to lookup)
What is formula for effective memory access time?
EMAT=(TLB hit rate×TLB access time)+(TLB miss rate×page table access time)