title: Hit and miss ration in cache and average time calculation
body: <p>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 .</p>
  
  <p><strong>Question :</strong>
  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</p>
  
  <p>a) 14.62ns   </p>
  
  <p>b) 348.47ns</p>
  
  <p>c) 29.62ns</p>
  
  <p>d) 296.2ns</p>
  
  <p><strong>My work ::::</strong></p>
  
  <p>Well, memory access time               = 100ns</p>
  
  <p>cache access time would be  =  10 ns          (10 time faster)</p>
  
  <pre><code>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)
  </code></pre>
  
  <p>Write through operation : cache location and main memory location is updated simultaneously.</p>
  
  <p>It is given that 85% request generated by CPU is read request and 15% is write request.</p>
  
  <pre><code>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)
  </code></pre>
  
  <p>//* 0.92 is  a hit  ratio for read request  ,  but hit ratio for write request is not given ??</p>
  
  <p>If I assume that hit hit ratio for write request is same as hit ratio for read request then,</p>
  
  <pre><code>  = 0.85(0.92*10+0.08*100)+0.15(0.92*(10+100)+0.08*100)
    =31 ns
  </code></pre>
  
  <p>If I assume that hit ratio is 0% for write request then,</p>
  
  <pre><code>  = 0.85(0.92*10+0.08*100)+0.15(0*110+1*100)
    =29.62 ns
  </code></pre>