GATE / CS ARCHIVE

SUBJECT COLLECTION

Computer Organization & Architecture · Cache Memory

69 questions, newest first

GATE CSE has asked 69 questions on Cache Memory (Computer Organization & Architecture) from 1992 to 2026, in 36 of the 46 papers; the most recent is in GATE CSE 2026 Set 2. In the last five years it carried 3 marks per 100-mark paper on average, against 2.7 since 2003. Since 2014 the questions have been 19 NAT, 12 MCQ and 4 MSQ. 13 groups of questions here are solved the same way; “One per method” keeps the newest of each.

Browse topics
Show
2 marks · MCQ
Report issue

How associativity changes cache tag length

Cache Memory

Question 38, GATE 2026: A byte-addressed processor has a 2^32-byte physical address space. The cache holds 2^23 bytes in 128-byte blocks. Compare direct-mapped tag length M with K-way set-associative tag length N, where K=2^L and L∈{1,2,3}. Choices are N=M+L, M−L, M+K, M−K.
Tap to enlarge
Your answer
Answer & solution

Official answer: A

Givens and goal

A byte-addressed processor has a 232-byte physical address space. The cache holds 223 bytes in 128-byte blocks. Compare direct-mapped tag length M with K-way set-associative tag length N, where K=2L and L∈{1,2,3}. Choices are N=M+L, M−L, M+K, M−K.

Approach

Partition the same physical address into tag, set index, and block offset for the two organizations.

Step-by-step solution

1. Byte addresses contain 32 bits. A 128-byte block needs log2(128)=7 offset bits.
2. The cache contains 223 / 27 = 216 blocks. In a direct-mapped organization, there are 216 sets, requiring 16 index bits. Hence its tag length is M=32−16−7=9.
3. K=2L ways reduce the set count to 216−L. The set index therefore uses 16−L bits while the block offset remains 7 bits.
4. The set-associative tag length is N=32−(16−L)−7=9+L=M+L.

Common error: Associativity changes the number of sets, not the number of bytes per block. Offset bits do not grow with the number of ways.

Concrete check: for L=2, the cache is four-way. It has 214 sets, so its address fields are 11 tag bits, 14 set-index bits and 7 offset bits, totaling 32. Direct mapping used 9+16+7=32. The increase is log₂4=2 bits, not four bits; this distinguishes M+L from M+K. Subtracting L or K would move the tag in the wrong direction.

Original paper, page 27 · Answer key

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 · NAT
Report issue

Maximum direct-mapped cache size from an address

Cache Memory

Question 56, GATE 2026: A byte-addressed machine has 1 MB physical memory. Address 0xA2C28 maps to cache block number 176 (decimal), numbered from zero. Find the largest cache size in KB under the conventional power-of-two direct-mapped bit-field organization. K=2¹⁰,M=2²⁰.
Tap to enlarge
Answer & solution

Official answer: 128

Givens and goal

A byte-addressed machine has 1 MB physical memory. Address 0xA2C28 maps to cache block number 176 (decimal), numbered from zero. Find the largest cache size in KB under the conventional power-of-two direct-mapped bit-field organization. K=2¹⁰,M=2²⁰.

Approach

Locate the required binary index within the physical address and maximize its allowed leading zeros.

Step-by-step solution

1. A 1 MB byte-addressed space has 20-bit addresses. The given address is 1010 0010 1100 0010 1000 in binary. Let b be block-offset bits and s be index bits. The cache index is (address >> b) mod 2s and cache capacity is 2b+s bytes.
2. The required index 176 is binary 10110000, so s≥8. In the address, the eight-bit slice equal to 10110000 occurs with its low end at bit 6: shifting right by b=6 gives 0x28B0, whose low eight bits are 0xB0=176. Examining possible offsets 0 through 12 yields no other matching eight-bit slice.
3. For b=6, the low 9,10, and 11 bits of 0x28B0 also equal 176 because the added bits are zero. The low 12 bits are 0x8B0=2224, so s=12 fails; all larger widths retain that unwanted set bit and fail too.
4. The maximum feasible choice is b=6,s=11: block size 2⁶=64 bytes, line count 2¹¹=2048, and capacity 2¹⁷=131072 bytes=128 KB. As a direct check, floor(0xA2C28/64)=10416, and 10416 mod 2048=176.
5. The feasible smaller capacities with the same block size are 16,32,64 KB. This maximization relies on conventional power-of-two cache/block sizes and consecutive index bits. Arbitrary modular mappings or nonstandard capacities are not implied by the source wording; retain that model qualification with official answer 128.

Original paper, page 39 · Answer key

2 marks · MCQ
Report issue

Calculating direct-mapped cache tag storage

Cache Memory

Question 36, GATE 2025: A byte-addressable system has 1 MiB of main memory, 20-bit addresses, and a 16 KiB direct-mapped cache with 16-byte blocks. How many bits store the tag values for all lines, excluding other metadata? A 6×2^10; B 8×2^10; C 2^12; D 2^14. Here K=2^10 and M=2^20.
Tap to enlarge
Your answer
Answer & solution

Official answer: A

Step through it (7 steps)

Approach: Split an address into tag, cache-line index and byte offset; then multiply tag width by the number of lines.
A 16-byte block requires log₂16=4 offset bits. The cache contains 16 KiB/16 bytes=214/24=210 lines, so direct mapping requires 10 index bits to select a line.
From the 20 address bits, the remaining tag width is 20−10−4=6 bits. Every line needs its own stored tag to distinguish the main-memory blocks that map to that line. Therefore total tag storage is 210×6=6144 bits, option A.
This is a bit count, not a byte count. The 16 KiB cache size describes data capacity; valid bits, dirty bits and other control metadata are not part of the requested tag values. Ignoring the block offset or using the number of bytes instead of lines would produce the wrong tag width or multiplier.

Original paper, page 36 · Answer key

2 marks · NAT
Report issue

Averaging cumulative memory-access path times

Cache Memory

Question 53, GATE 2025: Memory is searched in order L1,L2,main memory. L1 has 95% hit rate and 10 ns access time. L2 has 85% hit rate conditional on an L1 miss; its 20 ns time already includes the L1 miss penalty. Main-memory access is 200 ns including both cache miss penalties. Find average access time in ns to two decimals.
Tap to enlarge
Answer & solution

Official answer: 11.83 to 11.87

Our answer: 11.85

Approach: Partition accesses into mutually exclusive completion paths and weight the total time of each path.
An L1 hit has probability 0.95 and total time 10 ns. An L1 miss followed by an L2 hit has probability 0.05×0.85=0.0425 and total time 20 ns. Missing both caches has probability 0.05×0.15=0.0075 and total time 200 ns. These probabilities sum to 1.
The expected time is therefore 0.95×10+0.0425×20+0.0075×200=9.50+0.85+1.50=11.85 ns.
The word “including” in the diagram is essential: adding 10 ns again to the L2 or memory path would double-count time already included. Likewise the 85% L2 hit rate applies only to accesses reaching L2, not to all processor requests.

Original paper, page 53 · Answer key

2 marks · MCQ
Report issue

Cache Memory

Question 39, GATE 2025: A byte-addressable system has a direct-mapped cache. Addresses contain 4 tag bits and 12 cache-index bits; each cache block holds one byte. Choose main-memory address capacity and cache data capacity, respectively.
Options: A. 64 KB,4 KB; B. 128 KB,16 KB; C. 64 KB,8 KB; D. 128 KB,6 KB. Use KB=1024 bytes. The original wording says no other information is stored per block.
Tap to enlarge
Your answer
Answer & solution

Official answer: A

A one-byte block needs log2(1)=0 block-offset bits. Therefore each address has tag+index+offset=4+12+0=16 bits. With byte addressing it identifies 216 bytes, or 65536 bytes=64 KB of main memory.

The 12 index bits select one of 212=4096 cache lines. Each line holds one byte of data, so the cache data capacity is 4096 bytes=4 KB. This gives A.

Distinguish data capacity from total physical storage. The tag itself occupies 4 bits per line, so explicitly counting stored tags would add 4096·4 bits=2048 bytes=2 KB, making 6 KB before any other metadata. The offered correct option and standard cache-capacity convention use data bytes only. The original “no other information” wording does not turn the 4 tag bits into addressable data, and no option pairs the 64-KB address space with 6-KB physical storage. Answer: A under the stated data-capacity interpretation.

Original paper, page 30 · Answer key

2 marks · NAT
Report issue

Cache Memory

Question 55, GATE 2025: A two-level cache has L1 access time 1 ns and hit rate 90%. Conditional on reaching L2, its hit rate is 80%; the L1-miss transfer/access penalty through L2 is 10 ns. An L2 miss adds 100 ns to transfer from main memory. Find average memory access time in ns, to one decimal place, using additive miss penalties.
Tap to enlarge
Answer & solution

Official answer: 4.0

Always pay the 1-ns L1 lookup. With probability 1−0.9=0.1, an L1 miss adds 10 ns for the next level. Of those L1 misses, a fraction 1−0.8=0.2 also miss L2 and incur the additional 100 ns. Therefore
AMAT=1+0.1[10+0.2·100]=1+0.1·30=4.0 ns.

An equivalent path-probability calculation makes the nesting clear. L1 hits occur with probability 0.9 and cost 1 ns. L1 miss/L2 hit occurs with probability 0.1·0.8=0.08 and costs 1+10=11 ns. Misses in both levels occur with probability 0.1·0.2=0.02 and cost 1+10+100=111 ns. Their weighted sum is 0.9·1+0.08·11+0.02·111=4.0 ns.

The L2 hit rate is conditional on an L1 miss, not a separate 80% of all requests. Also, the stated miss penalties are additional times; treating them as inclusive complete-path times would describe a different model. Answer: 4.0.

Original paper, page 43 · Answer key

2 marks · MSQ
Report issue

Track dirty blocks under cache write policies

Cache Memory

Question 53, GATE 2024: Two set-associative caches use LRU replacement. WBC is write-back; WTC is write-through. Which are true? A A WBC read miss never evicts a dirty block. B A WTC read miss never writes a victim block back to memory. C A WBC write hit can change a dirty bit. D A WTC write miss always writes its victim back before loading a block.
Tap to enlarge
Select all that apply
Answer & solution

Official answer: B, C

Approach: Replacement policy selects the victim, whereas write policy determines whether the victim may contain newer data than main memory.
1. In a write-back cache, a write can modify the cached block without immediately updating memory. The dirty bit records this mismatch. On a write hit to a clean block, the bit can change from 0 to 1, proving C.
2. LRU selection does not guarantee a clean victim. A read miss can evict a dirty write-back block, which must then be written to memory. A's “never” is false.
3. Write-through propagates each write to memory, so a replaced cache block does not need an eviction-time dirty-block write-back in the standard completed-write model. Hence B is true.
4. D is false for the same reason. Moreover, a write-through cache may use no-write-allocate, in which case a write miss need not load a new block or select a cache victim at all.
Answer: B and C. Write-through memory traffic caused by the current write is not the same thing as writing back an evicted dirty block.

Original paper, page 33 · Answer key

2 marks · NAT
Report issue

Combine instruction and data cache stall costs

Cache Memory

