edited by
383 views
3 votes
3 votes

Assume that we have a two dimensional array 60 $\times$ 60. Each elements is of 4 bytes and array is stored in row major order. RAM is 2 MN and cache is 8 KB with each block of 16 bytes.

L1:
for (i=0; i<60; i++)
    {
        for (j=0; j<60; j++)
        {
            printf(“%d”, a[i][j]);
        }
    }
L2:
for (t=59; t>=0; t- -)
    {
        for (j=59; j>=0; j- -)
        {
            printf(“%d”, a[i][j]);
        }
    }

In case of direct mapped cache, the number of cache misses are_____ (Assume that cache is empty initially)

edited by

1 Answer

0 votes
0 votes
for L1:- 1/4*60*60=900 miss

because at every 4 elements in cache block 1 (MISS)

as when the program wants to print value searches value in the cache memory as it does not find(MISS) so it takes consecutive 16 byte means 4 elements and put inside block so for other three (HIT) now again same others.

for L2: -program prints from last so we can not put 16 bytes at a time so MISS for all elements 60*60=3600 (MISS)

Related questions

1 votes
1 votes
1 answer
1
learner_geek asked Jul 26, 2017
811 views
Find hit and miss ratio for both the questions?
0 votes
0 votes
1 answer
4
iita asked Jan 28, 2017
335 views