Skip to content

GATE CS 2007 Q80 — Memory Hierarchy: Cache, Main Memory and Secondary Storage

Explain with AI

Consider a machine with a byte addressable main memory of 2162^{16} bytes. Assume that a direct mapped data cache consisting of 3232 lines of 6464 bytes each is used in the system. A 50×5050 \times 50 two-dimensional array of bytes is stored in the main memory starting from memory location 1100H1100H. Assume that the data cache is initially empty. The complete array is accessed twice. Assume that the contents of the data cache do not change in between the two accesses. 

How many data misses will occur in total?

Choose one option
View worked solution

Answer: C

To find the total number of cache misses, we first determine how the array is mapped to the cache blocks.

1. Memory Blocks Spanned by the Array:

  • Array start address: 1100extH=43521100 ext{H} = 4352
  • Array size: 50×50=250050 \times 50 = 2500 bytes
  • Array end address: 4352+2500−1=68514352 + 2500 - 1 = 6851
  • Cache block size: 6464 bytes
  • Starting memory block: ⌊4352/64⌋=68\lfloor 4352 / 64 \rfloor = 68
  • Ending memory block: ⌊6851/64⌋=107\lfloor 6851 / 64 \rfloor = 107
  • Total blocks spanned: 107−68+1=40107 - 68 + 1 = 40 blocks (from block 68 to 107)

2. First Access Pass:

Since the cache is initially empty, accessing these 4040 blocks sequentially results in 4040 compulsory misses.

The cache has 3232 lines (indexed 00 to 3131). The blocks map to cache lines using Line=Block(mod32)\text{Line} = \text{Block} \pmod{32}:

  • Blocks 6868 to 7575 map to lines 44 to 1111.
  • Blocks 7676 to 9595 map to lines 1212 to 3131.
  • Blocks 9696 to 9999 map to lines 00 to 33.
  • Blocks 100100 to 107107 map to lines 44 to 1111 (overwriting blocks 6868 to 7575).

3. Second Access Pass:

  • Blocks 6868 to 7575: Map to lines 44 to 1111 (which currently hold blocks 100100 to 107107) →\rightarrow 88 misses.
  • Blocks 7676 to 9595: Map to lines 1212 to 3131 (which still hold blocks 7676 to 9595) →\rightarrow 00 misses.
  • Blocks 9696 to 9999: Map to lines 00 to 33 (which still hold blocks 9696 to 9999) →\rightarrow 00 misses.
  • Blocks 100100 to 107107: Map to lines 44 to 1111 (which now hold blocks 6868 to 7575 loaded earlier in this pass) →\rightarrow 88 misses.

Total misses in the second pass = 8+8=168 + 8 = 16.

Total Misses:

Total Misses=40 (First Pass)+16 (Second Pass)=56\text{Total Misses} = 40 \text{ (First Pass)} + 16 \text{ (Second Pass)} = 56

Free practice · Your answers on this page are not saved.

Published
Report a correction
Keep exploringMore Memory Hierarchy: Cache, Main Memory and Secondary Storage questions