A specific cache used to maintain the record of recently used virtual to physical memory transactions is called a Translation Lookaside Buffer (TLB). It is comprised of page numbers and their corresponding frame numbers that is stored in each TLB entry. TLB can be accessed by using the
Paging supports a virtual memory mechanism, which impacts the page table read and delays every load and store operation at least twice. It demands a considerable amount of mapping data as it divides the process into pages, which are small, fixed-sized blocks. Since the mapping data is typically maintained in primary storage, paging necessitates an additional memory lookup for every virtual address the CPU generates. It would be prolonged to read transactional data from memory before every operation.
Note: Accessing the TLB takes less time than accessing the main memory because it is a memory cache close to the CPU.
If a virtual address is provided, then the CPU checks the TLB. If a page table entry is matched (TLB hit), then the frame number is accessed, and the physical address is generated. When processing a page table, if an entry is missing from the TLB (TLB miss), then first, the TLB determines whether the page is already present in primary storage; if not, a page fault is sent; and second, the TLB is reset to add the new page entry.
Requests are transmitted straight from the CPU to the cache when the cache is virtually addressed, and the TLB is only used when the cache is missed. The CPU performs a TLB lookup on each memory transaction if the cache is physically addressed and the resultant physical address is transferred to the cache.
The workflow of TLB is defined as:
The following steps are involved in TLB hit case:
Likewise, TLB miss steps are as follows:
The following illustrates the step-by-step procedure for TLB hit:
Similarly, the working of TLB miss is shown below:
EMAT is calculated with the help of the following formula:
Where
Note: This formula is only valid when single-level paging is in use, and there are no page faults.