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?