Programming Tutorials

TLB and Effective Memory Access Time (EMAT): Formula and Worked Examples

The Translation Lookaside Buffer (TLB) is a small, fast cache that stores recently used virtual-to-physical address translations. It helps the processor avoid repeatedly reading page-table entries from memory. When a program accesses memory, the Memory Management Unit (MMU) uses the translation to turn a virtual address into a physical address.

To understand Effective Memory Access Time (EMAT), you need to know what happens on a TLB hit and a TLB miss. This guide explains both cases, derives the standard formula, works through numerical examples, and highlights the assumptions that matter in operating-systems exam questions.

Advertisement

What Is a Translation Lookaside Buffer (TLB)?

A page table stores the mapping between a process’s virtual pages and physical memory frames. Reading the page table from main memory for every access would add extra memory operations. A TLB reduces this overhead by keeping a cache of recently used address translations.

A virtual address is commonly divided into two parts:

Advertisement
  • Virtual page number (VPN): identifies the virtual page that needs to be translated.
  • Page offset: identifies the byte or location within that page. The offset remains unchanged during translation.

The TLB is searched using the virtual page number. If a matching entry is found, the corresponding physical frame number can be used with the original offset to form the physical address.

How TLB Hit and TLB Miss Work

1. TLB hit

A TLB hit occurs when the required virtual-page translation is already in the TLB. The processor obtains the physical frame number from the TLB and proceeds to access the requested data.

2. TLB miss

A TLB miss occurs when the required translation is not present in the TLB. The MMU or operating-system architecture-specific handling mechanism must consult the page tables to find the mapping. If the mapping is valid and the page is available, the translation can be added to the TLB for future use.

A TLB miss does not automatically mean a page fault. A page fault is a separate exception that occurs when the requested translation or access cannot be completed normally—for example, because the page is not currently present or the access violates its permissions. Some page faults are handled without reading data from storage, such as certain lazy-allocation or copy-on-write cases.

What Is Effective Memory Access Time (EMAT)?

Effective Memory Access Time (EMAT), also called effective access time (EAT) in many operating-systems texts, is the average time for a memory access after accounting for the different costs of TLB hits and misses.

Because a hit and a miss do not take the same amount of time, EMAT is calculated as a weighted average. The weights are the probabilities of each outcome:

  • Hit ratio (h): the fraction of accesses whose translations are found in the TLB.
  • Miss ratio (1 − h): the fraction of accesses whose translations are not found in the TLB.

Use h as a decimal in calculations. For example, a 90% hit ratio is 0.90, and the corresponding miss ratio is 0.10.

EMAT Formula for a Single-Level Page Table

The standard textbook formula below assumes that the TLB is searched first, the lookup is sequential, a TLB miss requires one page-table memory access, and the final data access requires one more memory access.

Let:

  • tTLB = time required to search the TLB
  • tM = time required for one main-memory access
  • h = TLB hit ratio, expressed as a decimal

Case 1: Time required for a TLB hit

When the translation is found in the TLB, the system performs the TLB lookup and then accesses the requested data in memory.

Hit time = tTLB + tM

Case 2: Time required for a TLB miss

When the translation is not found in the TLB, the simplified single-level model includes:

  1. One TLB lookup to establish that the entry is missing.
  2. One main-memory access to read the page-table entry.
  3. One additional main-memory access to read or write the requested data.

Miss time = tTLB + 2 × tM

Combine the two cases

Multiply each case’s time by its probability and add the results:

EMAT = h × Hit time + (1 − h) × Miss time

Substituting the two expressions gives:

EMAT = h × (tTLB + tM) + (1 − h) × (tTLB + 2 × tM)

After simplifying:

EMAT = tTLB + (2 − h) × tM

If a question explicitly says to ignore TLB lookup time, set tTLB to zero. The formula then becomes EMAT = (2 − h) × tM.

Worked Example: Calculate EMAT Step by Step

Question: A system has a TLB lookup time of 10 nanoseconds and a main-memory access time of 100 nanoseconds. If the TLB hit ratio is 90%, calculate the effective memory access time. Assume a single-level page table and sequential lookup.

Given:

  • tTLB = 10 ns
  • tM = 100 ns
  • h = 90% = 0.90
  • Miss ratio = 1 − 0.90 = 0.10

Step 1: Calculate hit time

Hit time = 10 + 100 = 110 ns