Question 56, GATE 2024: A program has 25% load/store instructions. Ideal CPI is 2; instruction-cache miss rate is 2%; data-cache miss rate is 8%; every miss costs 100 cycles. Find the speedup with perfect instruction and data caches, rounded to two decimals.
Tap to enlarge
Answer & solution

Official answer: 3.00

Approach: Express every stall contribution per executed instruction so they can be added to the base CPI.
1. Every instruction requires an instruction fetch. Instruction-cache stalls therefore contribute 0.02 misses/instruction ×100 cycles/miss=2 cycles/instruction.
2. Only 25% of instructions access data memory. Data-cache stalls contribute 0.25 accesses/instruction ×0.08 misses/access ×100 cycles/miss=2 cycles/instruction.
3. With the stated additive, nonoverlapped miss-penalty model, actual CPI=ideal CPI+instruction stalls+data stalls=2+2+2=6.
4. Perfect caches remove both stall terms and restore CPI=2. With the same instruction count and clock rate, execution time is proportional to CPI, so speedup=old time/new time=6/2=3.
Answer: 3.00. Using 8% for every instruction would overcount data misses. The reciprocal 2/6 is the new-to-old time ratio, not the speedup factor.

Original paper, page 33 · Answer key

2 marks · NAT
Report issue

Cache Memory

Question 64, GATE 2023: An 8-way set-associative cache has 64 KiB data capacity and 32-bit byte addresses divided into tag, set index, and block offset. Find the tag width.
Tap to enlarge
Answer & solution

Official answer: 19

Step through it (4 steps)

For byte addressing, cache data capacity equals associativity times number of sets times bytes per block. Therefore the number of sets times block size is 65536/8=8192=213. The index and block-offset fields together occupy 13 bits regardless of the particular power-of-two block size. The tag has 32-13=19 bits. As usual, the stated capacity is data capacity, excluding tag and replacement metadata.

Teaching detail. Let block size be 2b bytes and the number of sets be 2s. Eight ways means each set stores eight blocks, so 216=23·2s·2b and s+b=13. These lower address bits choose a set and byte within a block; the remaining bits identify which memory block occupies the selected way. Therefore tag width is independent of the unspecified block size, provided the conventional power-of-two partition is used. Associativity bits do not appear as a separate address field selecting a way.

Original paper, page 68 · Answer key

1 mark · MSQ
Report issue

Cache Memory

Question 24, GATE 2022: WB and WT are set-associative LRU caches using write-back and write-through respectively. Select FALSE statements: A both need a dirty bit per block; B every WB write hit transfers data to main memory; C WT eviction causes no cache-to-memory transfer; D a WB read miss never evicts a dirty block.
Tap to enlarge
Select all that apply
Answer & solution

Official answer: A,B,D

The question asks for false statements. A is false because write-through does not require dirty bits: writes already update memory. B is false because a write-back hit normally only changes the cache and marks the line dirty. C is true: evicting a write-through line needs no extra write-back. D is false because a write-back read miss can evict a dirty victim and consequently write memory. Thus A, B, D.

Dirty means the cached copy differs from memory. A write-back eviction of a clean victim needs no write; a dirty victim must be written before replacement. LRU determines which victim is chosen, not whether it is dirty, so a read operation can indirectly cause a write-back.

Original paper, page 19 · Answer key

1 mark · NAT
Report issue

Cache Memory

Question 33, GATE 2022: A cache initially has hit rate 0.8, lookup latency 10 ns and additional miss penalty 100 ns. An optimization increases lookup latency to 15 ns, leaving miss penalty unchanged. What minimum new hit rate prevents AMAT increasing? Round to two decimals.
Tap to enlarge
Answer & solution

Official answer: 0.85

Originally the average access time is 10+(1−0.8)100=30 ns. With the slower 15 ns cache it becomes 15+(1−h)100. Requiring this to be at most 30 gives h≥0.85, so the minimum hit ratio is 0.85. The 100 ns miss penalty is additional to the cache lookup, as in the standard AMAT formula.

Solve 15+100−100h≤30: 100h≥85, hence h≥0.85. At exactly 0.85 the AMAT is 15+15=30 ns. A smaller rate would cause the extra cache latency to outweigh the miss-rate improvement.

Original paper, page 23 · 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

1 mark · NAT
Report issue

Cache Memory

Question 22, GATE 2021: A system has 2^32 bytes of byte-addressable main memory and a 32 KB direct-mapped cache, with 1 KB=2^10 bytes and 64-byte cache blocks. How many bits are in the address tag?
Tap to enlarge
Answer & solution

Official answer: 17

Step through it (6 steps)

A byte address has 32 bits. The64-byte block uses 6 offset bits; 32KB/64=512 cache lines use 9 index bits. The remaining tag has 32−6−9=17 bits.

A direct-mapped address is partitioned into tag | line index | block offset. The offset selects one of 64 bytes, so it takes log2 64=6 bits. The data capacity contains 32768/64=512 lines, so index needs log2 512=9 bits. Address width is log2(232)=32 bits, leaving 17. Cache size is assumed to mean data capacity, as usual in this exercise, not data plus tag-store overhead.

Original paper, page 21 · Answer key

1 mark · NAT
Report issue

Cache Memory

Question 19, GATE 2021: Byte-addressable set-associative cache: capacity 2KB, block 64 bytes, addresses 32 bits, tag 22 bits, KB=1024 bytes. Find associativity.
Tap to enlarge
Answer & solution

Official answer: 2

A64-byte block needs 6 offset bits. The remaining index width is 32−22−6=4 bits, giving 16 sets. Capacity2048/64=32 cache lines means 32/16=2 lines per set, so two-way associativity.

Address format is [tag | set index | byte offset]. Capacity includes all ways, so number of sets is not total number of lines unless the cache is direct-mapped. Check reconstruction: 16 sets×2 ways×64 bytes=2048 bytes and 22+4+6=32 address bits.

Original paper, page 64 · Answer key

2 marks · MCQ
Report issue

Cache Memory

Question 27, GATE 2021: Inclusive two-level cache L1,L2 with L2 larger. S1 read misses in write-through L1 do not cause dirty writebacks to L2. S2 write-allocate must accompany write-through and no-write-allocate must accompany write-back. A only S1; B only S2; C both; D neither.
Tap to enlarge
Your answer
Answer & solution

Official answer: A

Write-through propagates each L1 write to the next level, so an evicted L1 line does not need a dirty writeback to L2. S1 is true. Allocation on a write miss is a separate design choice, and the asserted mandatory policy pairing is false. Thus A; conventional write-back/write-allocate and write-through/no-write-allocate combinations already refute S2.

Separate write propagation from write-miss allocation. Write-through specifies when lower memory is updated; write-allocate specifies whether a missing block enters the cache. They are independent policy axes. Inclusion says L1-resident blocks also reside in L2; it does not reverse the normal dirty-state argument for write-through L1.

Original paper, page 68 · Answer key

1 mark · NAT
Report issue

Cache Memory

Question 21, GATE 2020: A 1 MB direct-mapped cache has 256-byte blocks, access time 3 ns, hit rate 94%, and 64-bit words. On a miss, main memory delivers the first word in 20 ns and every subsequent word in 5 ns. Find average access time to one decimal place. Official scoring accepts 13.3 or 13.5 ns as separate values.
Tap to enlarge
Answer & solution

Official answer: 13.3 OR 13.5

Our answer: 13.5 or 13.3 under the two accepted timing conventions

Worked explanation

Convert the word size first: 64 bits is 8 bytes. A block therefore contains 32 words, and the first-word latency is paid once, followed by 31 further transfers, giving 20+31×5=175 ns. Miss probability is 1−0.94=0.06. If the 175 ns is an extra miss penalty after lookup, every reference pays 3 ns and 6% pay the extra penalty. If it is the entire miss-path time instead, only the hit branch uses the separate 3 ns figure in a weighted average. These conventions produce the two official answers already preserved below. The 1 MB capacity and direct mapping are not needed once the hit rate is given. No early-restart timing is specified, so use a full refill.

Derivation and answer

Each block holds 256/8=32 words. A complete refill takes 20+31·5=175 ns. If a miss incurs the 3 ns cache lookup before refill, AMAT=3+0.06·175=13.5 ns. If the 175 ns miss time is treated as the total miss-service time, the weighted average is 0.94·3+0.06·175=13.32 ns, rounding to 13.3. The official key explicitly accepts both 13.3 and 13.5; neither is silently discarded. Both calculations assume full-block service without critical-word early restart.

Original paper, page 8 · Answer key

2 marks · MCQ
Report issue

Cache Memory

Question 30, GATE 2020: A 32-bit-word system has 16 MB byte-addressable memory and a 64 KB four-way set-associative cache with 256-byte blocks. Addresses: A1=0x42C8A4, A2=0x546888, A3=0x6A289C, A4=0x5E4880. Which is true? A A1,A4 map to different sets; B A2,A3 same set; C A3,A4 same set; D A1,A3 same set.
Tap to enlarge
Your answer
Answer & solution

Official answer: B

Worked explanation

Compute organization before extracting bits. Total cache blocks=216/28=28; four blocks per set gives 26 sets. A 24-bit physical byte address therefore divides as tag 10 bits | set 6 bits | byte offset 8 bits. Shifting each address right by 8 discards its final byte; masking the next six bits gives 0x08,0x28,0x28,0x08, or 8,40,40,8. Same set does not require equal tags or equal byte offsets, and four-way associativity does not change this index extraction. Only B among the offered statements is true.

Derivation and answer

The cache has 65536/256=256 lines and 64 four-way sets. Offset uses 8 bits and set index 6 bits, so index=(address>>8)&63. The four addresses map to sets 8, 40, 40, 8, respectively. Exactly A2 and A3 share a set among the listed positive claims, B; A1 and A4 actually also share a set, contrary to A.

Original paper, page 10 · Answer key

1 mark · MCQ
Report issue

Tag and index bits in a fully associative cache

Cache Memory

Question 1, GATE 2019: A byte-addressed processor has 32-bit addresses and a fully associative 16 kB cache with 16-byte blocks. Find tag bits and index bits, in that order. Choices: A (24,0); B (28,4); C (24,4); D (28,0).
Tap to enlarge
Your answer
Answer & solution

Official answer: D

Step through it (6 steps)

Method: partition the address into tag, set index, and block offset.

1. Because memory is byte-addressed, the offset selects one of the 16 bytes in a block. It requires log2(16) = 4 bits.
2. A fully associative cache has only one set containing all cache lines. Any memory block can occupy any line, so the processor address supplies no set index: log2(1) = 0 bits.
3. The remaining address bits identify which memory block is stored: tag bits = 32 − 4 − 0 = 28.
4. The 16 kB capacity determines the number of available lines, not an address index in this organization. Interpreting kB as 1024 bytes gives 1024 lines, all compared associatively.

Result: D, 28 tag bits and 0 index bits. The four low-order bits are an offset, not an index.

Original paper, page 4 · Answer key

2 marks · NAT
Report issue

Bandwidth with block-transfer overhead

Cache Memory

Question 45, GATE 2019: A cache block contains 8 words of 4 bytes each. With a 60 MHz memory clock, serial miss service uses 1 cycle to accept the address, 3 cycles to fetch the block, then transmits 1 word per cycle. Find maximum bandwidth as a coefficient of 10^6 bytes/s.
Tap to enlarge
Answer & solution

