5,622 views
3 votes
3 votes

A byte addressable computer has a small data cache capable of holding eight 32 bit words. Each cache block consists of two 32 bit words. For the following sequence of address (in hex decimal) find the hit ratio if two way set associative LRU cache is used.

200,204,208,20C,2F4,2F0,2F0,2F4,2F0,21C,218,24C.

This pattern is repeated four times. Assume that the cache is initially empty. if full associative mapping is used,then  computer the number of hits.

1 Answer

Best answer
3 votes
3 votes

cache size = 32 bytes,

Block size = 8 bytes

Number of sets = total size / (block size * 2) = 32 bytes / (8 bytes * 2) = 2 sets

it is a 2-way set associative cache. there are 2 sets, each consisting of TWO blocks. Each block consisting of TWO 32-bit (total 8 bytes) words.

Tag bits set bits offset bits
8 1 3

it is 2 way set associative so number of blocks per set = 2

address set Hit/miss
200 0  compulsory miss
204 0   compulsory miss
208 1  compulsory miss
20C 1  compulsory miss
2F4 0  compulsory miss
2F0 0  compulsory miss
2F0 0  Hit
2F4 0  Hit
2F0 0  Hit
21C 1   compulsory miss
218 1   compulsory miss
24C 1  compulsory miss

so number of hit = 3

3 hits out of 12 references = 3/12 = 0.25

hit ratio = 0.25 

Now this pattern is repeated four times , next time also hit = 3 so total hits 3+3+3+3 = 12 after four iterations.

---------------

if full associative mapping is used 

then also number of hit = 3 in each iteration. so here also total hit = 12 .

edited by
Answer:

Related questions

0 votes
0 votes
1 answer
1
0 votes
0 votes
1 answer
3
rahuldb asked Nov 17, 2016
572 views
Find out the number of page fault in the following strings of pages used by CPU using the page replaced algorithm LRU and LIFO[taking 3 page frames]1,1,3,5,3,4,2,2,2,1,8