SelfNote:
Example of Compulsory and Conflict Miss in a set associative Cache :
contention of multiple block on same cache set is considered as conflict miss ..lets take this scenario suppose memory blocks are 5 , 13 , 29 and 5 .
There are 4 sets set 0, set 1 , set 2 and set 3 . Total number of sets are 4 and blocks per set is 2 .
Set selection = ( memory block reference or block address) % (number of sets)
5 is mapped to set 1 , 5%4 = 1 > it is compulsory miss ,
the cache memory scenario is at this moment 5 | __Blank__
13 is mapped to set 1 , 13%4 = 1 > compulsory miss again ,
the cache memory scenario is at this moment 5 | 13
29 is mapped to set 1 and 5 get replaced , 29%4 = 1 > it is compulsory miss , the cache memory scenario is at this moment 13 | 29
now again 5 comes and 5 is mapped to set 1 by replacing 13 , it is considered as Conflict Miss , as 5 come once previously so when next time 5 is mapped it is conflict miss .
Contention means conflict , here when 5 is mapped in same set it does not find previous block 5 , as that get replaced , so here in this example " multiple block " which is mapped again is 29 and 5 , that same cache set is set 1 .
the scenario is at this moment 29 | 5 .
So in my example, number of compulsory miss is 3 and number of conflict miss is 1 .
Source:
https://gateoverflow.in/69118/difference-between-compulsory-miss-conflict-miss-capacity