Official answer: 160

1. Compute useful bytes per completed block: 8 words×4 bytes/word=32 bytes. Clock frequency is 60×106 cycles per second.
2. The description gives successive stages, so their times add. Address acceptance takes 1 cycle, block fetching takes 3, and sending eight words at one per cycle takes 8. Total service time is 1+3+8=12 cycles per block.
3. The completed-block rate is (60×106)/12=5×106 blocks/s. Multiplying by 32 bytes/block gives 160×106 bytes/s.
4. Thus the requested numeric coefficient is 160. Equivalently, one block takes 12/(60×106)=200 ns, and 32 bytes/200 ns gives the same bandwidth.
5. Counting only the eight transfer cycles would incorrectly ignore the four-cycle overhead. Conversely, interpreting the three fetch cycles as three per word would contradict the stated fetch of all eight words. This calculation assumes the sequential per-block controller service described; overlapping different block transactions would require a separate pipelining model not specified here.

Original paper, page 14 · Answer key

2 marks · MCQ
Report issue

Set-associative cache tag width

Cache Memory

Question 34, GATE 2018: Physical addresses span 2^P bytes, words have 2^W bytes, cache capacity is 2^N bytes, blocks hold 2^M words, and associativity is K. Choose tag bits: A P−N−log₂K; B P−N+log₂K; C P−N−M−W−log₂K; D P−N−M−W+log₂K.
Tap to enlarge
Your answer
Answer & solution

Official answer: B

Method

A byte address has P bits. First convert block capacity from words to bytes, obtaining 2M+W. Cache blocks total 2N−M−W; grouping K per set divides this by K. Address bits split into tag, set index and byte-within-block offset. Increasing associativity at fixed capacity reduces index bits and therefore increases tag bits, a useful sign check on the log₂K term. The result assumes integral power-of-two field sizes.

Solution

A block contains 2M+W bytes. There are 2N−M−W/K sets, so index bits=N−M−W−log2K, and block-offset bits=M+W. Subtract both from P address bits: tag=P−N+log2K, B, under the conventional power-of-two cache parameters.

Original paper, page 14 · Answer key

1 mark · NAT
Report issue

Cache Memory

Question 25, GATE 2017: A two-level cache sees 1.4 memory accesses per instruction. L1 miss rate is 0.1; L2 has 7 misses per 1000 instructions. Find the L2 miss rate to two decimals.
Tap to enlarge
Answer & solution

Official answer: 0.05

1. Choose a common basis of 1000 instructions. This gives 1000×1.4=1400 L1 accesses.

2. L1 misses on 0.1×1400=140 of these, and only those misses access L2. L2 therefore sees 140 accesses, not 1400 and not 1000.

3. Its local miss rate is L2 misses/L2 accesses=7/140=0.05. Dividing 7 by 1400 instead computes a global miss rate and answers a different question.

Original paper, page 13 · Answer key

2 marks · NAT
Report issue

Cache Memory

Question 51, GATE 2017: A 256-block, 2-way set-associative cache uses LRU and starts empty. Repeat this block-reference sequence ten times: 0,128,256,128,0,128,256,128,1,129,257,129,1,129,257,129. Count conflict misses, excluding compulsory first-access misses.
Tap to enlarge
Answer & solution

Official answer: 76.0

Our answer: 76

1. There are 256/2=128 sets. Block number modulo 128 puts {0,128,256} in set 0 and {1,129,257} in set 1; each set holds only two blocks.

2. For the first set-0 subsequence 0,128,256,128,0,128,256,128 the outcomes are compulsory,compulsory,compulsory,hit,conflict,hit,conflict,hit. LRU ends with 256 then 128 from least to most recent. Set 1 behaves identically.

3. Each later subsequence starts with those two survivors: accesses to its first,third,fifth,seventh entries miss, all now conflicts. Thus repetition 1 has four conflicts total, and each of nine later repetitions has eight. Total=4+9×8=76 conflicts, alongside six compulsory misses.

Original paper, page 23 · Answer key

2 marks · NAT
Report issue

Cache Memory

Question 54, GATE 2017: A cache has capacity N words, blocks of B words, and a 10-bit tag when directly mapped. With unchanged capacity and block size, redesign as 16-way set associative. Find tag width.
Tap to enlarge
Answer & solution

Official answer: 14.0

Our answer: 14

1. Address bits are partitioned into tag, set index, and block offset. Keeping B fixed leaves offset width unchanged.

2. A direct-mapped cache has N/B sets. A 16-way cache of the same total capacity has N/(16B) sets, requiring log₂16=4 fewer index bits.

3. The address width has not changed, so those four bits move to the tag. New tag width=10+4=14 bits. Associativity changes the set count, not the number of offset bits.

Original paper, page 24 · Answer key

2 marks · MCQ
Report issue

Cache Memory

Question 29, GATE 2017: L1 and L2 cache access times are 1 and 8 cycles. The additional L2-to-memory miss penalty is 18 cycles. The L1 miss rate is twice the L2 miss rate. Given AMAT=2 cycles, find the rates (L1,L2). A:(0.111,0.056). B:(0.056,0.111). C:(0.0892,0.1784). D:(0.1784,0.0892).
Tap to enlarge
Your answer
Answer & solution

Official answer: A

1. Let m be the local L2 miss rate, conditional on reaching L2. The L1 miss rate is 2m. Every access pays 1 cycle, an L1 miss adds 8, and an L2 miss on that path adds 18.

2. Therefore 2=1+2m(8+18m). Expanding gives 36m²+16m-1=0. The quadratic formula gives m=(-16±√400)/72, so its nonnegative root is 4/72=1/18; the other root is invalid as a probability.

3. Thus L2 misses about 0.05556 and L1 misses 1/9≈0.11111. In the requested L1,L2 order, the rounded pair is A. Treating the L2 rate as a global rate, or charging lower-level time on every hit, would give a different model.

Original paper, page 11 · Answer key

2 marks · NAT
Report issue

Cache Memory

Question 45, GATE 2017: I-cache read time/hit ratio:2 ns/0.8; D-cache:2 ns/0.9; shared L2:8 ns/0.9. Main-memory read time is 90 ns. Caches are direct mapped, use referred-word-first and write-back, and every dirty bit is 0. Of reads,60% fetch instructions and 40% fetch operands. Find average read time in ns to two decimals.
Tap to enlarge
Answer & solution

Official answer: 4.72

1. Compute the chance of reaching L2 by weighting the two L1 miss rates: 0.6(1-0.8)+0.4(1-0.9)=0.12+0.04=0.16. Every read first pays the 2 ns L1 lookup.

2. Conditional on an L1 miss, the L2 lookup adds 8 ns. Its local miss probability is 0.1, and such a miss adds 90 ns for memory. The expected additional time on an L1 miss is therefore 8+0.1·90=17 ns.

3. AMAT=2+0.16·17=4.72 ns. As a separate check, instruction reads average 2+0.2·17=5.4 ns and data reads 2+0.1·17=3.7 ns; 0.6·5.4+0.4·3.7=4.72. Clean blocks eliminate dirty write-back penalties, and referred-word-first permits the demanded read to finish without waiting for an unspecified whole-block transfer.

Original paper, page 18 · Answer key

2 marks · NAT
Report issue

Cache Memory

Question 53, GATE 2017: A byte-addressable main memory contains 2^32 bytes, divided into 32-byte blocks. A direct-mapped cache has 512 lines. How many address bits form the tag field?
Tap to enlarge
Answer & solution

Official answer: 18.0

Our answer: 18

Step through it (6 steps)

1. There are 232 separately addressable bytes, so a memory address needs 32 bits. A 32-byte block needs log₂32=5 low-order offset bits to select a byte within it.

2. A direct-mapped cache with 512=29 lines uses 9 index bits to select the one cache line where a block may reside.

3. The remaining high-order bits distinguish the different memory blocks that map to that same line: tag=32-5-9=18 bits. Equivalently, memory has 227 blocks and each of 29 lines represents 218 possible blocks. Do not use 512 as the cache byte capacity; it is the number of lines.

Original paper, page 21 · Answer key

2 marks · NAT
Report issue

Cache Memory

Question 32, GATE 2016: A machine’s physical addresses have 40 bits. Find tag width in a 512 KB, 8-way set-associative cache under the usual byte-addressed binary-capacity convention.
Tap to enlarge
Answer & solution

Official answer: 24.0 : 24.0

Our answer: 24

Step through it (4 steps)

For byte-addressed memory and binary KB, cache capacity 512 KiB=219 bytes with 8 ways gives 216 bytes per way. Index plus block-offset bits total 16 regardless of block size, leaving 40−16=24 tag bits. The usual power-of-two cache and byte-address convention is assumed.

Let a block contain 2b bytes. The number of cache sets is 219/(2³×2b)=216−b. Therefore the address has b offset bits and 16−b index bits; their sum is fixed even though block size is unstated. The remaining high 24 bits distinguish memory blocks mapping to the same set.

Original paper, page 33 · Answer key

1 mark · NAT
Report issue

Cache Memory

Question 18, GATE 2015: A read takes 50 ns on a cache miss or 5 ns on a hit. Hit rate 80%. Find mean read time in nanoseconds.
Tap to enlarge
Answer & solution

Official answer: 14

The stated miss time is the entire request time, not an extra penalty. Average=0.8·5+0.2·50=14 ns.

The random read time takes only two stated values:5 with probability.8 and 50 with probability.2. Its expected value is the probability-weighted sum, .8×5+.2×50=4+10=14 ns. Do not add 5 to the miss case: the prompt already says the entire request takes 50 ns on a miss. If it had called 50 an additional miss penalty, the formula would differ.

Original paper, page 32 · Answer key

1 mark · MCQ
Report issue

Cache Memory

Question 34, GATE 2015: A byte-addressable main memory has size 2²⁰ bytes. Blocks contain 16 bytes, and a direct-mapped cache has 2¹² lines. Two consecutive memory-byte addresses are hexadecimal E201F and E2020. For address E201F, identify the tag and cache-line address, in hexadecimal. (A) E,201; (B) F,201; (C) E,E20; (D) 2,01F.
Tap to enlarge
Your answer
Answer & solution

Official answer: A

Step through it (7 steps)

1. A hexadecimal digit represents four bits, so the 4+12+4 split aligns exactly with E | 201 | F. The next address E2020 illustrates the offset wrapping from F to 0 and the cache-line index advancing from 201 to 202.

2. The20-bit address has 4 offset bits for 16-byte blocks and 12 index bits for 212 lines, leaving 4 tag bits. Hex E201F therefore splits tagE, index 201, offsetF. Thus A.

Original paper, page 65 · Answer key

2 marks · MCQ
Report issue

Cache Memory

Question 44, GATE 2014: A cache-block reference sequence has length N and n distinct block addresses. At most k distinct block addresses occur between two consecutive references to the same address. What is the miss ratio for an LRU cache with associativity A≥k? A: n/N. B: 1/N. C: 1/A. D: k/n. The printed inequality is non-strict, and the initial cache state is not specified.
Tap to enlarge
Your answer
Answer & solution

Official answer: A

