in CO and Architecture edited by
23,605 views
69 votes
69 votes
The memory access time is $1$ nanosecond for a read operation with a hit in cache, $5$ nanoseconds for a read operation with a miss in cache, $2$ nanoseconds for a write operation with a hit in cache and $10$ nanoseconds for a write operation with a miss in cache. Execution of a sequence of instructions involves $100$ instruction fetch operations, $60$ memory operand read operations and $40$ memory operand write operations. The cache hit-ratio is $0.9$. The average memory access time (in nanoseconds) in executing the sequence of instructions is ______.
in CO and Architecture edited by
23.6k views

4 Comments

edited by

"5ns with a miss in cache" statement given in the question, it says if it is a miss (cache+M.M =5ns). so we can safely assume read access time of main memory is 4ns.

0
0
I'm confused with these qsn terms.

someone please clarify.

here access time is given, So isn't like in that time hit is already included??

we should take h.t or t
0
0

Instruction Fetch is included in the Read Operation from the memory . 

Total Read Operation : 100+60 = 160 

Total Write Operation: 40 

Read : Hit time = 1ns , Miss time =  5ns 

Write :Hit time = 2ns , Miss time = 10ns 

Cache Hit : 90% .

Now do the basic calculation :) Do it . 

0
0

6 Answers

67 votes
67 votes
Best answer
The question is to find the time taken for,

$\frac{\Large100 \space \text{fetch operations and $60$ operand read operations and $40$ memory
operand write operations}}{\Large\text{total number of instructions}}$.

Total number of instructions $=100+60+40 =200$

Time taken for $100$ fetch operations(fetch = read) $= 100*((0.9*1)+(0.1*5))$

$1$ corresponds to time taken for read when there is cache hit $= 140 \,\text{ns}$

$0.9$ is cache hit rate

Time taken for $60$ read operations,

$= 60*((0.9*1)+(0.1*5))$
$= 84\,\text{ns}$

Time taken for $40$ write operations

$= 40*((0.9*2)+(0.1*10))$
$= 112\,\text{ns}$

Here, $2$ and $10$ are the times taken for write when there is cache hit and no cache hit respectively.

So,the total time taken for $200$ operations is,

$= 140+84+112$
$= 336\,\text{ns}$

Average time taken $=$ time taken per operation

$=\dfrac{336}{200}$

$= 1.68\,\text{ns}$
edited by

4 Comments

@Bikram sir can you explain when to go for simultaneous or hierarchy access?
0
0

I have a doubt here, “ Execution of a sequence of instructions involves 100 instruction fetch operations, 60 memory operand read operations and 40 memory operand write operations. “ Why are we considering 200 instructions… There can be 100 instructions also, as every instruction must be fetched 1st- so 100 fetch. Now out of these 40 are memory read,  and 60 are memory writes. What is wrong with this?

1
1
every instruction fetch itself includes a memory read operation as well to read the opcode. then after reading the opcode, it says whether to read or write which is separate.
0
0
37 votes
37 votes
Fetch is also a memory read operation.

Avg access time $= \dfrac{160 (0.9 \times 1+0.1 \times 5)+ 40(0.9 \times 2+0.1 \times 10)}{200} \\=\dfrac{160\times 1.4+40 \times 2.8}{200} \\=\dfrac{336}{200} \\=1.68$
edited by

4 Comments

@sumit

The answer is 1.68 and it is correct .

see the question, what it says : " Execution of a sequence of instructions involves 100 instruction fetch operations, 60 memory operand read operations and 40 memory operand write operations. "

 Now instruction fetch operation is same as Read operations. so  total 100 read operations . And 60 operand read operations and 40 memory operand write operations .  

Total number of instructions= 100+60+40 =200
1
1

iamhusayn   and @sushmita @bharti

why do we divide 336 by 200? Here it is not mentioned to find out Average Access Time per instruction. So answer should be 3.36 instead of 1.68 .

Average Memory Access Time = Time  for 1 memory access. 

Total number of instructions= 100+60+40 =200

Here for 200 memory accesses total time is 336 ns .

so for 1 memory access time is 336 ns / 200 = 1.68 ns

Hence Average mem Access Time = 1.68 ns

4
4
i got each and every thing but here the no. of instructions are 100 only and according to me out of 100 fetched instructions 60 are read and 40 are for write operation..? but why is it wrong..?
1
1
6 votes
6 votes
TavgR = 0.9 * 1 + 0.1 * 5 = 1.4 //TavgR here is avg time needed to one read operation

TavgW=0.9 *2 + 0.1*10 =2.8 //TavgW here is avg time needed to one write operation

Tavg = Total time needed to read/write operations / total no.of operations

Here Read operations are=100(fetch) + 60(memory read) = 160

Here Write operations are=40

So= (160 * 1.4 + 40 * 2.8 ) / 200

    =336/200=1.68ns

4 Comments

@Bikram sir,

yes sir, now I got it .thank you for explaining me.

Earlier, i was considering the total time 336 ns as 1 memory access time. i had wrongly interpreted the question .Thank you, sir for clarifying this
0
0
its clearly written that 100 fetch which means 100 instructions, why are u taking 200 instructions??

200 is total of memory references.
0
0

@ sushmita

Fetching means loading ,rt?

And in microprocessor load is an instruction.

I think that is why we are calculating w.r.t.200 instructions.

0
0
1 vote
1 vote

……………………....………….….………..……..........................….……..…

1 comment

Nice explanation
0
0
Answer:

Related questions