在内存中访问单词的平均时间

时间:2015-03-22 17:01:30

标签: caching memory operating-system

  Here is the question:

考虑具有缓存,主内存(RAM)和磁盘的计算机系统,操作系统使用虚拟内存。从高速缓存访​​问字需要2纳秒,从RAM访问字需要10纳秒,从磁盘访问字需要10毫秒。如果缓存命中率为95%且主内存命中率(缓存未命中后)为99%,则访问单词的平均时间是多少?

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

这是对的吗?

这是另一种解决方案

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

哪一个是这个问题的完美解决方案?

问题内存命中率也给出,但在第二个解决方案中使用的公式中没有使用。问题中是否有不必要的问题? 如果存在高速缓存命中率为85%且内存命中率为5%且磁盘命中率为10%的问题,则该情况下的未命中罚款是什么?

1 个答案:

答案 0 :(得分:1)

95%将命中缓存,4.95%将命中RAM,0.05%将命中磁盘((95×2)+(4.95×10)+(。05×10×1000000))/ 100 = 5002.45纳秒