Our answer: A requires strict A>k and an initially empty cache

1. Method and setup. LRU evicts a block after A other distinct blocks mapped to its set have been accessed. Therefore a guaranteed hit requires the intervening distinct-block count for that set to be strictly less than A. Counting one compulsory miss per distinct address is valid only after establishing that all subsequent references hit and that first references begin uncached.

2. Work through the result and its assumptions. An LRU hit requires fewer than A distinct intervening blocks mapping to the same set. The stated bound k suffices when A>k, but not at A=k. For example, let a direct-mapped cache have A=k=1 and let distinct x, y map to the same set. The sequence x, y, x, y has N=4, n=2 and one distinct intervening block on each reuse, yet all four accesses miss, giving 1 rather than n/N=1/2. Thus the official cold-miss-only answer A needs a strict inequality (or a reuse-distance definition including the reused block) and an initially empty cache.

Original paper, page 19 · Answer key

1 mark · NAT
Report issue

Cache Memory

Question 9, GATE 2014: A 16 KB cache is 4-way set associative. A block contains 8 words, each 32 bits. Physical address space is 4 GB. Find the number of tag bits.
Tap to enlarge
Answer & solution

Official answer: 20

Step through it (7 steps)

1. Set up the reasoning. Use the textbook binary KB/GB and byte-addressing convention. Convert words to bytes first: one line has 8×4=32 bytes; compute line count, set count, and their base-two logarithms.

2. Derive the result. A block is 8×4=32 bytes, requiring 5 offset bits. The cache has 16384/32=512 lines and 128 sets, requiring 7 index bits. A4GB byte address is 32 bits, leaving 32−7−5=20 tag bits.

3. Check the interpretation. Do not allocate only three offset bits: those identify the eight words but miss the two byte-within-word bits. The tag, set index, and byte offset together must total the 32 physical-address bits.

Original paper, page 31 · Answer key

2 marks · MCQ
Report issue

Cache Memory

Question 43, GATE 2014: In cache design, which statement is correct? A Smaller blocks imply better spatial locality. B Smaller blocks imply smaller tags and lower tag overhead. C Smaller blocks imply larger tags and lower hit time. D Smaller blocks incur a lower miss penalty.
Tap to enlarge
Your answer
Answer & solution

Official answer: D

1. Set up the reasoning. Use the conventional miss-penalty decomposition: fixed access latency plus time to transfer the fetched block. With finite transfer bandwidth, fetching fewer bytes reduces the transfer component.

2. Derive the result. A smaller cache block requires fewer bytes to refill, reducing the transfer component of a miss penalty under the usual fixed-latency, finite-bandwidth memory model. Thus D is the intended statement. It does not improve the program’s inherent spatial locality, and smaller blocks do not justify a shorter tag or guaranteed lower hit time. If critical-word-first timing or fixed-size physical bursts dominate, the measured penalty need not strictly decrease; the answer uses the textbook full-block refill model.

3. Check the interpretation. Spatial locality describes a program's access pattern, not a benefit created by making blocks smaller. Tag size and hit latency require other cache parameters; D is the intended full-block-refill statement, not a universal guarantee under critical-word-first or fixed-burst timing.

Original paper, page 41 · Answer key

2 marks · MCQ
Report issue

Cache Memory

Question 44, GATE 2014: A cache's associativity doubles while its total capacity and block size stay fixed. Which is guaranteed not to be affected? A tag-comparator width; B set-index-decoder width; C way-selection-multiplexor width; D processor-to-main-memory data-bus width.
Tap to enlarge
Your answer
Answer & solution

Official answer: D

1. Set up the reasoning. Let capacity be C, line size B, and associativity A. The set count is C/(AB), so doubling A halves the number of sets without changing the line-offset field.

2. Derive the result. With capacity C and block size B fixed, doubling associativity halves the set count C/(AB). The set index loses one bit and the tag gains one. The way-selection fan-in doubles, while the processor-to-main-memory data-bus width need not change. Therefore D. Here multiplexor width means its way-selection configuration/fan-in, not the unchanged data-word output width.

3. Check the interpretation. The index loses a bit and the tag gains a bit. More ways require greater selection fan-in, but internal cache organization does not dictate a new external data-bus width. The keyed interpretation of multiplexor “width” is its selection configuration, not its unchanged output-word width.

Original paper, page 41 · Answer key

2 marks · NAT
Report issue

Cache Memory

Question 44, GATE 2014: Cache access times are read hit 1 ns, read miss 5 ns, write hit 2 ns, write miss 10 ns. A sequence performs 100 instruction fetches, 60 operand reads and 40 operand writes. Cache hit ratio is stated as 0.9. Find mean memory-access time in ns.
Tap to enlarge
Answer & solution

Official answer: 1.68

Our answer: 1.68 if each access class has hit ratio 0.9

Step 1: Count instruction fetches as reads: there are 160 reads and 40 writes, 200 accesses total. Under the intended common hit ratio of 0.9 for each class, a read averages 0.9×1+0.1×5=1.4 ns, and a write averages 0.9×2+0.1×10=2.8 ns. Step 2: Weight by access count: (160×1.4+40×2.8)/200=1.68 ns. Miss times are given complete access times, not penalties to add again. Step 3: Preserve the ambiguity: an aggregate hit ratio alone only fixes 20 total misses. If w are write misses, read misses are 20−w and total time is 160+2×40+4(20−w)+8w=320+4w ns. Thus the mean can be 1.6+0.02w for 0≤w≤20, ranging from 1.6 to 2.0 ns. The official 1.68 assumes w=4 or the same hit ratio for both classes.

Original paper, page 63 · Answer key

1 mark · MCQ
Report issue

Set-associative cache line range

Cache Memory

Question 20, GATE 2013: A cache has v sets of k consecutive lines each, sets numbered from 0 in order. Memory block j maps to which line interval? A(j mod v)k through(j mod v)k+k−1; B(j mod v) through(j mod v)+k−1; C(j mod k) through(j mod k)+v−1; D(j mod k)v through(j mod k)v+v−1.
Tap to enlarge
Your answer
Answer & solution

Official answer: A

Block j maps to set s=j mod v. Each earlier set occupies k consecutive lines, so this set starts at sk and ends at sk+k−1. Substituting s gives the interval in A.

First choose the set, not a particular way: s=j mod v. There are s earlier sets, each occupying k line positions, so the first line of set s is sk. The k allowed ways occupy offsets 0 through k−1, hence last line sk+k−1. For example, v=4, k=2, j=6 gives s=2 and lines 4, 5. This example also shows why omitting the factor k, as in B, gives the wrong physical positions.

Original paper, page 5 · Answer key

2 marks · MCQ
Report issue

VIPT synonym avoidance by page colouring

Cache Memory

Question 53, GATE 2013: Using the preceding page size and 1MB16-way VIPT cache with 64-byte blocks, how many page colours prevent synonyms mapping to different sets? A2, B4, C8, D16.
Question 53, GATE 2013: Using the preceding page size and 1MB16-way VIPT cache with 64-byte blocks, how many page colours prevent synonyms mapping to different sets? A2, B4, C8, D16.
Tap to enlarge
Your answer
Answer & solution

Official answer: C

There are 220/(16×64)=210 cache sets. A 64-byte cache block uses six offset bits, so the ten set-index bits are virtual-address bits 6 through 15. From the preceding linked question, the page size is 8 KiB and the page offset consists of bits 0 through 12. Only seven set-index bits (6 through 12) lie inside the page offset and are automatically identical for synonyms. The remaining three bits (13 through 15) can differ between virtual aliases of the same physical page. Distinguishing 23=8 page colours, and requiring aliases of a physical page to use the same colour, makes all index bits agree. Thus eight colours are necessary and sufficient, option C. Equivalently, colours=(cache size)/(associativity×page size)=1 MiB/(16×8 KiB)=8.

Synonyms share a physical page but can have different virtual page numbers. A VIPT lookup uses virtual index bits before the physical tag is known; if any such bit is outside the page offset, aliases can select different sets. Here10 index bits follow 6block-offset bits, ending at bit15. Only bits 0–12belong to the 8KiBpage offset, leaving three potentially different index bits. Colouring controls exactly those three bits, requiring eight choices. More tag bits do not repair selection of the wrong set.

Original paper, page 12 · Answer key

2 marks · MCQ
Report issue

Tag bits in a four-way cache

Cache Memory

Question 54, GATE 2012: A 256 KByte, four-way set-associative write-back cache uses 32-byte blocks and 32-bit byte addresses. Every tag-directory entry holds the tag plus 2 valid bits, 1 modified bit, and 1 replacement bit.
How many address tag bits are there?
(A) 11 (B) 14 (C) 16 (D) 27.
Question 54, GATE 2012: A 256 KByte, four-way set-associative write-back cache uses 32-byte blocks and 32-bit byte addresses. Every tag-directory entry holds the tag plus 2 valid bits, 1 modified bit, and 1 replacement bit.
How many address tag bits are there?
(A) 11 (B) 14 (C) 16 (D) 27.
Tap to enlarge
Your answer
Answer & solution

Official answer: C

Step through it (7 steps)

Using binary cache units, 256 KiB/32 bytes=8192 cache lines. Four lines per set give 2048=2¹¹ sets, so the set index uses 11 bits. A 32-byte block requires 5 byte-offset bits. The remaining address bits are tag bits: 32−11−5=16, C.

Check: The address splits as [16 tag bits | 11 set bits | 5 byte-offset bits]. Associativity reduces the number of sets relative to the number of lines, so using 13 line-index bits would incorrectly treat the cache as direct mapped.

Original paper, page 15 · Answer key

2 marks · MCQ
Report issue

Cache directory size including per-line metadata

Cache Memory

Question 55, GATE 2012: A 256 KByte, four-way set-associative write-back cache uses 32-byte blocks and 32-bit byte addresses. Every tag-directory entry holds the tag plus 2 valid bits, 1 modified bit, and 1 replacement bit.
What is the tag-directory size?
(A) 160 Kbits (B) 136 Kbits (C) 40 Kbits (D) 32 Kbits.
Question 55, GATE 2012: A 256 KByte, four-way set-associative write-back cache uses 32-byte blocks and 32-bit byte addresses. Every tag-directory entry holds the tag plus 2 valid bits, 1 modified bit, and 1 replacement bit.
What is the tag-directory size?
(A) 160 Kbits (B) 136 Kbits (C) 40 Kbits (D) 32 Kbits.
Tap to enlarge
Your answer
Answer & solution

Official answer: A

Step through it (9 steps)

There are 256×1024/32=8192 cache lines and hence 8192 tag-directory entries. The preceding calculation gives a 16-bit address tag. Each entry additionally has the explicitly specified 2 valid bits, 1 modified bit and 1 replacement bit, for 16+2+1+1=20 bits. The directory is 8192×20=163, 840 bits=160 Kibits, option A (printed as Kbits). Count entries per cache line, not per set; the problem explicitly assigns the replacement bit per entry.

Check: Four ways do not mean only one tag per set: each way stores a distinct block and needs its own tag and metadata. Equivalently, 2048 sets×4 entries/set×20 bits/entry=163840 bits, confirming the per-line calculation.

Original paper, page 15 · Answer key

