Consider a 4-way set associative cache (initially empty) with total 16 cache blocks. The main memory consists of 256 blocks and the request for memory blocks is in the following order:
0, 255, 1, 4, 3, 8, 133, 159, 216, 129, 63, 8, 48, 32, 73, 92, 155.
Which one of the following memory block will NOT be in cache if LRU replacement policy is used?
(A) 3
(B) 8
(C) 129
(D) 216
Answer: (D)
Explanation: 4 way set associative so 16 block will be divided in 4 sets of 4 blocks each.
We apply(Address mod 4) function to decide set.
Set 0 | 0 | 48 | | 0 | mod4=0 | * |
4 | 32 | 255 | mod4=3 | * |
8 | 8 | 1 | mod4=1 | * |
216 | 92 | 4 | mod4=0 | * |
Set 1 | 1 | 1 | 3 | mod4=3 | * |
133 | 133 | 8 | mod4=0 | * |
129 | 129 | 133 | mod4=1 | * |
73 | 73 | 159 | mod4=3 | * |
Set 2 | | | 216 | mod4=0 | * |
| | 129 | mod4=1 | * |
| | Â Â Â Â Â Â Â Â Â 63 | mod4=3 | * |
| | 8 | mod4=0 | * |
Set 3 | 255 | 155 | 98 | mod4=0 | * |
3 | 3 | 32 | mod4=0 | * |
159 | 159 | 73 | mod4=1 | * |
63 | 63 | 92 | mod4=0 | * |
| | | | 155 | Mod4=3 | * |
All * are misses S1 in the first stage ans S2 in the second.
In the second stage 216 is not present in the cache.
So, (D) is correct option.
Quiz of this Question