The Gateway to Computer Science Excellence

+27 votes

In the three-level memory hierarchy shown in the following table, $p_i$ denotes the probability that an access request will refer to $M_i$.

$$\begin{array}{|c|c|c|c|} \hline \textbf {Hierarchy Level } & \textbf{Access Time}& \textbf{Probability of Access} & \textbf{Page Transfer Time} \\

(M_i) &(t_i)&(p_i) &(T_i)\\ \hline

M _1 & 10^{-6} & 0.99000 & \text{0.001 sec} \\ M _2 & 10^{-5} & 0.00998 & \text{0.1 sec} \\ M _3 & 10^{-4} & 0.00002 & \text{---} \\\hline \end{array}$$

If a miss occurs at level $M_i$, a page transfer occurs from $M_{i+1}$ to $M_i$ and the average time required for such a page swap is $T_i$. Calculate the average time $t_A$ required for a processor to read one word from this memory system.

$$\begin{array}{|c|c|c|c|} \hline \textbf {Hierarchy Level } & \textbf{Access Time}& \textbf{Probability of Access} & \textbf{Page Transfer Time} \\

(M_i) &(t_i)&(p_i) &(T_i)\\ \hline

M _1 & 10^{-6} & 0.99000 & \text{0.001 sec} \\ M _2 & 10^{-5} & 0.00998 & \text{0.1 sec} \\ M _3 & 10^{-4} & 0.00002 & \text{---} \\\hline \end{array}$$

If a miss occurs at level $M_i$, a page transfer occurs from $M_{i+1}$ to $M_i$ and the average time required for such a page swap is $T_i$. Calculate the average time $t_A$ required for a processor to read one word from this memory system.

+24 votes

Best answer

We are given the probability of access being a hit in each level (clear since their sum adds to $1$).

So, we can get the average access time as:

$t_A = 0.99 \times {10}^{-6} \\+ 0.00998 \times ({10}^{-6} +{10}^{-5} + 0.001)$

$+ 0.00002 \times ({10}^{-6} + {10}^{-5} + {10}^{-4} + 0.1 + 0.001)]$

$\approx (0.99 + 10 + 2 ) \times [10^{-6}] \\= 13 \mu s$.

We can also use the following formula- for $100$% of accesses $M_1$ is accessed,

whenever $M_1$ is a miss, $M_2$ is accessed and when both misses only $M_3$ is accessed.

So, average memory access time,

$t_A = 10^{-6} + (1-0.99) \times (10^{-5} + 0.001) + 0.00002 \times (10^{-4} + 0.1)

\\= 1 + 10.01 + 2 \mu s

\\= 13.01 \mu s.$

+2

Difference between Hit ratio and Probability as per my understanding;;

Hit Ratio....

Suppose H1=.8 H2=.9 H3=1

Suppose 100 Request came then 80 are handled by L1 . 18 are handled by L2. 1 is Handled by L3.

Note:-Hit ratio means... (No. Of hit / No. Of reference made)

Now Probability...

P1=.8 P2=.11 P3=.09 (sums Upto 1)

Then if 100 request came then 80 are handle by L1 ,11 by L2, 9 by L3

Plz Correct Me!!!

@Arjun sir

Hit Ratio....

Suppose H1=.8 H2=.9 H3=1

Suppose 100 Request came then 80 are handled by L1 . 18 are handled by L2. 1 is Handled by L3.

Note:-Hit ratio means... (No. Of hit / No. Of reference made)

Now Probability...

P1=.8 P2=.11 P3=.09 (sums Upto 1)

Then if 100 request came then 80 are handle by L1 ,11 by L2, 9 by L3

Plz Correct Me!!!

@Arjun sir

0

@Rajesh even in 1st case we have to think about miss in previous level and hit in that level.

Which is not considered here. rt?

Which is not considered here. rt?

0

@srestha ,assuming u r talking abt arjun sir's ans case-1

