retagged by
911 views
0 votes
0 votes

Consider a $2$ – way set associative cache memory with $4$ sets and total $8$ cache blocks $(0 – 7)$. Main memory has $64$ blocks $(0 - 63)$. If LRU policy is used for replacement and cache is initially empty then total number of conflict cache misses for the following sequence of memory block references is:

$0 \  5 \  9 \  13 \  7 \  0 \ 15 \  25$

  1. $2$
  2. $3$
  3. $0$
  4. $1$
retagged by

4 Answers

Best answer
8 votes
8 votes

Reference string: 0  5  9  13  7  0  15  25

0 - set 0 - Compulsory miss

5 - set 1 - Compulsory miss

9 - set 1 - Compulsory miss (set 1 now full)

13 - set 1 - Compulsory miss (5 replaced, but this is not conflict miss; if 5 is again accessed then that access causes conflict miss by its definition. Remember that conflict miss is something which can be avoided if the cache is fully associative and hence it can never happen with compulsory miss)

7 - set 3 - Compulsory miss

0 - set 0 - Hit

15 - set 3 - Compulsory miss

25 - set 1 - Compulsory miss - 9 replaced. Again this is not a conflict miss. 

So, number of conflict misses = 0. 

Ref GATE question

selected by
0 votes
0 votes
Sir can you describe all other misses?

Compulsary misses are 8 rt?
0 votes
0 votes

2 - way set associative cache means number of Blocks per set is 2 . And there are total 4 sets .

memory block references is : 0  5  9  13  7  0  15  25 

conflict misses occur due to the contention of multiple blocks for the same cache set .

 Set selection = ( memory block reference or block address) % (number of sets)

0% 4 = set 0    
5% 4 = set  1
9% 4 = set 1    
13% 4 = set 1  now 5 get replaced 
7% 4 = set 3
0% 4 = set 0     cache hit
15% 4 = set  3
25% 4 = set 1  now 9 get replaced


So total number of conflict misses are 0 , 7 compulsory misses .

edited by
0 votes
0 votes

First miss of any element is a compulsory miss (in demand paging/caching).

Given: 0 5 9 13 7 0 15 25

Only 0 is repeated twice, so maximum conflict misses can be 1 (ie just for the element 0). For rest others, it'll be just the one compulsory miss.

If you make the cache, and trace out this reference string, 0 is a hit the second time. Hence, there are no conflict misses.

Option C

Answer:

Related questions