Cache Memory

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.


![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]](../../../assets/questions/CS-2008-Q72-1.webp)
![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]](../../../assets/questions/CS-2008-Q72-2.webp)
![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.](../../../assets/questions/CS-2002-Q67-1.webp)
![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.](../../../assets/questions/CS-2002-Q67-2.webp)
![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.](../../../assets/questions/CS-2002-Q67-3.webp)
