Effective memory access time — Aptitude Question
Effective memory access time: A paged system has a TLB hit ratio of 80%. A TLB lookup takes 20 ns and a memory… Answer and worked solution on CodeKairo.
- Topic: OS, DBMS & Networks
- Section: Programming MCQs
- Difficulty: Hard
- Time target: 150 seconds
Question
A paged system has a TLB hit ratio of 80%. A TLB lookup takes 20 ns and a memory access takes 100 ns. On a TLB miss the page table must be read from memory before the data itself is fetched. What is the effective memory access time?
Options
- 100 ns
- 120 ns
- 140 ns
- 220 ns
Show the answer and the worked solution
Correct answer: C. 140 ns
Worked solution
- On a hit the cost is the TLB lookup plus one memory access: 20 + 100 = 120 ns, which happens 80% of the time.
- On a miss the cost is the TLB lookup, a memory access for the page table and a second one for the data: 20 + 100 + 100 = 220 ns, which happens 20% of the time.
- The weighted average is 0.8 × 120 + 0.2 × 220 = 96 + 44 = 140 ns.
Answer: 140 ns.
The idea
Read the question carefully for whether the TLB lookup is charged on a miss as well, and whether the hit ratio is given as a fraction or a percentage — both are where marks are lost.
Shortcut. Every access pays 20 + 100 ns and only the misses pay a second 100: 120 + 0.2 × 100 = 140 ns.
Common trap. "120 ns" is the cost of a hit alone, ignoring the 20% of accesses that must also read the page table.