It is considered there..

And this is the best link to understand the whole picture:-

Read AMAT part only

https://www.cs.uaf.edu/2011/spring/cs641/lecture/04_05_modeling.html

It is considered there..

And this is the best link to understand the whole picture:-

Read AMAT part only

https://www.cs.uaf.edu/2011/spring/cs641/lecture/04_05_modeling.html

+2

@Rajesh yes, but for the second it must be clear that the probability is with respect to total no. of memory references as mentioned in the given question.

0

how ?

and one more doubt that why we are not taking probability like

p_{1} (m_{1}) + (1-p_{1}) (p_{2}) m_{2+....}

0

after determining hit rates from probabilities, we get relative hit rates then why are we not using that formula?? please clear arjun sir.

why not this formula?

+1

Sir why have u not used hierarchical access here?? My concepts are shattering :(

+1

@sushmita It is same only and you are correct. There was calculation mistake in the given answer-- corrected now.

0

@sushmita,

In the formula, you have given above. **T1+(1-H1)(T2+(1-H2)T3)).**

while calculating T3, you have not added the extra time required 0.001 sec to moving the page from 2nd level to 1st level.

Read this, mentioned in the question.

If a miss occurs at level Mi, a page transfer occurs from Mi+1 to Mi and the average time required for such a page swap is Ti.

+1

It is not required @hemant

It will be simulteneous access

Page access time required for 1 level

not for all prev levels

It will be simulteneous access

Page access time required for 1 level

not for all prev levels

0

I think they have given "Probability of access" instead of "probability of hit" in the table ...Because by probability of access they mean that this is the fraction of time only during which access to this memory will happen ... But access to 1 st level memory will always happen and access to 2 nd level memory will always happen when 1 miss in first level .. and so on ...

0

@srestha i feel that in the table, heading of 3 rd column should have been "probability of hit" instead of "Probability of access" right ?

+45 votes

Quick Cache Maths:-

Suppose that in 250 memory references there are 30 misses in L1 and 10 misses in L2.

Miss rate of L1 = $\frac{30}{250}$

Miss rate of L2 = $\frac{10}{30}$ (In L1 we miss 30 requests, so at L2 we have 30 requests, but it misses 10 out of $30$)

See this question.

Here, Probabilities are given, We need to convert it into Hit ratios.

$p_1 = 0.99000$, it says we hit 0.99 times in $M_1$ but we miss 0.01 times. Here hit rate is same as probability $H_1 = 0.99$

$p_2 = 0.00998$, it says we hit 0.00998 times out of 0.01 requests (0.01 misses from $M_1$), $H_2 = \frac{0.00998}{0.01} = 0.998$

($H_3$ is of course 1. we hit 0.00002 times in $M_3$ out of 0.00002 misses from $M_2$)

$H_1 = 0.99$, $H_2 = 0.998$, $H_3 = 1$. $t_i$ is Access time, and $T_i$ is page transfer time.

$t_A = t_1+(1-H_1)\times \text{Miss penalty 1}$

$\text{Miss penalty 1} = (t_2+T_1)+(1-H_2)\times \text{Miss penalty 2}$

$\text{Miss penalty 2} = (t_3+T_2)$

Ref: question 3 here

https://www.cs.utexas.edu/~fussell/courses/cs352.fall98/Homework/old/Solution3.ps

+6

Fortunately, I still have this downloaded pdf on my PC :)

uploaded it here -http://docdro.id/fIYPp6K

uploaded it here -http://docdro.id/fIYPp6K

+1

This answer should be included in GO book. Thanks a ton!! This a clear explanation on relative probabilities.

0

It is mentioned that pi is probability that an access will REFER to Mi. But the first memory level i.e. M1 is always referred in the sense that firstly , any information is checked first in M1 then in successive memory levels. So why not p1 is 1? Which means probability that a request will refer to M1 is 1.

EDIT: pi should be fraction of requests satisfied by Mi.

