890 views
0 votes
0 votes

Assume that we have a two dimensional array of 60 × 60. Each element is of 4 bytes and array is stored in row major order. RAM is 2 MB and cache is 8 KB with each block of 16 bytes.

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

Ans. 1288

1 Answer

2 votes
2 votes

for L1:-

Array size=60 x 60=3600 bytes

Block size=16 bytes

Element size=4 bytes

Number of elements in one block=4 bytes

When first element A[0][0]  is referred, we bring block number 0 of main memory to line number 0.We not only bring  A[0][0]  element but also 22 - 1 elements(as we bring the whole block).So, when first element is referred, gives a miss. Next 22-1 elements gives hit.

Miss rate= 1/4

No. of misses= 1/4 x number of references.

No. of misses= 1/4  x 60 x 60 =900.

for L2:-

No. of Blocks in cache  = 512.

The elements are already present in the cache, so no miss operation will takes place for this 512 blocks.

Number of misses=900-512=388

Total Number of misses in cache=900+388=1288

Related questions

1 votes
1 votes
0 answers
3
0 votes
0 votes
0 answers
4
bts1jimin asked Jan 17, 2019
451 views
here it is given byte addressable. So these locations refer to words or byte location. What are set, block fields here : number of words or number of bytes for these loca...