Question 1: What is the average access time for a 3-level memory system with access time $T_1$, $2T_1$ and $3T_1$? (Hit ratio $h_1$ = $h_2$ = 0.9)
The solution given is: $0.9[T_1] + 0.1(0.9[2*T_1] + 0.1[3*T_1]) = 1.11[T_1]$ (Method 1)
Here, they have considered the page won't be copied to the lower level. Otherwise, it would have been like the following
If a page is not there in cache, it would be copied from main memory to cache and then accessed. $T_1 + 2T_1$
If a page is not there even in main memory, it would be brought to main memory, then cache and then accessed. $T_1 + 2T_1 + 3T_1$
$0.9[T_1] + 0.1(0.9[T_1+2*T_1] + 0.1[T_1 + 2*T_2 + 3*T_1]) = 1.23[T_1]$ (Method 2)
I went through another similar problem.
Question 2
Cache Access Time = 20ns
Memory Access Time = 120ns
Hit Ratio = 0.8
Some other useless information below...
Cache Block size = 16 words
Set size = 2 blocks
Number of sets = 128
Size of main memory address = 21bits
What is the hit ratio if the average access time is increased by 40ns?
(A) Remains same (B) 0.921 (C) 0.467 (D) 0.592
I simply calculated it using Method 1 as follows
Effective access time = 0.8*20 + 0.2*(120) = 40ns
Increase by 40ns, so new time = 80ns
80 = h*20 + (1-h)*120
Hit ratio = 0.4
But this is not in the options
But when I calculated it using Method 2
Effective access time = 0.8*20 + 0.2*(20 + 120) = 44ns
Increase by 40ns, so new time = 84ns
84 = h*20 + (1-h)*120
Hit ratio = 0.467
That is option (C)
Here, the answer is coming using Method 2 but in the above question they are using Method 1.
How do I know which method to take while solving such problems? Whether would the missed page be brought into the lower memory (cache) or not?