Memory Hierarchy
A fully associative cache holding 2 lines with LRU replacement starts empty. If blocks are referenced in the order A, B, A, C, B, A, how many misses occur?
- A4
- B5
- C6
Show answer and explanation
Answer: B. 5
Step by step: A (miss, [A]), B (miss, [A,B]), A (hit, A becomes most recent), C (miss, evicts least recent B, [A,C]), B (miss, evicts least recent A, [C,B]), A (miss, evicts least recent C, [B,A]), for 5 misses. Counting 4 comes from wrongly evicting A when C arrives; under LRU, the hit on A made it the most recent. 6 overlooks the hit on the third reference.
- A. 4 results from evicting the wrong block.
- B. Correct. Only the third reference (A) hits, giving 5 misses.
- C. 6 overlooks the hit on the third reference to A.