Skip to content
Official PYQ · 2017

GATE CS 2017 Set 1 Q51 — Memory Hierarchy: Cache, Main Memory and Secondary Storage

Explain with AI

Consider a 22-way set associative cache with 256256 blocks and uses LRU\text{LRU} replacement. Initially the cache is empty. Conflict misses are those misses which occur due to the contention of multiple blocks for the same cache set. Compulsory misses occur due to first time access to the block. The following sequence of access to memory blocks :

      {0,128,256,128,0,128,256,128,1,129,257,129,1,129,257,129}\big \{0,128,256,128,0,128,256,128,1,129,257,129,1,129,257,129 \big \}

is repeated 1010 times. The number of conflict misses experienced by the cache is _________ .

View worked solution

Answer: 76

The cache is 22-way set associative with 256256 blocks. Thus, the number of sets is:

S=2562=128 setsS = \frac{256}{2} = 128 \text{ sets}

The set index for any memory block BB is given by B(mod128)B \pmod{128}. Mapping the blocks in the sequence to their respective sets:

  • Set 0: Blocks 0,128,2560, 128, 256
  • Set 1: Blocks 1,129,2571, 129, 257

Since the sets are independent, we can analyze the accesses to Set 0 and Set 1 separately. Because the access patterns are identical in structure, both sets will experience the same number of conflict misses.

Analysis for Set 0 (Capacity = 2 blocks, LRU):

The access sequence for Set 0 in one iteration is: {0,128,256,128,0,128,256,128}\{0, 128, 256, 128, 0, 128, 256, 128\}.

Iteration 1:

  1. Access 00: Compulsory Miss (Cache: [0][0])
  2. Access 128128: Compulsory Miss (Cache: [128,0][128, 0])
  3. Access 256256: Compulsory Miss (Cache: [256,128][256, 128], 00 evicted)
  4. Access 128128: Hit (Cache: [128,256][128, 256])
  5. Access 00: Conflict Miss (Cache: [0,128][0, 128], 256256 evicted)
  6. Access 128128: Hit (Cache: [128,0][128, 0])
  7. Access 256256: Conflict Miss (Cache: [256,128][256, 128], 00 evicted)
  8. Access 128128: Hit (Cache: [128,256][128, 256])

In Iteration 1, Set 0 has 2 conflict misses. The state of Set 0 at the end of Iteration 1 is [128,256][128, 256] (with 128128 as MRU and 256256 as LRU).

Iterations 2 to 10 (9 iterations):
Starting with state [128,256][128, 256]:

  1. Access 00: Conflict Miss (Cache: [0,128][0, 128])
  2. Access 128128: Hit (Cache: [128,0][128, 0])
  3. Access 256256: Conflict Miss (Cache: [256,128][256, 128])
  4. Access 128128: Hit (Cache: [128,256][128, 256])
  5. Access 00: Conflict Miss (Cache: [0,128][0, 128])
  6. Access 128128: Hit (Cache: [128,0][128, 0])
  7. Access 256256: Conflict Miss (Cache: [256,128][256, 128])
  8. Access 128128: Hit (Cache: [128,256][128, 256])

Each of the remaining 9 iterations results in exactly 4 conflict misses.

Total Conflict Misses:

  • Conflict misses for Set 0 = 2+(9×4)=382 + (9 \times 4) = 38
  • Conflict misses for Set 1 = 3838 (by symmetry)

Total conflict misses experienced by the cache = 38+38=7638 + 38 = 76.

Free practice · Your answers on this page are not saved.

Published
Report a correction
Keep exploringMore Memory Hierarchy: Cache, Main Memory and Secondary Storage questions