GATE / CS ARCHIVE

GATE CSE 2004 / QUESTION 65

Two-way LRU cache conflicts

Computer Organization & Architecture · Cache Memory · Full GATE CSE 2004 paper

GATE 2004, Q65 2 marks · MCQ
Report issue

Cache Memory

Question 65, GATE 2004: A two-way set-associative cache contains four blocks total and uses LRU replacement. How many misses occur for block references 8,12,0,12,8? Assume an initially empty cache and conventional block-number modulo number-of-sets mapping.
Options:
(A) 2
(B) 3
(C) 4
(D) 5
Tap to enlarge
Your answer
Answer & solution

Answer: C (no official key was published)

1. Four blocks in a two-way cache means two sets. With the standard block-number modulo 2 mapping,8,12,0 all map to the same set.

2. Starting empty:8 miss gives[8];12 miss gives[8,12];0 miss evicts least-recent 8, giving[12,0];12 hits and becomes MRU;8 misses and evicts 0. Thus four misses.

3. The unused other set cannot absorb these conflicting blocks. An initially empty cache and conventional set indexing are assumed.

4. Teaching check: Only two ways are available in the even-numbered set despite four blocks existing overall. The access to 12 after inserting 0 is a hit and changes recency. That change determines which entry is evicted on the final 8 reference, although the miss count remains four.

Original paper, page 9