These type of questions look very confusing to students. But if you read this answer, everything will be cleared.
In Hierarchical memory access,
CPU ←→ L1 cache ←→ L2 cache ←→ Main memory
Let,
H1 → L1 cache hit rate
H2 → L2 cache hit rate
T1 → L1 cache access time (1 clock cycle)
T2 → L2 cache access time (8 clock cycles)
Tmm → memory access time (18 clock cycles) => miss penalty from the L2 cache to main memory
AMAT = H1*T1 + (1-H1)*H2*(T1+T2) + (1-H1)*(1-H2)*(T1+T2+Tmm) --------- 1
or
AMAT = H1*T1 + (1-H1)*L1 miss penalty
L1 miss penalty= H2*(T1+T2) + (1-H2)*L2 miss penalty
L2 miss penalty= T1 + T2 +Tmm
If you solve these three equations you will get the result same as equation 1.
or
AMAT = T1 + (1-H1)*T2 + (1-H1)*(1-H2)*Tmm (This equation is formed by solving equation 1 further, let’s consider this as equation 2)
or
AMAT = T1 + (1-H1)*L1 miss penalty
L1 miss penalty= T2 + (1-H2)*L2 miss rate
L2 miss penalty= Tmm
If you solve these three equations you will get the result same as equation 2.
It is given that miss rate of L1 cache is twice that of L2
=> L1 miss rate (Let x) = 2 * L2 miss rate
=> L2 miss rate = x/2;
It is also given that the miss penalty from the L2 cache to main memory is 18 clock cycles
=> Tmm = 18
By solving from above equation 2,
AMAT = T1 + (1-H1) * T2 + (1-H1) * (1-H2) * Tmm
AMAT = T1 + L1 miss rate * T2 + L1 miss rate * L2 miss rate * Tmm
=> $2 = 1 + x * 8 + x * x/2 * 18$ (AMAT = 2)
=> $2 = 1 + 8x + 9x^2$
=> $9x^2 + 8x - 1 = 0$
=> x = 0.111
=> L1 miss rate = 0.111
=> L2 miss rate = 0.111 / 2 = 0.05
If you solve by equation 1 you will get the same result but that will be lengthy, so always try to solve by using equation 2 in these type of questions.
Let me solve this also
AMAT = H1 * T1 + (1-H1) * H2 * (T1+T2) + (1-H1) * (1-H2) * (T1+T2+Tmm)
= (1 – L1 miss rate) * T1 + L1 miss rate * (1 – L2 miss rate) * (T1 + T2) + L1 miss rate * L2 miss rate * (T2 + T2 + Tmm) -----------so lengthy
= $(1 - x) * 1 + x * (1 - x/2) * (1 + 8) + x * x/2 * (1 + 8 + 18)$
= $1 - x + 9x -9x^2/2 + 27x^2/2$
= $1 + 8x + 18x^2/2$
=> $2 = 1 + 8x + 9x^2$
=> $9x^2 + 8x - 1 = 0$
Which will gave the same answer.
Please upvote if you like the answer.