Step 2: Calculate miss time

Miss time = 10 + 100 + 100 = 210 ns

Step 3: Calculate the weighted average

EMAT = (0.90 × 110) + (0.10 × 210)

EMAT = 99 + 21

Final answer: EMAT = 120 nanoseconds.

This result is an average under the stated textbook assumptions. It is not a fixed latency that every real processor will experience.

EMAT with a Multilevel Page Table

Modern operating systems can use hierarchical page tables. If a simplified problem states that a TLB miss requires k page-table levels to be read from main memory, the miss path includes k page-table accesses plus one final data access.

Using the same sequential-lookup assumptions:

  • Hit time: tTLB + tM
  • Miss time: tTLB + (k + 1) × tM

The generalised formula is:

EMAT = h × (tTLB + tM) + (1 − h) × [tTLB + (k + 1) × tM]

It can also be simplified to:

EMAT = tTLB + [1 + k × (1 − h)] × tM

This is a teaching model, not a universal hardware timing rule. Real processors may cache intermediate page-table information, use multiple levels of TLBs, support large-page mappings, or overlap parts of address translation with other work. The actual miss cost can therefore differ from a simple count of main-memory accesses.

Common Mistakes in EMAT Questions

  • Using a percentage directly: convert 90% to 0.90 before substituting it into the formula.
  • Forgetting the TLB lookup on a miss: include it when the question assumes that the TLB is searched first and gives a lookup time.
  • Counting only one memory access on a miss: in the single-level model, a miss requires a page-table access and then a data access.
  • Confusing a TLB miss with a page fault: a miss means the translation was not cached; the page table may still contain a valid mapping.
  • Ignoring the page-table structure: if the question specifies multiple levels, use the stated number of page-table accesses.
  • Mixing units: convert all times to the same unit, such as nanoseconds, before calculating.
  • Ignoring the wording about parallel lookup: some questions state that TLB lookup overlaps another operation or should be ignored. Follow the model specified in the question rather than automatically adding the lookup time.

Why TLB Performance Matters

A higher TLB hit ratio generally reduces the average address-translation overhead in the simplified model because fewer accesses need a page-table walk. Programs that repeatedly access a relatively small working set can often reuse cached translations. Large or irregular working sets may put more pressure on translation caches.

Operating systems and processors also use techniques such as hierarchical page tables, page-walk caches and larger page mappings to manage translation overhead. Linux documentation describes its page-table hierarchy and the role of the MMU, TLBs and page-walk caches. The details depend on the processor architecture and memory-management configuration.

Frequently Asked Questions

1. What is the difference between a TLB hit and a TLB miss?

A TLB hit means the requested virtual-to-physical translation is already cached in the TLB. A TLB miss means it is not cached, so the system must consult the page tables or use the architecture’s translation-handling mechanism.

2. Does every TLB miss cause a page fault?

No. A TLB miss can be resolved by finding a valid, resident page-table entry and loading the translation into the TLB. A page fault is a separate exception that may occur if the mapping is absent, the page is not resident, or the requested access is not permitted.

3. What happens if the TLB hit ratio is 100%?

In the single-level sequential model, every access follows the hit path, so EMAT equals tTLB + tM. This is the model’s best case, not a guarantee about the latency of every real processor access.

4. What happens if the TLB hit ratio is 0%?

Every access follows the miss path. For a single-level page table, EMAT becomes tTLB + 2 × tM under the stated assumptions.

5. Why is the TLB needed?

The TLB caches recently used address translations so that the processor does not need to perform a full page-table lookup for every memory reference. This reduces translation overhead and helps improve memory-access performance.

Conclusion

The Translation Lookaside Buffer speeds up virtual-to-physical address translation by caching recent mappings. Effective Memory Access Time combines the cost of TLB hits and misses using their respective probabilities. For a single-level page table with sequential lookup, remember the hit time, miss time and weighted-average formula—but always check the assumptions in the question. Multilevel page tables and modern processor features can make the real miss path more complex.

Further Reading

RochakGuy

Hi, I'm Piyush and I'm a passionate blogger. I love sharing my insights on Rochaksite.com. I'm committed to providing practical and informative content that helps readers achieve their goals and make informed decisions. When I'm not writing, I enjoy exploring new topics and trends in Technology and indulging in my personal hobbies and interests.

Related Articles

Leave a Reply

Your email address will not be published. Required fields are marked *

Back to top button