Cache Memory · Computer Organization and Architecture
68 questions · asked in 25 of 27 years (2000–2026)
MCQ 44 · MSQ 4 · NAT 201-mark 30 · 2-mark 38
2000Questions per year2026
Questions 46–50 of 68
Consider a machine with a 2-way set associative data cache of size 64Kbytes and block size 16bytes. The cache is managed using 32 bit virtual addresses and the page size is 4Kbyts. A program to be run on this machine begins as follows:
The cache hit ratio for this initialization loop is
double ARR[1024][1024];
int i, j;
// Initialize array ARR to 0.0
for(i = 0; i < 1024; i++)
for(j = 0; j < 1024; j++)
ARR[i][j] = 0.0; The size of double is 8Bytes. Array ARR is located in memory starting at the beginning of virtual page 0xFF000 and stored in row major order. The cache is initially empty and no pre-fetching is done. The only data memory references made by the program are those to array ARR The cache hit ratio for this initialization loop is
Answer: (C)
The block size and each element takes
So one block holds elements.
The array has elements. The number of blocks needed .
In each block, the first element is a miss and the second is a hit, because two elements come in together.
Correct Answer:
So one block holds elements.
The array has elements. The number of blocks needed .
In each block, the first element is a miss and the second is a hit, because two elements come in together.
Correct Answer:
Consider a machine with a 2-way set associative data cache of size 64Kbytes and block size 16bytes. The cache is managed using 32 bit virtual addresses and the page size is 4Kbyts. A program to be run on this machine begins as follows:
Which of the following array elements has the same cache index as ARR[0][0]?
double ARR[1024][1024];
int i, j;
// Initialize array ARR to 0.0
for(i = 0; i < 1024; i++)
for(j = 0; j < 1024; j++)
ARR[i][j] = 0.0; The size of double is 8Bytes. Array ARR is located in memory starting at the beginning of virtual page 0xFF000 and stored in row major order. The cache is initially empty and no pre-fetching is done. The only data memory references made by the program are those to array ARR Which of the following array elements has the same cache index as ARR[0][0]?
Answer: (B)
The cache has 64 KB, 16 B blocks and 2 blocks per set, so the number of sets is .
A 32-bit address splits into 4 offset bits (16 B block), 11 index bits and 17 tag bits. The index is address bits 4 to 14.
So two addresses have the same index when their addresses differ by a multiple of bytes (a whole number of cache-size/2-way spans).
ARR starts at virtual address 0xFF000000 (page 0xFF000, offset 000). Element is at bytes (row major, 8 bytes per double). The base is a multiple of 32768, so only the distance from ARR[0][0] matters.
(A) ARR[0][4]: distance , index , not 0.
(B) ARR[4][0]: distance , index 0, same as ARR[0][0].
(C) ARR[0][5]: distance , index , not 0.
(D) ARR[5][0]: distance , and , index , not 0.
Answer: (B)
A 32-bit address splits into 4 offset bits (16 B block), 11 index bits and 17 tag bits. The index is address bits 4 to 14.
So two addresses have the same index when their addresses differ by a multiple of bytes (a whole number of cache-size/2-way spans).
ARR starts at virtual address 0xFF000000 (page 0xFF000, offset 000). Element is at bytes (row major, 8 bytes per double). The base is a multiple of 32768, so only the distance from ARR[0][0] matters.
(A) ARR[0][4]: distance , index , not 0.
(B) ARR[4][0]: distance , index 0, same as ARR[0][0].
(C) ARR[0][5]: distance , index , not 0.
(D) ARR[5][0]: distance , and , index , not 0.
Answer: (B)
Consider a machine with a 2-way set associative data cache of size 64Kbytes and block size 16bytes. The cache is managed using 32 bit virtual addresses and the page size is 4Kbyts. A program to be run on this machine begins as follows:
The total size of the tags in the cache directory is
double ARR[1024][1024];
int i, j;
// Initialize array ARR to 0.0
for(i = 0; i < 1024; i++)
for(j = 0; j < 1024; j++)
ARR[i][j] = 0.0; The size of double is 8Bytes. Array ARR is located in memory starting at the beginning of virtual page 0xFF000 and stored in row major order. The cache is initially empty and no pre-fetching is done. The only data memory references made by the program are those to array ARR The total size of the tags in the cache directory is
Answer: (D)
Number of sets , so the index needs 11 bits.
A block has 16 bytes, so the offset needs 4 bits.
Tag bits .
Number of cache blocks .
Total tag size .
Answer: (D)
A block has 16 bytes, so the offset needs 4 bits.
Tag bits .
Number of cache blocks .
Total tag size .
Answer: (D)
For inclusion to hold between two cache levels L1 and L2 in a multi-level cache hierarchy, which of the following are necessary?
I. L1 must be a write-through cache
II. L2 must be a write-through cache
III. The associativity of L2 must be greater than that of L1
IV. The L2 cache must be at least as large as the L1 cache
I. L1 must be a write-through cache
II. L2 must be a write-through cache
III. The associativity of L2 must be greater than that of L1
IV. The L2 cache must be at least as large as the L1 cache
Answer: (A)
Inclusion means every block present in L1 must also be present in L2.
I is not needed. Inclusion is about which blocks are present, not how L1 handles writes. A write-back L1 can also keep inclusion.
II is not needed. It decides when L2 writes reach memory, which has no effect on which blocks L2 holds.
III is not needed. L2 does not need higher associativity. Inclusion can be kept by removing the L1 copy whenever L2 evicts that block.
IV is needed. L2 must be able to hold every block that L1 holds, so L2 must be at least as large as L1.
Answer: (A)
I is not needed. Inclusion is about which blocks are present, not how L1 handles writes. A write-back L1 can also keep inclusion.
II is not needed. It decides when L2 writes reach memory, which has no effect on which blocks L2 holds.
III is not needed. L2 does not need higher associativity. Inclusion can be kept by removing the L1 copy whenever L2 evicts that block.
IV is needed. L2 must be able to hold every block that L1 holds, so L2 must be at least as large as L1.
Answer: (A)
Consider a Direct Mapped Cache with 8 cache blocks (numbered 0-7). If the memory block requests are in the following order
3, 5, 2, 8, 0, 63, 9,16, 20, 17, 25, 18, 30, 24, 2, 63, 5, 82,17, 24.
Which of the following memory blocks will not be in the cache at the end of the sequence ?
3, 5, 2, 8, 0, 63, 9,16, 20, 17, 25, 18, 30, 24, 2, 63, 5, 82,17, 24.
Which of the following memory blocks will not be in the cache at the end of the sequence ?
Answer: (B)
The cache is direct mapped, so each block goes to line . No replacement policy is needed. The last request that maps to a line stays in it.
Requests to each line, in order:
Line 0: 8, 0, 16, 24, 24. It ends with 24.
Line 1: 9, 17, 25, 17. It ends with 17.
Line 2: 2, 18, 2, 82. It ends with 82.
Line 3: 3. It ends with 3.
Line 4: 20. It ends with 20.
Line 5: 5, 5. It ends with 5.
Line 6: 30. It ends with 30.
Line 7: 63, 63. It ends with 63.
Blocks 3, 20 and 30 are in the cache. Block 18 was replaced by 82 in line 2 (both give 2 when taken mod 8), so 18 is not in the cache.
Answer: (B)
Requests to each line, in order:
Line 0: 8, 0, 16, 24, 24. It ends with 24.
Line 1: 9, 17, 25, 17. It ends with 17.
Line 2: 2, 18, 2, 82. It ends with 82.
Line 3: 3. It ends with 3.
Line 4: 20. It ends with 20.
Line 5: 5, 5. It ends with 5.
Line 6: 30. It ends with 30.
Line 7: 63, 63. It ends with 63.
Blocks 3, 20 and 30 are in the cache. Block 18 was replaced by 82 in line 2 (both give 2 when taken mod 8), so 18 is not in the cache.
Answer: (B)
Keep practising