EDIT: pi should be fraction of requests satisfied by Mi.

+3 votes

All the times can be converted to microsecond or nanoseconds. Modified table is,

M_{i} |
t_{i} |
p_{i} |
T_{i} |
---|---|---|---|

M_{1} |
1 microseconds | 0.99 | 1000 microseconds |

M_{2} |
10 microseconds | 0.00998 | 10^{5 }microseconds |

M_{3} |
100 microseconds | 0.00002 | --- |

us ==> microseconds

t_{A} = 0.99 (1 us) + 0.00998 (10 us + 1 us + 1000 us) + 0.00002 (1 us+ 10 us + 100 us + 1000 us + 10^{5 }us)

= 0.99 us + 10.09978 us + 2.02222 us

= **13.1 us**

Another way :

t_{A }= 1 us + 0.00998 (1010 us) + 0.00002 (111 us + 101000 us)

= 1 us + 10.0798 us + 2.02 us

= **13.1 us**

+1 vote

Here the probability of accessing each level is given, we can calculate the average access time as

We access the 1st level memory with probability 0.99 and its access time is 10^-6 seconds = 1 microsecond, so **0.99*1 **microsecond for accessing from level-1.

But when we access 2nd level memory its access time is 10^-5 seconds = 10 microseconds, apart from this the block has to be moved to 1st level and the time taken for it is 0.001 seconds = 1000 microseconds and then the overall access time in level-1, so **0.00998*(1+10+1000) **microsecond for level-2.

Similarly when accessing from level-3, access time in level-3 is 10^-4 seconds = 100 microseconds, and the time to move the content to level-2 is 0.1 second = 10^5 microseconds. So the overall time from level-3 = 0.00002(1 + 10 + 100 + 1000 + 10^5)

So the average access time is

tA = 0.99 (1 us) + 0.00998 (10 us + 1 us + 1000 us) + 0.00002 (1 us+ 10 us + 100 us + 1000 us + 10^5 us)

= 0.99 us + 10.09978 us + 2.02222 us

= 13.1 us

0 votes

$0.99000 \times {10}^{-6} + (1-0.99000) \times [(0.00998)\times ({10}^{-6} +{10}^{-5} + 0.001) + (1-0.00998){(0.00002)\times ({10}^{-6} + {10}^{-5} + {10}^{-4} + 0.1)}] \\= 1.1\times {10}^{-6} s.$

+1

are you missing something on the third part of the expression, because you eventually have to transfer the page from m3->m2->m1, where as , you have missed out the transfer time from m2->m1.

0 votes

The standard way is (hierarchical memory access) :

AMAT = Hit Ratio for L1 x L1 access time **+**

Miss Ratio for L1 x Hit Ratio for L2 x (page transfer time from L2 to L1 + L1 access time + L2 access time) **+**

Miss Ratio for L1 x Miss Ratio L2 x Hit Ratio for L3 x (page transfer time from L3 to L2 + page transfer time from L2 to L1 + L1 access time + L2 access time + L3 access time)

= 0.99 x 1 us + .01 x .998 x (1000 + 1 + 10)us + .01 x .002 x 1 x (100000 + 1000 + 1 + 10 + 100)

= 13.102 us

** Note:** you have to convert probabilities into Hit Ratios respectively as specified by sachin mittal.

- All categories
- General Aptitude 1.8k
- Engineering Mathematics 7.4k
- Digital Logic 2.9k
- Programming and DS 4.9k
- Algorithms 4.4k
- Theory of Computation 6.2k
- Compiler Design 2.1k
- Databases 4.1k
- CO and Architecture 3.4k
- Computer Networks 4.1k
- Non GATE 1.4k
- Others 1.7k
- Admissions 595
- Exam Queries 576
- Tier 1 Placement Questions 23
- Job Queries 72
- Projects 17

50,666 questions

56,158 answers

193,767 comments

93,758 users