farheen
farheen

Reputation: 111

average time to access a word in memory

  Here is the question:

Consider a computer system that has cache memory, main memory (RAM) and disk, and the operating system uses virtual memory. It takes 2 nsec to access a word from the cache, 10 nsec to access a word from the RAM, and 10 ms to access a word from the disk. If the cache hit rate is 95% and main memory hit rate (after a cache miss) is 99%, what is the average time to access a word?

Here is how I solved it.
consider 100 references
95 cache hits(due to 0.95 cache hit ratio)
95*2nsec = 190 nsec

this would leave 5 references which were passed to memory
`5*0.99=4.95=5` successfully found in memory

this would count for

5*10nsec=50nsec 

average access time=total time/total accesses
=(50+190)/100 nsec
=240/100 nsec
=2.4 nsec

Is this correct?

Here is another solution

memory access time 
=cache hit ratio * cache access time + (1 - hit ratio) * miss penalty(or memory access time)
=0.95*2+(1-0.95)10
2.4 nsec

which one is the perfect solution to this problem?

In question memory hit ratio is also given but is not used in the formula I used in second solution.Was it unnecessarily given in the question? If there is a problem where cache hit rate is 85% and memory hit rate is 5% and disk hit rate is 10%, then what would be the miss penalty in that case?

Upvotes: 1

Views: 5471

Answers (1)

Maged
Maged

Reputation: 11

95% will hit the cache, and 4.95% will hit the RAM and .05% will hit the disk therefor ( (95 × 2) +(4.95 × 10) +(.05 × 10 × 1000000) )/100 = 5002.45 nsec

Upvotes: 1

Related Questions