Consider a small two-way set-associative cache memory, consisting of four blocks. For choosing the block to be replaced, use the least recently used (LRU) scheme. The number of cache misses for the following sequence of block addresses is:
.
View worked solution
Answer: C
To find the number of cache misses, we first determine the cache configuration:
- Total number of blocks:
- Set associativity: -way
- Number of sets: (Set 0 and Set 1)
A block with address maps to set index:
All block addresses in the given sequence () are even numbers. Therefore, all of them map to Set 0. Since each set can hold at most blocks, the problem simplifies to managing a cache of size using the Least Recently Used (LRU) replacement policy.
Let's trace the state of Set 0 step-by-step (ordered from Most Recently Used (MRU) to Least Recently Used (LRU)):
| Step | Block Address | Set 0 Contents (MRU → LRU) | Result |
|---|---|---|---|
| 1 | Miss | ||
| 2 | Miss | ||
| 3 | (8 is replaced as it is LRU) |
Miss | |
| 4 | (12 becomes MRU) |
Hit | |
| 5 | (0 is replaced as it is LRU) |
Miss |
Counting the misses from the trace, we get a total of cache misses.
Free practice · Your answers on this page are not saved.