2 marks · MCQ
Report issue

Write-back direct-mapped cache metadata

Cache Memory

Question 43, GATE 2011: An 8 KB direct-mapped write-back cache has 32-byte blocks and 32-bit byte addresses. Metadata per cache block contains one valid bit, one modified bit, and the minimum tag bits needed to identify the mapped memory block. How many metadata bits are needed in total?

(A) 4864
(B) 6144
(C) 6656
(D) 5376
Tap to enlarge
Your answer
Answer & solution

Official answer: D

Step through it (8 steps)

There are 8192/32=256 cache lines, requiring 8 index bits. A 32-byte block requires 5 byte-offset bits, leaving 32−8−5=19 address-tag bits. Add one valid bit and one modified (dirty) bit per line: 21 bits per line. The metadata memory is therefore 256×21=5376 bits, option D. Data storage itself is not included.

Interpret 8 KB as 8×1024 bytes in the conventional cache model. The address splits into [19 tag bits][8 line-index bits][5 block-offset bits]. The index chooses one of the 256 lines, and the offset selects a byte within its 32-byte block. Only the tag must be stored as an address identifier; index and offset are implicit in placement. Write-back additionally needs the dirty bit to decide whether eviction must write data to memory, while valid distinguishes populated from unused entries.

Original paper, page 11 · Answer key

2 marks · MCQ
Report issue

L2-to-L1 block-transfer time

Cache Memory

Question 48, GATE 2010: An L1 cache connects to L2, which connects to main memory. Both connecting data buses are four words wide. L1 blocks contain four words; L2 blocks contain sixteen words. Access times are 2 ns for L1, 20 ns for L2 and 200 ns for main memory. On an L1 miss and L2 hit, one block is transferred from L2 to L1. What is the transfer time?
Options: (A) 2 ns; (B) 20 ns; (C) 22 ns; (D) 88 ns.
Question 48, GATE 2010: An L1 cache connects to L2, which connects to main memory. Both connecting data buses are four words wide. L1 blocks contain four words; L2 blocks contain sixteen words. Access times are 2 ns for L1, 20 ns for L2 and 200 ns for main memory. On an L1 miss and L2 hit, one block is transferred from L2 to L1. What is the transfer time?
Options: (A) 2 ns; (B) 20 ns; (C) 22 ns; (D) 88 ns.
Tap to enlarge
Your answer
Answer & solution

Answer: C (no official key was published)

The L1 block is 4 words and the L2–L1 bus transfers 4 words, so one bus-width transfer suffices. Under the serial source-read plus destination-write model implicit in the offered transfer-time choices, reading L2 takes 20 ns and writing L1 takes 2 ns, giving 22 ns, C. This is the block movement time, not an extra sum including a previous failed lookup. Bus width alone does not specify pipelining, write overlap or timing semantics; the result relies on this conventional serialized model.

Do not use the entire 16-word L2 block as the transfer size here: the destination L1 line needs only four words, exactly one bus width. Under the stated serialized interpretation, 20 ns pays for the source access and 2 ns for the destination write. The 88 ns distractor is four times 22 ns and incorrectly moves four L1-sized pieces.

Original paper, page 12

2 marks · MCQ
Report issue

Main-memory refill through two cache levels

Cache Memory

Question 49, GATE 2010: An L1 cache connects to L2, which connects to main memory. Both connecting data buses are four words wide. L1 blocks contain four words; L2 blocks contain sixteen words. Access times are 2 ns for L1, 20 ns for L2 and 200 ns for main memory. On misses in both caches, a block is first transferred from main memory to L2, then a block from L2 to L1. What is the total transfer time?
Options: (A) 222 ns; (B) 888 ns; (C) 902 ns; (D) 968 ns.
Question 49, GATE 2010: An L1 cache connects to L2, which connects to main memory. Both connecting data buses are four words wide. L1 blocks contain four words; L2 blocks contain sixteen words. Access times are 2 ns for L1, 20 ns for L2 and 200 ns for main memory. On misses in both caches, a block is first transferred from main memory to L2, then a block from L2 to L1. What is the total transfer time?
Options: (A) 222 ns; (B) 888 ns; (C) 902 ns; (D) 968 ns.
Tap to enlarge
Your answer
Answer & solution

Answer: C (no official key was published)

The L2 block has 16 words and the memory–L2 bus is 4 words wide, so filling it requires four transfers. Under the same non-overlapped read/write model as CS48, each costs 200 ns to read memory plus 20 ns to write L2: 4(200+20)=880 ns. The question says first fill L2, then transfer one 4-word block from L2 into L1, costing 20+2=22 ns. Total 902 ns, option C. No burst/pipelining/critical-word-first mechanism is specified; other timing models would require extra assumptions and are not used.

Keep the destination line size separate at each level: filling L2 moves sixteen words, hence four memory-bus transfers; filling L1 moves four words, hence one L2-bus transfer. The total is therefore 4×220+1×22, not four times the entire two-level path. The question explicitly orders the two fills, so their durations add in the model used.

Original paper, page 12

2 marks · MCQ
Report issue

Four-way set-associative LRU contents

Cache Memory

Question 29, GATE 2009: An initially empty four-way cache has 16 blocks and memory 256 blocks. Reference sequence:0, 255, 1, 4, 3, 8, 133, 159, 216, 129, 63, 8, 48, 32, 73, 92, 155. With LRU within each set, which block is absent at the end? A 3; B 8; C 129; D 216.
Tap to enlarge
Your answer
Answer & solution

Answer: D (no official key was published)

There are 16/4=4 sets, selected by block number modulo 4. Simulating LRU gives oldest-to-newest final sets: set 0=[8, 48, 32, 92], set 1=[1, 133, 129, 73], set 2=[], set 3=[3, 159, 63, 155]. Thus 3, 8, 129 remain but 216 has been evicted, D. In set 0, insertion 32 removes 4 and insertion 92 removes 216 after 8 was refreshed.

There are 16/4=4 sets; choose set number by block modulo 4. Only blocks mapping to the same set compete for four ways. In set 0, references are 0, 4, 8, 216, 8, 48, 32, 92. The second 8 refreshes its recency; inserting 48 removes 0, 32 removes 4, and 92 removes 216. The final set is 8, 48, 32, 92. Other sets retain 3 and 129. Hence 216, option D, is the absent listed block.

Original paper, page 6

2 marks · MCQ
Report issue

Inclusive multilevel-cache requirements

Cache Memory

Question 35, GATE 2008: Which are necessary for L1/L2 cache inclusion? I: L1 must be write-through. II: L2 must be write-through. III: L2 associativity must exceed L1 associativity. IV: L2 must be at least as large as L1.

(A) IV only
(B) I and IV only
(C) I,II,IV only
(D) I,II,III,IV
Tap to enlarge
Your answer
Answer & solution

Answer: A under full-capacity inclusion convention (no official key was published)

1. For every resident L1 block also to be represented in L2 while L1 can use its full capacity, L2 must be at least as large: IV. Write-back can be compatible with inclusion via appropriate dirty-state and invalidation handling, so I and II are not required.
2. Equal associativity can satisfy inclusion; it need not be strictly greater, so III is false. Hence A under the standard capacity convention.
3. A policy that deliberately underutilizes a larger L1 through back-invalidations could preserve resident-set inclusion with a smaller L2, so IV is not a purely set-theoretic necessity without the full-capacity convention.

Original paper, page 6

2 marks · MCQ
Report issue

Total virtual cache-tag storage

Cache Memory

Question 71, GATE 2008: A machine has a 64-KiB, two-way set-associative data cache with 16-byte blocks, managed using 32-bit virtual addresses; pages are 4 KiB. A row-major double ARR[1024][1024] starts at the beginning of virtual page 0xFF000. A double occupies 8 bytes. The cache is initially empty, there is no prefetching, and only ARR causes data-memory references. The code is:
for(i=0;i<1024;i++)
 for(j=0;j<1024;j++) ARR[i][j]=0.0;
What is the total tag storage in the cache directory?

(A) 32 Kibits
(B) 34 Kibits
(C) 64 Kibits
(D) 68 Kibits
Question 71, GATE 2008: A machine has a 64-KiB, two-way set-associative data cache with 16-byte blocks, managed using 32-bit virtual addresses; pages are 4 KiB. A row-major double ARR[1024][1024] starts at the beginning of virtual page 0xFF000. A double occupies 8 bytes. The cache is initially empty, there is no prefetching, and only ARR causes data-memory references. The code is:
for(i=0;i<1024;i++)
 for(j=0;j<1024;j++) ARR[i][j]=0.0;
What is the total tag storage in the cache directory?

(A) 32 Kibits
(B) 34 Kibits
(C) 64 Kibits
(D) 68 Kibits
Tap to enlarge
Your answer
Answer & solution

Answer: D (no official key was published)

1. The 64-KiB cache with 16-byte blocks contains 4096 lines. Two ways give 2048 sets, requiring 11 index bits; the byte offset needs 4 bits.
2. The 32-bit virtual address therefore leaves 32−11−4=17 tag bits per line. Total tag storage is 4096×17=69632 bits=68 Kibits, option D.
3. Valid, dirty and replacement bits are not tags and are excluded.

Original paper, page 15

2 marks · MCQ
Report issue

Array element sharing a cache index

Cache Memory

Question 72, GATE 2008: A machine has a 64-KiB, two-way set-associative data cache with 16-byte blocks, managed using 32-bit virtual addresses; pages are 4 KiB. A row-major double ARR[1024][1024] starts at the beginning of virtual page 0xFF000. A double occupies 8 bytes. The cache is initially empty, there is no prefetching, and only ARR causes data-memory references. The code is:
for(i=0;i<1024;i++)
 for(j=0;j<1024;j++) ARR[i][j]=0.0;
Which element has the same cache index as ARR[0][0]?

(A) ARR[0][4]
(B) ARR[4][0]
(C) ARR[0][5]
(D) ARR[5][0]
Question 72, GATE 2008: A machine has a 64-KiB, two-way set-associative data cache with 16-byte blocks, managed using 32-bit virtual addresses; pages are 4 KiB. A row-major double ARR[1024][1024] starts at the beginning of virtual page 0xFF000. A double occupies 8 bytes. The cache is initially empty, there is no prefetching, and only ARR causes data-memory references. The code is:
for(i=0;i<1024;i++)
 for(j=0;j<1024;j++) ARR[i][j]=0.0;
Which element has the same cache index as ARR[0][0]?

(A) ARR[0][4]
(B) ARR[4][0]
(C) ARR[0][5]
(D) ARR[5][0]
Tap to enlarge
Your answer
Answer & solution

Answer: B (no official key was published)

1. The index repeats every 2048 sets×16 bytes=32768 bytes. A row contains 1024 doubles×8 bytes=8192 bytes.
2. ARR[4][0] is 4×8192=32768 bytes after ARR[0][0], so it has the same set index, option B. ARR[0][4] and ARR[0][5] are only 32 and 40 bytes later; ARR[5][0] is 40960 bytes later, changing the index.

Original paper, page 15

2 marks · MCQ
Report issue

Cache hits for row-major initialization

Cache Memory

