GateAI
Cache Memory and Hierarchy

GATE CSE 2017 Set 1 · Q51

NAT2 marksMedium

Time

Consider a 2-way set associative cache with 256 blocks and uses LRU replacement. Initially the cache is empty. Conflict misses are those misses which occur due to contention of multiple blocks for the same cache set. Compulsory misses occur due to first time access to the block. The following sequence of accesses to memory blocks (0,128,256,128,0,128,256,128,1,129,257,129,1,129,257,129)(0, 128, 256, 128, 0, 128, 256, 128, 1, 129, 257, 129, 1, 129, 257, 129) is repeated 10 times. The number of conflict misses experienced by the cache is _________.

Your answerNumerical answer

Enter a value to check

Solution

Step-by-step verified solution

Official answer: 76 (±0)

Cache Memory and Hierarchy

### Cache Organization

  • Total number of cache blocks = 256256

  • Associativity = 22-way set-associative

  • Number of sets:

    Sets=2562=128(indexed 0 to 127)\text{Sets} = \frac{256}{2} = 128 \quad (\text{indexed } 0 \text{ to } 127)

### Mapping of Blocks

  • Set index for block B=B(mod128)B = B \pmod{128}

  • Blocks 0,128,2560, 128, 256 map to Set 0\text{Set } 0.

  • Blocks 1,129,2571, 129, 257 map to Set 1\text{Set } 1.

The given sequence consists of accesses to Set 00 followed by identical relative accesses to Set 11:

  • Sequence for Set 00: (0,128,256,128,0,128,256,128)(0, 128, 256, 128, 0, 128, 256, 128)

  • Sequence for Set 11: (1,129,257,129,1,129,257,129)(1, 129, 257, 129, 1, 129, 257, 129)

### Trace for Set 00 (Capacity = 2 blocks, LRU replacement)

Iteration 1:

  1. Access 0: Compulsory miss →\rightarrow Cache: [0][0]

  2. Access 128: Compulsory miss →\rightarrow Cache: [0,128][0, 128]

  3. Access 256: Compulsory miss (replaces 00) →\rightarrow Cache: [128,256][128, 256]

  4. Access 128: Hit →\rightarrow Cache: [256,128][256, 128]

  5. Access 0: Conflict miss (replaces 256256) →\rightarrow Cache: [128,0][128, 0]

  6. Access 128: Hit →\rightarrow Cache: [0,128][0, 128]

  7. Access 256: Conflict miss (replaces 00) →\rightarrow Cache: [128,256][128, 256]

  8. Access 128: Hit →\rightarrow Cache: [256,128][256, 128]

  • In Iteration 1 for Set 0: 33 Compulsory misses, 22 Conflict misses.

Iterations 2 through 10 (9 iterations): Starting cache state: [256,128][256, 128] (256256 is LRU, 128128 is MRU)

  1. Access 0: Conflict miss (replaces 256256) →\rightarrow Cache: [128,0][128, 0]

  2. Access 128: Hit →\rightarrow Cache: [0,128][0, 128]

  3. Access 256: Conflict miss (replaces 00) →\rightarrow Cache: [128,256][128, 256]

  4. Access 128: Hit →\rightarrow Cache: [256,128][256, 128]

  5. Access 0: Conflict miss (replaces 256256) →\rightarrow Cache: [128,0][128, 0]

  6. Access 128: Hit →\rightarrow Cache: [0,128][0, 128]

  7. Access 256: Conflict miss (replaces 00) →\rightarrow Cache: [128,256][128, 256]

  8. Access 128: Hit →\rightarrow Cache: [256,128][256, 128]

  • Each subsequent iteration produces 44 conflict misses in Set 00.

  • Total conflict misses for Set 0=2+(9×4)=380 = 2 + (9 \times 4) = 38.

### Total Conflict Misses Since Set 11 follows the exact same pattern:

Total Conflict Misses=38 (Set 0)+38 (Set 1)=76\text{Total Conflict Misses} = 38 \text{ (Set 0)} + 38 \text{ (Set 1)} = 76

Try the question first, then check your work.

Think the official key or this write-up is wrong?

Report error or challenge

Examiner trap

The misconception this question tests

This Cache Memory and Hierarchy previous year question is Q51 of the GATE CSE 2017 Set 1 paper. Find more GATE CSE PYQs on Cache Memory and Hierarchy in Computer Organization and Architecture, or browse all GATE CSE PYQs.

Free diagnostic

Where do you stand for GATE?

Take the 20-minute diagnostic: the 3 topics that cost you the most marks, and a rank range. Or sit 5 related Cache Memory and Hierarchy PYQs now with no account.

One GATE CSE PYQ every morning

An official question by email at 7 AM IST, with a link to its verified solution. Unsubscribe in one click.

Cache Memory and Hierarchy in GATE CSE

Cache Memory and Hierarchy has 47 GATE CSE PYQs across 23 papers from 2011 to 2026. 16 of them are 2-mark NAT questions like this one, and GATE CSE 2017 Set 1 has 3.

How GATE tests Cache Memory and Hierarchy

More from GATE CSE 2017 Set 1

Share this solution

A plain-text card for WhatsApp or Telegram study groups.

GateAI solution cardGATE CSE 2017 Set 1 · Q51 · NAT

Consider a 2-way set associative cache with 256 blocks and uses LRU replacement. Initially the cache is empty. Conflict misses are those misses which occur due to contention of multiple blocks for the same cache set. Compulsory misses occur due to first time access to the block. The following sequence of accesses to memory blocks (0, 128, 256, 128, 0, 128, 256, 128, 1, 129, 257, 129, 1, 129, 257, 129) is repeated 10 times. The number of conflict misses experienced by the cache is …

Topic-wise GATE CS PYQs with verified steps

Independent practice explanation verified by the GateAI team. GATE is conducted by the IITs; question text follows the official paper.