GATE Computer ScienceVery hardGATE CS (PYQ pattern)

A direct-mapped cache of 128 bytes with 32-byte blocks (4 lines) is used while a program reads the 4-byte words at byte addresses 0, 4, 8, …, 252 in order, and then reads the same 64 words again in the same order. How many cache hits occur in total (out of 128 reads)?

  1. A. 120
  2. B. 64
  3. C. 96
  4. D. 112

Correct answer: D. 112

64 words span 8 blocks. The first pass has 8 compulsory misses (7 hits per block); the 8 blocks map into 4 lines so the second pass again misses once per block (blocks 4-7 evicted 0-3). Total misses 2 × 8 = 16, so hits = 128 − 16 = 112 (a 4-block cache would not help since the loop is twice the cache).

More Computer Organization and Architecture questions

Exams that ask this topic