1

This is my knowledge:

  • A Compulsory Miss happens when the block is accessed for the first time.

  • A Conflict Miss happens when there are other empty blocks in cache, but a collision happens due to mapping strategies, hence a block has to be replaced (Direct Mapped and Set Associative Mapped Cache).

Say there are two blocks (0 and 1). We have a direct mapped cache and incoming requests are 0, 128.

The request for 0 is a Compulsory Miss (mapped to block 0 as 0 % 2 = 0).

The request for 128 is a Compulsory Miss (as it is accessed for the first time). But it collides with 0 (since 128 % 2 = 0). My confusion is, shouldn't it be a conflict miss as well?

ggorlen
  • 44,755
  • 7
  • 76
  • 106

1 Answers1

0

Your facts are right.

In this case, if 128 and 0 are both mapped to the same set index (let's say 0), there can only be one type of a miss.

Let's say you first wanted to get address 0 from the memory, then your cache notices that address 0 should be populated in set 0 at the cache but the valid flag is false(0) - it is a compulsory miss (or cold miss) since there is no data block in this cache set. The 0 set is now populated by the block from address 0 of the memory and the valid flag is set to true(1).

When the cache checks for address 128 it calculates the set index to be 0 also, but now the valid flag of set 0 is true(1) because it's populated with the memory block from address 0. Now, the cache compares the tag field of the set to see if it matches address 128, it doesn't. So, the data block for this set is overriden by the data block from the memory at address 128. That's a conflict miss and not a cold miss.


Maybe these links will help you out:

ggorlen
  • 44,755
  • 7
  • 76
  • 106