Question 73, GATE 2008: A machine has a 64-KiB, two-way set-associative data cache with 16-byte blocks, managed using 32-bit virtual addresses; pages are 4 KiB. A row-major double ARR[1024][1024] starts at the beginning of virtual page 0xFF000. A double occupies 8 bytes. The cache is initially empty, there is no prefetching, and only ARR causes data-memory references. The code is:
for(i=0;i<1024;i++)
 for(j=0;j<1024;j++) ARR[i][j]=0.0;
What is the cache hit ratio for the initialization loop? The printed statement does not specify write allocation.

(A) 0%
(B) 25%
(C) 50%
(D) 75%
Question 73, GATE 2008: A machine has a 64-KiB, two-way set-associative data cache with 16-byte blocks, managed using 32-bit virtual addresses; pages are 4 KiB. A row-major double ARR[1024][1024] starts at the beginning of virtual page 0xFF000. A double occupies 8 bytes. The cache is initially empty, there is no prefetching, and only ARR causes data-memory references. The code is:
for(i=0;i<1024;i++)
 for(j=0;j<1024;j++) ARR[i][j]=0.0;
What is the cache hit ratio for the initialization loop? The printed statement does not specify write allocation.

(A) 0%
(B) 25%
(C) 50%
(D) 75%
Tap to enlarge
Your answer
Answer & solution

Answer: C (assuming write allocation) (no official key was published)

1. Sequential row-major stores touch two adjacent 8-byte doubles in each 16-byte cache line. With the intended write-allocate policy and an initially empty cache, the first store misses and allocates the line, and the second store hits.
2. The hit ratio is therefore 1/2=50%, option C. The array is page-aligned and thus line-aligned.
3. No line is reused after the traversal moves beyond it, so capacity misses do not change this pairing. A no-write-allocate cache would leave every store a miss and yield 0% (A).

Original paper, page 15

1 mark · MCQ
Report issue

Cache tag set and word bits

Cache Memory

Question 10, GATE 2007: A 4-way set-associative cache has 128 lines of 64 words each. Main-memory word addresses are 20 bits. What are the TAG, LINE and WORD field lengths, respectively?
Options:
(A) 9,6,5
(B) 7,7,6
(C) 7,5,8
(D) 9,5,6
Tap to enlarge
Your answer
Answer & solution

Answer: D (no official key was published)

Step through it (7 steps)

1. Approach. First divide total lines by associativity to obtain sets. The address chooses a word inside a line, then a set; the remaining high bits form the tag.

2. Derivation and interpretation. There are 128/4=32 sets, needing 5 set-index bits. A 64-word line needs 6 word-offset bits. With 20-bit word addresses the tag uses 20−5−6=9 bits. Thus 9,5,6, option D; the stated LINE field is the set index in this associative organization.

Original paper, page 3

2 marks · MCQ
Report issue

Cache misses across two array scans

Cache Memory

Question 80, GATE 2007: Main memory is byte-addressable with 2^16 bytes. A direct-mapped data cache has 32 lines, 64 bytes each, and starts empty. A 50×50 array of bytes is contiguous starting at hexadecimal address 1100H. The complete array is accessed twice, with no intervening changes to cache contents. The source does not specify traversal order; use increasing-address scans for the intended result. How many total data-cache misses occur?
Options:
(A) 48
(B) 50
(C) 56
(D) 59
Question 80, GATE 2007: Main memory is byte-addressable with 2^16 bytes. A direct-mapped data cache has 32 lines, 64 bytes each, and starts empty. A 50×50 array of bytes is contiguous starting at hexadecimal address 1100H. The complete array is accessed twice, with no intervening changes to cache contents. The source does not specify traversal order; use increasing-address scans for the intended result. How many total data-cache misses occur?
Options:
(A) 48
(B) 50
(C) 56
(D) 59
Tap to enlarge
Your answer
Answer & solution

Answer: C (no official key was published)

1. Approach. Convert the starting address to a block number and count all touched blocks, including the partial final block. For the second scan, identify conflicts modulo the 32 cache lines instead of treating all 40 blocks as compulsory misses again.

2. Derivation and interpretation. Assuming each complete pass reads the array in increasing memory-address order, the 2500-byte array begins at 0x1100=4352, a 64-byte boundary. It spans ceil(2500/64)=40 blocks, numbered 68 through 107. The cold first pass misses 40 times. In the 32-line direct-mapped cache, blocks 68–75 and 100–107 compete for lines 4–11. In the second pass, loading 68–75 evicts 100–107, so both groups miss again, while the other 24 blocks hit. Total 40+8+8=56, option C. Merely saying the complete array is accessed does not specify traversal order; different orders can produce different miss counts.

Original paper, page 20

2 marks · MCQ
Report issue

Cache lines replaced on second scan

Cache Memory

Question 81, GATE 2007: Main memory is byte-addressable with 2^16 bytes. A direct-mapped data cache has 32 lines, 64 bytes each, and starts empty. A 50×50 array of bytes is contiguous starting at hexadecimal address 1100H. The complete array is accessed twice, with no intervening changes to cache contents. The source does not specify traversal order; use increasing-address scans for the intended result. Which cache lines are replaced by new blocks during the second access? Lines are numbered from zero.
Options:
(A) 4 through 11
(B) 4 through 12
(C) 0 through 7
(D) 0 through 8
Question 81, GATE 2007: Main memory is byte-addressable with 2^16 bytes. A direct-mapped data cache has 32 lines, 64 bytes each, and starts empty. A 50×50 array of bytes is contiguous starting at hexadecimal address 1100H. The complete array is accessed twice, with no intervening changes to cache contents. The source does not specify traversal order; use increasing-address scans for the intended result. Which cache lines are replaced by new blocks during the second access? Lines are numbered from zero.
Options:
(A) 4 through 11
(B) 4 through 12
(C) 0 through 7
(D) 0 through 8
Question 81, GATE 2007: Main memory is byte-addressable with 2^16 bytes. A direct-mapped data cache has 32 lines, 64 bytes each, and starts empty. A 50×50 array of bytes is contiguous starting at hexadecimal address 1100H. The complete array is accessed twice, with no intervening changes to cache contents. The source does not specify traversal order; use increasing-address scans for the intended result. Which cache lines are replaced by new blocks during the second access? Lines are numbered from zero.
Options:
(A) 4 through 11
(B) 4 through 12
(C) 0 through 7
(D) 0 through 8
Tap to enlarge
Your answer
Answer & solution

Answer: A (no official key was published)

1. Approach. Map each memory block to block_number mod 32. Forty sequential blocks exceed the cache by eight, so identify which eight line indices are used twice rather than assuming that replacements start at line zero.

2. Derivation and interpretation. With increasing-address scans as in Q80, the array occupies blocks 68–107. Modulo 32, the first eight blocks 68–75 and final eight 100–107 both map to cache lines 4–11. Only those lines are replaced in the second scan, first by 68–75 and later by 100–107. Answer A. Lines are numbered from zero; the result is conditional on the scan-order assumption omitted from the common statement.

Original paper, page 20

2 marks · MCQ
Report issue

Two-way cache hit latency

Cache Memory

Question 74, GATE 2006: Compare two 32 KB caches with 32-byte blocks and 32-bit addresses: one is two-way set associative, the other direct mapped. A 2:1 multiplexer takes 0.6 ns; a k-bit comparator takes k/10 ns. The hit-latency model counts comparator and way-selection delays. Find two-way cache hit latency h₁.
Options:
(A) 2.4 ns
(B) 2.3 ns
(C) 1.8 ns
(D) 1.7 ns
Question 74, GATE 2006: Compare two 32 KB caches with 32-byte blocks and 32-bit addresses: one is two-way set associative, the other direct mapped. A 2:1 multiplexer takes 0.6 ns; a k-bit comparator takes k/10 ns. The hit-latency model counts comparator and way-selection delays. Find two-way cache hit latency h₁.
Options:
(A) 2.4 ns
(B) 2.3 ns
(C) 1.8 ns
(D) 1.7 ns
Tap to enlarge
Your answer
Answer & solution

Answer: A (no official key was published)

Step 1: 32 KB / 32 B=1024 cache lines. Two ways give 512 sets, so index=9 bits and block offset=5 bits.

Step 2: The tag is 32−9−5=18 bits. Two tag comparisons proceed in parallel, taking 18/10=1.8 ns; selecting the matching way adds 0.6 ns.

Step 3: Thus h1=2.4 ns, A, within the stated model that counts comparator and multiplexer latency.

Step 4: Teaching check: Two-way associativity halves the number of sets relative to direct mapping, increasing the tag by one bit. Both way tags are compared in parallel, so do not double comparator latency. The selected data then passes through one 2:1 multiplexer.

Original paper, page 11

2 marks · MCQ
Report issue

Direct-mapped cache hit latency

Cache Memory

Question 75, GATE 2006: Compare two 32 KB caches with 32-byte blocks and 32-bit addresses: one is two-way set associative, the other direct mapped. A 2:1 multiplexer takes 0.6 ns; a k-bit comparator takes k/10 ns. The hit-latency model counts comparator and way-selection delays. Find direct-mapped hit latency h₂.
Options:
(A) 2.4 ns
(B) 2.3 ns
(C) 1.8 ns
(D) 1.7 ns
Question 75, GATE 2006: Compare two 32 KB caches with 32-byte blocks and 32-bit addresses: one is two-way set associative, the other direct mapped. A 2:1 multiplexer takes 0.6 ns; a k-bit comparator takes k/10 ns. The hit-latency model counts comparator and way-selection delays. Find direct-mapped hit latency h₂.
Options:
(A) 2.4 ns
(B) 2.3 ns
(C) 1.8 ns
(D) 1.7 ns
Tap to enlarge
Your answer
Answer & solution

Answer: D (no official key was published)

1. A direct-mapped 32 KB cache with 32-byte blocks has 1024 lines, requiring 10 index bits and 5 offset bits. The tag has 32−10−5=17 bits.

2. Its comparison takes 17/10=1.7 ns and no way-selection multiplexer is needed. Thus h2=1.7 ns, D, using the problem’s comparator/multiplexer-only timing model.

3. Teaching check: Direct mapping determines the only candidate line from the index bits, so no way selection is needed. There are 1024 lines rather than 512 sets, giving a 17-bit rather than 18-bit tag. The difference in hit time comes from both the tag size and the absent multiplexer.

Original paper, page 11

2 marks · MCQ
Report issue

Row-major traversal cache misses

Cache Memory

Question 80, GATE 2006: A CPU has a 32 KB direct-mapped cache with 128-byte blocks. C array A[512][512] uses 8-byte elements. The two programs execute separately from the same initially cold cache; i,j,x are in registers.
P1: for(i=0;i<512;i++) for(j=0;j<512;j++) x+=A[i][j];
P2: for(i=0;i<512;i++) for(j=0;j<512;j++) x+=A[j][i];
Let M1,M2 be their cache-miss counts. Use the conventional block-aligned base address assumed by the listed answers. Find M1.
Options:
(A) 0
(B) 2048
(C) 16384
(D) 262144
Question 80, GATE 2006: A CPU has a 32 KB direct-mapped cache with 128-byte blocks. C array A[512][512] uses 8-byte elements. The two programs execute separately from the same initially cold cache; i,j,x are in registers.
P1: for(i=0;i<512;i++) for(j=0;j<512;j++) x+=A[i][j];
P2: for(i=0;i<512;i++) for(j=0;j<512;j++) x+=A[j][i];
Let M1,M2 be their cache-miss counts. Use the conventional block-aligned base address assumed by the listed answers. Find M1.
Options:
(A) 0
(B) 2048
(C) 16384
(D) 262144
Tap to enlarge
Your answer
Answer & solution

