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?
This is not the answer, but you may consider it as hints to find it
yourself.

Why do you write 4.95=5 without any explanation. Is that your idea of
perfect solution? Apparently your first solution never accesses the
disk. Your second solution is essentially the same as the first,
presented more abstractedly (hence a bit better in my opinion, but the reasonning may not be explicited enough for what seems to be your level of proficiency), but it
ignores the disk access as much as the first soution.

That may not always be true, but you should always worry at least a
little bit where you are ignoring part of the data of your problem.
You should convince yourself that the data you ignore is


either redundant with the data you use. This means that it is
actually a consequence of the data you are using, and can thus be
taken into acount implicitly through the data you are using;
or irrelevant to the problem. In this case you should preferably
have some argument as to why it is irrelevant. This argument may not
be required in your answer (though it may not hurt to give it), but
you probably at least sketch it for yourself to convince yourself
that you are right in ignoring the corresponding data.
Irrelevance can also include the fact that the corresponding data is negligible in the context of your problem. But that usually demands some argument to convince the reader that it is indeed the case.


Does the data you ignore correspond to such a case?