Electronic – Time average for two caches , cpu and ram

cachecpuram

enter image description here

I have a CPU, with two caches, L1 and L2, with access time T1 and T2 respectively.
and The time to access RAM is Tm.
The hit ratio for L1 is a, and the hit ratio for L2 is b.

Is the mathematical type of time average this or not?:

Taverage = aT1 + (1-a)T2 + (1-a-b)Tm

(T1 , T2 << Tm)

Best Answer

Almost right. A subtlety not mentioned in the question is that an access to the next-level memory is generally not started until the access to the current level is known to be a miss.

This means that ALL accesses will take time T1, regardless of whether they hit in L1. Similarly, (1-a) accesses will take additional time T2, whether or not they hit in L2. And then (1-b) of the accesses to L2 will also incur the penalty of a main-memory access.

So the final equation becomes

$$T_{average} = T1 + (1-a)T2 + (1-a)(1-b)Tm$$