Answer: C (no official key was published)

1. In C, A is row-major. Each 128-byte cache block holds 128/8=16 elements.

2. P1 visits all 512×512 elements sequentially, so one compulsory miss serves each group of 16 elements. For a block-aligned A, M1=512×512/16=16384, C; each later element in the same block hits.

3. Teaching check: C’s rightmost subscript varies over contiguous elements. Each cache block supplies sixteen consecutive doubles, causing one miss followed by fifteen hits in a sequential scan. The whole array is much larger than the cache, but immediate within-block reuse still occurs.

Original paper, page 12

2 marks · MCQ
Report issue

Row versus column traversal miss ratio

Cache Memory

Question 81, GATE 2006: A CPU has a 32 KB direct-mapped cache with 128-byte blocks. C array A[512][512] uses 8-byte elements. The two programs execute separately from the same initially cold cache; i,j,x are in registers.
P1: for(i=0;i<512;i++) for(j=0;j<512;j++) x+=A[i][j];
P2: for(i=0;i<512;i++) for(j=0;j<512;j++) x+=A[j][i];
Let M1,M2 be their cache-miss counts. Use the conventional block-aligned base address assumed by the listed answers. Find M1/M2.
Options:
(A) 0
(B) 1/16
(C) 1/8
(D) 16
Question 81, GATE 2006: A CPU has a 32 KB direct-mapped cache with 128-byte blocks. C array A[512][512] uses 8-byte elements. The two programs execute separately from the same initially cold cache; i,j,x are in registers.
P1: for(i=0;i<512;i++) for(j=0;j<512;j++) x+=A[i][j];
P2: for(i=0;i<512;i++) for(j=0;j<512;j++) x+=A[j][i];
Let M1,M2 be their cache-miss counts. Use the conventional block-aligned base address assumed by the listed answers. Find M1/M2.
Options:
(A) 0
(B) 1/16
(C) 1/8
(D) 16
Question 81, GATE 2006: A CPU has a 32 KB direct-mapped cache with 128-byte blocks. C array A[512][512] uses 8-byte elements. The two programs execute separately from the same initially cold cache; i,j,x are in registers.
P1: for(i=0;i<512;i++) for(j=0;j<512;j++) x+=A[i][j];
P2: for(i=0;i<512;i++) for(j=0;j<512;j++) x+=A[j][i];
Let M1,M2 be their cache-miss counts. Use the conventional block-aligned base address assumed by the listed answers. Find M1/M2.
Options:
(A) 0
(B) 1/16
(C) 1/8
(D) 16
Tap to enlarge
Your answer
Answer & solution

Answer: B (no official key was published)

1. P1 has 16384 misses under the block-aligned assumption. P2 accesses A[j][i] with stride 512×8=4096 bytes=32 cache lines.

2. The cache has 32768/128=256 lines, so successive row accesses cycle through only 256/gcd(256,32)=8 cache indices. With 512 rows, every would-be reused block is evicted before the next column accesses it.

3. All 512²=262144 P2 accesses miss. M1/M2=16384/262144=1/16, B.

4. The last options are on physical page 13.

5. Teaching check: A 4096-byte stride advances by 32 cache indices modulo 256. Only eight indices participate in a column, repeatedly overwriting each other. Thus the next column cannot reuse the previous column’s blocks, even though adjacent elements within a row occupy the same block.

Original paper, page 12

2 marks · MCQ
Report issue

Direct-mapped cache index and tag

Cache Memory

Question 67, GATE 2005: Direct-mapped cache data capacity 32 KB, block 32 bytes, CPU 32-bit byte addresses. Required(index bits, tag bits): A(10, 17); B(10, 22); C(15, 17); D(5, 17). Use binary capacity units.
Tap to enlarge
Your answer
Answer & solution

Answer: A (no official key was published)

Step through it (6 steps)

The cache contains 32 KiB/32 bytes =1024 lines, so its index needs 10 bits. A block offset needs log2(32)=5 bits. Of the 32 address bits, 32−10−5=17 remain for the tag. Thus (10, 17), option A.

First divide data capacity by block size to obtain 1024 distinct cache positions. Choosing one needs 10 bits. Choosing a byte within 32-byte block needs 5 low-order bits. The tag identifies which memory block is currently occupying that position, using the remaining 32−10−5=17 bits. Check 10+17+5=32. The cache’s total number of bytes is not the number of line indices.

Original paper, page 9

2 marks · MCQ
Report issue

Two-way LRU cache conflicts

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

Descriptive
Report issue

Find array elements that conflict in a direct-mapped cache

Cache Memory

Question 10(a), GATE 2002: A C program declares float A[2048], with four bytes per element and A starting at address 0x00000000. It runs on a computer with an 8-Kbyte direct-mapped data cache and 16-byte cache blocks (lines). Which array elements conflict with A[0] in the cache? Briefly justify.
Question 10(a), GATE 2002: A C program declares float A[2048], with four bytes per element and A starting at address 0x00000000. It runs on a computer with an 8-Kbyte direct-mapped data cache and 16-byte cache blocks (lines). Which array elements conflict with A[0] in the cache? Briefly justify.
Question 10(a), GATE 2002: A C program declares float A[2048], with four bytes per element and A starting at address 0x00000000. It runs on a computer with an 8-Kbyte direct-mapped data cache and 16-byte cache blocks (lines). Which array elements conflict with A[0] in the cache? Briefly justify.
Tap to enlarge
Shared context

float A[2048] begins at address 0; each element occupies 4 bytes. The direct-mapped data cache has 8 Kbytes = 8192 bytes and 16-byte lines. Part (b) scans from A[2047] to A[0], starting with an empty cache and no other accesses.

Answer & solution

Answer: None; A[1], A[2], A[3] share A[0]’s block but do not conflict (no official key was published)

1. Convert sizes using the standard binary Kbyte convention. The cache holds 8×1024=8192 bytes. Dividing by the 16-byte block size gives 512 direct-mapped cache lines. Each block holds 16/4=4 array elements.

2. Derive the mapping from an array index. Since A begins at address 0, A[i] starts at address 4i. Its memory-block number is floor(4i/16)=floor(i/4). The corresponding cache-line index is floor(i/4) mod 512; the tag distinguishes blocks with that same index.

3. Find all array elements with A[0]’s index. Its block is block 0 and its cache index is 0. An index of 0 requires block number 0,512,1024,… . Within the declared array, 0≤i≤2047, so floor(i/4) ranges only from 0 to 511. Only block 0 occurs, containing A[0], A[1], A[2], A[3].

4. Distinguish sharing from conflict. A[1], A[2], A[3] are in the same memory block as A[0], so they are fetched together and coexist. They do not compete for the line or evict A[0]. A conflict requires a different memory block, hence a different tag, mapping to that line.

5. The next genuinely conflicting block would start at byte address 8192, corresponding to A[2048], which is outside the declared array. Therefore no element within A[0…2047] conflicts with A[0]. Saying merely “A[1…3] have the same cache index” is true but does not answer the eviction/conflict question correctly.

Original paper, page 8

Descriptive
Report issue

Count reverse-scan cache misses

Cache Memory

Question 10(b), GATE 2002: A C program declares float A[2048], with four bytes per element and A starting at address 0x00000000. It runs on a computer with an 8-Kbyte direct-mapped data cache and 16-byte cache blocks (lines). Starting with an empty cache, access each array element once in reverse order, from the last element through the first. Ignore all other data and instruction accesses. How many data-cache misses occur? Briefly justify.
Question 10(b), GATE 2002: A C program declares float A[2048], with four bytes per element and A starting at address 0x00000000. It runs on a computer with an 8-Kbyte direct-mapped data cache and 16-byte cache blocks (lines). Starting with an empty cache, access each array element once in reverse order, from the last element through the first. Ignore all other data and instruction accesses. How many data-cache misses occur? Briefly justify.
Question 10(b), GATE 2002: A C program declares float A[2048], with four bytes per element and A starting at address 0x00000000. It runs on a computer with an 8-Kbyte direct-mapped data cache and 16-byte cache blocks (lines). Starting with an empty cache, access each array element once in reverse order, from the last element through the first. Ignore all other data and instruction accesses. How many data-cache misses occur? Briefly justify.
Tap to enlarge
Shared context

float A[2048] begins at address 0; each element occupies 4 bytes. The direct-mapped data cache has 8 Kbytes = 8192 bytes and 16-byte lines. Part (b) scans from A[2047] to A[0], starting with an empty cache and no other accesses.

Answer & solution

Answer: 512 cache misses (no official key was published)

1. Count the blocks touched. The array holds 2048 four-byte elements, so its total size is 8192 bytes. With 16-byte lines, there are 8192/16 = 512 distinct array blocks, each containing four consecutive elements.

2. Trace the first reversed block. The first access, A[2047], misses because the cache is empty and loads the entire block A[2044…2047]. The next accesses A[2046], A[2045], A[2044] therefore hit. Crossing to A[2043] causes the next miss and loads the next group of four.

3. Generalize the pattern. In every group of four reversed accesses, the first is a miss and the other three are hits. No accesses outside the array intervene. The 512 array blocks have distinct cache indices, although even a smaller cache would still preserve this immediate three-hit pattern for a single uninterrupted sequential scan.

4. Multiply the counts: misses = 512×1 = 512, hits = 512×3 = 1536, total accesses = 512+1536 = 2048. All these misses are compulsory first references, not conflict misses.

5. Reverse traversal changes which element first brings in each block, but not the number of blocks touched. A direct-mapped simulation from A[2047] down to A[0] confirms the count of 512 misses.

Original paper, page 8

1 mark · MCQ
Report issue

Why cache blocks contain multiple words

Cache Memory

Question 1.7, GATE 2001: Why does a cache block contain multiple words? Choices: temporal locality, spatial locality, reduced miss penalty, or none of these.
Tap to enlarge
Your answer
Answer & solution

Answer: B (no official key was published)

Step 1: A reference often predicts references to nearby addresses, for example successive array elements or adjacent instructions. Loading neighboring words with the requested word prepares for those accesses: spatial locality.

Step 2: Temporal locality concerns repeated use of the same location and already motivates retaining even a single cached word. A larger block can increase rather than reduce the transfer time of a miss.

Therefore spatial locality is the specific reason for grouping words, B.

Original paper, page 2

Descriptive
Report issue

Number of cache sets

Cache Memory

Question 9(a), GATE 2001: 32-bit byte addresses; cache data capacity 256 KB=2^18 bytes; 4-way set associative; 16-byte blocks.

Task: Find the number of cache sets.
Question 9(a), GATE 2001: 32-bit byte addresses; cache data capacity 256 KB=2^18 bytes; 4-way set associative; 16-byte blocks.

Task: Find the number of cache sets.
Tap to enlarge
Shared context

32-bit byte addresses; cache data capacity 256 KB=2^18 bytes; 4-way set associative; 16-byte blocks.

