Consider an array A & each element occupies 4 word. A 32 word cache is used and divided into 16 word blocks. What is the miss ratio for the following statement. Assume one block is read into cache in case of miss:
for(i=0; i < 1000; i++) A[i] = A[i] + 99
Explanation: Since there is 16 word block, 4 element can stay in one block. Now notice that each element is referred twice, one read and one write operation.
So when in a block when 1st element is referred for read, it will be miss, and hence that block will be copied to cache.
Now 2nd, 3rd, and 4th references to that 1st element will be hit for read and write. So out of 8 reference, 1 miss and 7 hit for one block. Gets repeated for each and every block.
Therefore, hit 7/8 and miss 1/8.
Option (A) is correct.
Quiz of this Question
Attention reader! Don’t stop learning now. Learn all GATE CS concepts with Free Live Classes on our youtube channel.