GATE Computer ScienceVery hardGATE CS (PYQ pattern)

A loop reads a[i] and then b[i] for i = 0..1023, where a and b are int arrays (4 bytes) starting at byte addresses 0 and 4096. The data cache is 4 KB with 32-byte blocks. How many misses occur in a direct-mapped cache and in a 2-way set-associative LRU cache of the same size, as (direct, 2-way)?

  1. A. (2048, 2048)
  2. B. (2048, 256)
  3. C. (256, 256)
  4. D. (256, 2048)

Correct answer: B. (2048, 256)

In the direct-mapped cache a[i] and b[i] (4096 apart) share a line and evict each other every access: 2048 misses. With 2 ways both blocks live in the same set, so only compulsory misses remain: 1024 ints / 8 per block = 128 blocks per array, 256 in all.

More Computer Organization and Architecture questions

Exams that ask this topic