GATE / CS ARCHIVE

SIMILAR QUESTIONS / COMPUTER ORGANIZATION & ARCHITECTURE

Trace repeated references in an empty direct-mapped cache

2 questions solved the same way, newest first. Back to Computer Organization & Architecture

How these are solved

Split each of four hexadecimal addresses into block offset, line index and tag, then simulate the repeated P,Q,R,S sequence for ten rounds from an initially empty direct-mapped cache.

2 marks · MSQ
Report issue

Direct-mapped cache conflicts

Cache Memory

Question 52, GATE 2026: A byte-addressed machine has 16 MB physical memory and an initially empty 4 KB direct-mapped cache with 16-byte blocks. Repeat P,Q,R,S ten times, where P=0x845B32, Q=0x845B26, R=0x845B36, S=0x846B32. Select: A every P misses; B every R hits; C every Q misses; D all S after the first hit. K=2¹⁰,M=2²⁰.
Tap to enlarge
Select all that apply
Answer & solution

Official answer: A, B

Givens and goal

A byte-addressed machine has 16 MB physical memory and an initially empty 4 KB direct-mapped cache with 16-byte blocks. Repeat P,Q,R,S ten times, where P=0x845B32, Q=0x845B26, R=0x845B36, S=0x846B32. Select: A every P misses; B every R hits; C every Q misses; D all S after the first hit. K=2¹⁰,M=2²⁰.

Approach

Split addresses into tag, line index, and byte offset before tracing the repeating pattern.

Step-by-step solution

1. There are 4096/16=256 cache lines, requiring 8 index bits, and a 16-byte block requires 4 offset bits. In a 24-bit physical address, the remaining 12 bits form the tag.
2. The decompositions (tag,index,offset) are P=(845,B3,2), Q=(845,B2,6), R=(845,B3,6), S=(846,B3,2), all hexadecimal. P and R share one memory block; S has the same index but a different tag; Q has a separate index.
3. In the first cycle, P misses and loads tag 845 into line B3. Q misses and loads its separate line B2. R hits the block loaded by P. S misses and replaces B3 with tag 846.
4. At the start of every later cycle B3 contains S’s tag. P therefore misses and replaces S; R subsequently hits P’s block; S then misses and replaces P again. Q remains resident and hits in all nine later cycles.
5. A and B are true; C and D are false. As a check, misses total 10 for P, 1 for Q, 0 for R, and 10 for S: 21 misses and 19 hits over 40 accesses. Spatial locality explains R’s hits, whereas index conflict explains repeated P/S misses.

Original paper, page 38 · Answer key

2 marks · MSQ
Report issue

Cache Memory

Question 54, GATE 2022: An initially empty 2 KB direct-mapped data cache has 64-byte blocks; physical space is 64 KB and words are 16 bits. Access P,Q,R,S in that order ten times, with first-byte addresses 0xA248,0xC28A,0xCA8A,0xA262. Select true statements: A every S hits; B P never evicted after loading; C only R,S remain at the end; D every R evicts Q.
Tap to enlarge
Select all that apply
Answer & solution

Official answer: A,B,D

There are 2048/64=32 cache lines. A byte address maps to line (address>>6) mod 32. P and S both lie in the same block from 0xA240 through 0xA27F, mapping to line 9. Q and R map to line 10 but have different tags. Thus the first P loads the P/S block permanently, and every S access hits. Each Q access replaces R (or loads the initially empty line), and every R access replaces Q. At the end the cache contains the P/S block and the R block, so P still resides and C is false. Select A, B, D. Each two-byte word fits inside its block.

The 16-bit physical byte address splits into 5 tag bits, 5 line bits and 6 offset bits. P: line9,tag 20,offset 8; S: line9,tag 20,offset 34; Q: line10,tag 24,offset 10; R: line10,tag 25,offset 10. The first cycle is miss,miss,miss,hit; later cycles are hit,miss,miss,hit. Therefore there are 21 misses and 19 hits across 40 accesses.

Original paper, page 36 · Answer key