Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Hit and miss ration in cache and average time calculation

I'm trying to solve a objective type question , came In examination. I actually don't know the right answer, and don't know how to get it , need your help. Thank you .

Question : In a certain system the main memory access time is 100 ns. The cache is 10 time faster than the main memory and uses the write though protocol. If the hit ratio for read request is 0.92 and 85% of the memory requests generated by the CPU are for read, the remaining being for write; then the average time consideration both read and write requests is

a) 14.62ns

b) 348.47ns

c) 29.62ns

d) 296.2ns

My work ::::

Well, memory access time = 100ns

cache access time would be = 10 ns (10 time faster)

In order to find avg time we have a formula

Tavg = hc+(1-h)M

   where h = hit rate
     (1-h) = miss rate
       c   = time to access information from cache
        M  = miss penalty  (time to access main memory)

Write through operation : cache location and main memory location is updated simultaneously.

It is given that 85% request generated by CPU is read request and 15% is write request.

Tavg = 0.85(avg time for read request)+ 0.15(avg time for write request)
     = 0.85(0.92*10+0.08*100)+0.15(avg time for write request)

//* 0.92 is a hit ratio for read request , but hit ratio for write request is not given ??

If I assume that hit hit ratio for write request is same as hit ratio for read request then,

  = 0.85(0.92*10+0.08*100)+0.15(0.92*(10+100)+0.08*100)
  =31 ns

If I assume that hit ratio is 0% for write request then,

  = 0.85(0.92*10+0.08*100)+0.15(0*110+1*100)
  =29.62 ns
like image 759
siddstuff Avatar asked May 06 '13 12:05

siddstuff


People also ask

How is cache hit and miss ratio calculated?

A cache hit ratio is calculated by dividing the number of cache hits by the total number of cache hits and misses, and it measures how effective a cache is at fulfilling requests for content.

How do you find average access time of cache memory?

With a 2-level cache, we can expand our formula: average memory access time = hit time0 + miss rate0 * (hit time1 + miss rate1 * miss penalty1 )

How do you calculate MS ratio?

NIM = Net Interest Income / Avg Interest Earning Assets And Average Interest-earning assets are loans / advances given to borrowers by banks / NBFCs. Average of the beginning to end of the period is considered for prudent calculation.

How do you calculate average access time in case of multi level hierarchy?

Average Memory access time(AMAT)= Hit Time + Miss Rate * Miss Penalty.


1 Answers

Your second assumption is correct.

With the write-through cache, it writes immediately the modified blocks to memory and then onto disk. Since no disk access time is given, it is eliminated from the equation. My notations are little different, but I will post it that way for future readers. I used the notation given in William Stallings Operating Systems: Internals and Design Principles.

Given:

Tm = 100ns
Tc = 10ns /* 10x faster than Tm */ 
Hr = 0.92 /* Hit rate reading */
85% reading => 15% of the time writing

Solution:

The effective access time for reading:
Te_r = Hr * Tc + (1-Hr)Tm = 0.92*10 + (1 - 0.92)100 = 9.2 + 8 = 17.2

The effective access time for writing, is determined from the Hit rate Hw,
which is always 0, because the data must be immediately written onto the 
memory.
Te_w = Hw * Tc + (1-Hw)Tm = 0*10 + (1 - 0)100 = 100

Taking into account the percentage:
0.85*17.2 + 0.15*100 = 14.62 + 15 = 29.62

                                                                    Q.E.D
like image 175
Dimitar Avatar answered Sep 22 '22 16:09

Dimitar