Answer & solution

Answer: 4096 sets. (no official key was published)

Step through it (7 steps)

1. First count cache blocks: 218 bytes ÷24 bytes/block =214 blocks, or 16,384 blocks.

2. Four-way associativity means four blocks in each set, not four sets. Divide by four to obtain 214/2²=212=4096 sets.

3. Equivalently, one set holds 4×16=64 data bytes, and 262,144/64=4096. This cross-check uses the complete data capacity.

4. Consequently the set index requires 12 bits, a fact used when partitioning the address in later parts.

Original paper, page 8

Descriptive
Report issue

Cache tag width

Cache Memory

Question 9(b), GATE 2001: 32-bit byte addresses; cache data capacity 256 KB=2^18 bytes; 4-way set associative; 16-byte blocks.

Task: Find the tag-field width per block.
Question 9(b), GATE 2001: 32-bit byte addresses; cache data capacity 256 KB=2^18 bytes; 4-way set associative; 16-byte blocks.

Task: Find the tag-field width per block.
Tap to enlarge
Shared context

32-bit byte addresses; cache data capacity 256 KB=2^18 bytes; 4-way set associative; 16-byte blocks.

Answer & solution

Answer: 16 tag bits per block. (no official key was published)

Step through it (7 steps)

1. An address separates into tag, set index, and byte offset. The 16-byte block needs log₂16=4 offset bits.

2. There are (256×1024)/(4×16)=4096 sets, so the set index needs log₂4096=12 bits.

3. The remaining bits are tag bits: 32−12−4=16. In bit positions, tag=A31…A16, set=A15…A4, byte offset=A3…A0.

4. Associativity affects the number of sets and hence the tag width. There is no address field selecting a way; the stored tags determine which of the four candidate ways matches.

Original paper, page 8

Descriptive
Report issue

Parallel tag comparators

Cache Memory

Question 9(c), GATE 2001: 32-bit byte addresses; cache data capacity 256 KB=2^18 bytes; 4-way set associative; 16-byte blocks.

Task: Find the number and size of comparators for tag matching.
Question 9(c), GATE 2001: 32-bit byte addresses; cache data capacity 256 KB=2^18 bytes; 4-way set associative; 16-byte blocks.

Task: Find the number and size of comparators for tag matching.
Tap to enlarge
Shared context

32-bit byte addresses; cache data capacity 256 KB=2^18 bytes; 4-way set associative; 16-byte blocks.

Answer & solution

Answer: Four 16-bit equality comparators for a parallel four-way lookup. (no official key was published)

1. The 12 index bits select one set containing four candidate cache blocks. The requested block may occupy any of those four ways.

2. The incoming 16-bit tag must be compared with each of the four stored 16-bit tags. A standard parallel lookup therefore uses four comparators, each comparing two 16-bit quantities.

3. Each comparator produces one match bit, normally qualified by the corresponding valid bit. The hit way selects its data.

4. Comparators for every cache block are unnecessary because the index has already selected one set. A serial implementation could reuse hardware with additional latency, but the conventional associative lookup requested here is parallel.

Original paper, page 8

Descriptive
Report issue

Cache byte offset width

Cache Memory

Question 9(d), GATE 2001: 32-bit byte addresses; cache data capacity 256 KB=2^18 bytes; 4-way set associative; 16-byte blocks.

Task: Find the byte-offset address width.
Question 9(d), GATE 2001: 32-bit byte addresses; cache data capacity 256 KB=2^18 bytes; 4-way set associative; 16-byte blocks.

Task: Find the byte-offset address width.
Tap to enlarge
Shared context

32-bit byte addresses; cache data capacity 256 KB=2^18 bytes; 4-way set associative; 16-byte blocks.

Answer & solution

Answer: 4 bits. (no official key was published)

Step through it (7 steps)

1. A block stores 16 individually addressable bytes. The byte offset must distinguish positions 0 through 15 within that block.

2. An unsigned b-bit field distinguishes 2b positions, so 2b=16 gives b=4.

3. These are the lowest four address bits A3…A0. For example offsets 0000 and 1111 identify the first and last byte.

4. The four-way organization does not change this field: associativity changes where a whole block is placed, not how bytes inside it are selected.

Original paper, page 8

Descriptive
Report issue

Cache tag storage overhead

Cache Memory

Question 9(e), GATE 2001: 32-bit byte addresses; cache data capacity 256 KB=2^18 bytes; 4-way set associative; 16-byte blocks.

Task: Find total extra memory in bytes required for tag bits.
Question 9(e), GATE 2001: 32-bit byte addresses; cache data capacity 256 KB=2^18 bytes; 4-way set associative; 16-byte blocks.

Task: Find total extra memory in bytes required for tag bits.
Tap to enlarge
Shared context

32-bit byte addresses; cache data capacity 256 KB=2^18 bytes; 4-way set associative; 16-byte blocks.

Answer & solution

Answer: 32,768 bytes = 32 KiB for tags only. (no official key was published)

Step through it (8 steps)

1. Total cache blocks equal 256×1024/16=16,384. Every resident block requires its own tag even though blocks share a set index.

2. Each tag has 32−12−4=16 bits. Thus tag storage is 16,384×16=262,144 bits.

3. Convert bits to bytes by dividing by 8: 262,144/8=32,768 bytes, or 32 KiB.

4. This is only the requested tag-bit memory. Valid bits, dirty bits, and replacement metadata would add storage, but their costs are not part of the tag-only question and are not silently included.

Original paper, page 8

1 mark · MCQ
Report issue

Two-way set-associative mapping

Cache Memory

Question 1.22, GATE 1999: Main memory has 2cm blocks and cache has 2c blocks, with two blocks per set. Which set receives block k: k mod m,c,2c,or 2cm?
Tap to enlarge
Your answer
Answer & solution

Answer: B (no official key was published)

The number of cache sets is capacity divided by associativity: (2c)/2=c. Consecutive main-memory blocks are distributed cyclically over these c sets, so the set index is k mod c. The remaining quotient supplies tag information, while either way within that indexed set may hold the block. Thus B. The paper display products 2cm and 2c, not exponents; reading the latter as 2c would change the set-count formula incorrectly.

Original paper, page 3

5 marks · Descriptive
Report issue

Cache loop hit ratio

Cache Memory

Question 18, GATE 1998: A cache has l sets, block size b, k blocks per set, cache/main-memory times tc,tm. A loop of size nb executes 100 times, with n=km and 1<m≤l. Find hit ratio and discuss l=1.
Tap to enlarge
Answer & solution

Answer: Under cold, aligned contiguous block-level accesses: 99%; l=1 contradicts 1<m≤l. (no official key was published)

The loop contains n blocks and total cache capacity is kl blocks. Assume contiguous aligned loop blocks, ordinary block-number modulo-l indexing, no competing data/code, an initially empty cache and one counted access per loop block per pass. Since n≤kl, each set receives at most ceil(n/l)≤k loop blocks. Thus no loop block must evict another after the first pass.

The first traversal incurs n compulsory misses. The remaining 99 traversals hit on all n blocks. Out of 100n block references, 99n hit, so H=0.99. Neither tc nor tm affects this count; they would enter effective access-time calculations instead.

If b denotes b separately referenced words/instructions per block, the denominator changes: there are 100nb references, still n misses, giving H=1−1/(100b). If b is bytes while instructions have unspecified lengths, that word-reference formula cannot be asserted numerically. The definition of an access must be explicit.

The separate request l=1 is incompatible with the earlier constraint 1<m≤l. If it means keep m>1 while replacing the cache by one fully associative k-block set, then n=km>k. Under LRU and repeated cyclic scanning, every block-level access misses: by the time a block is revisited, at least k distinct blocks have intervened. H=0 at block granularity, or 1−1/b for b consecutive word references per block. This is conditional on LRU; an unspecified replacement policy can produce a different ratio. If the intended comparison instead keeps the entire loop fitting, its warmed-up behavior remains 99%. The source does not resolve these alternatives.

Original paper, page 7

1 mark · MCQ
Report issue

Locality and the memory hierarchy

Cache Memory

Question 1.6, GATE 1995: Which mechanism is directly justified by locality: interrupts, DMA, polling, or cache memory?
Question 1.6, GATE 1995: Which mechanism is directly justified by locality: interrupts, DMA, polling, or cache memory?
Tap to enlarge
Your answer
Answer & solution

Answer: D (no official key was published)

Temporal locality means a recently accessed item is likely to be accessed again. Spatial locality means nearby addresses are likely to be accessed soon. A cache retains recent blocks in fast storage, exploiting both kinds of locality to avoid slower memory accesses. Interrupts and polling concern detecting events; DMA concerns moving data without the CPU handling every transfer. None depends on locality in the same direct way, so cache memory is the relevant mechanism.

Original paper, page 1

2 marks · MCQ
Report issue

Set and offset bits in a cache

Cache Memory

Question 2.25, GATE 1995: A 4K-word cache is four-way set associative with 64 words per block. Find SET and WORD field widths.
Tap to enlarge
Your answer
Answer & solution

Answer: D: 4 set bits,6 word bits (no official key was published)

Step through it (5 steps)

The cache contains 4096/64=64 blocks. Grouping four blocks per set gives 64/4=16 sets, requiring log₂16=4 set-index bits. A block contains 64 words, requiring log₂64=6 word-offset bits. Associativity changes the number of sets, not the within-block offset. No tag width can be computed without the total main-memory address width, but it is not requested. These counts use word addresses, as specified, rather than adding an unstated byte offset.

Original paper, page 5

Descriptive
Report issue

Average write-through access time

Cache Memory

Question 5(a), GATE 1992: Main memory takes 500 ns and cache 50 ns. Requests are 80% reads and 20% writes; read hit ratio is 0.9. Writes update cache and main memory simultaneously. Find average access time.
Tap to enlarge
Answer & solution

Answer: 180 ns for sequential cache lookup then main-memory read on a miss; 176 ns if miss latency already includes lookup or reads begin in parallel. (no official key was published)

Separate access types before averaging. A read hit costs 50 ns. Under the usual serial lookup model, a read miss first spends 50 ns discovering the miss and then 500 ns accessing main memory, for 550 ns. Therefore E[read]=0.9(50)+0.1(550)=100 ns.

The statement explicitly says write-through updates are simultaneous, so the write completes when the slower device completes: E[write]=max(50,500)=500 ns. Adding 50+500 for a write would contradict this parallel-update stipulation. No write buffer or early processor release is stated.

Weighting by request mix gives E[access]=0.8(100)+0.2(500)=180 ns. Equivalently, the overall probabilities are 0.72 read hit, 0.08 read miss and 0.20 write, giving 0.72(50)+0.08(550)+0.20(500).

There is a timing-model ambiguity: if main-memory access starts in parallel with cache lookup, or a quoted 500 ns miss time is interpreted as total latency including lookup, then a miss costs 500 rather than 550 ns. That model gives E[read]=95 ns and overall 176 ns. The text establishes simultaneous writes but does not explicitly establish read overlap; 180 ns is the serial-read result, while 176 ns requires the alternative convention. This is effective time per processor memory request, not a change to the physical 500 ns main-memory device latency.

Original paper, page 5