Tutorial 1 Ans
Tutorial 1 Ans
Tutorial 1 Ans
Let us ignore data read/write operations and assume the processor only fetches instructions. Then the
processorneedsaccesstomainmemoryonceeverymicrosecond.
Processor
Main Memory
External Device
Transferringcharactersmainmemoryfromanexternaldevicetransmittingat9600bitspersecond(bps);
Hence,1bit=1/9600s=1.04X104s=104us
Fetchinstructiontype,1millioninstructionspersecond
Assumethat,
1Instruction=1bps
1mps=1usperInstruction
9600persecond=104usperinstruction
So,ProcessorSlowdown=(1/104)x100%=0.9615%(approx.)Ans
2. A computer consists of a CPU and an I/O device D connected to main memory M via a shared
bus with a data bus width of one word (16-bits). The CPU can execute a maximum of 106
instructions per second. An average instruction requires five processor cycles, three of which use
the memory bus. A memory read or write operation uses one processor cycle. Suppose that the
CPU is continuously executing background programs that require 95% of its instruction
execution rate but not any I/O instructions. Assume that one processor cycle equals one bus cycle.
Now suppose that very large blocks of data are to be transferred between M and D.
a. If programmed I/O is used and each one-word I/O transfer requires the CPU to execute two
instructions, estimate the maximum I/O data transfer rate, in words per second, possible through
D.
b. Estimate the same rate if DMA transfer is used.
Processor
Answer
Main Memory
I/O Device
a.Theprocessorcanonlydevote5%(or,5/100)ofitstimetoI/O.
CPUcanexecuteamaximumof106instructionspersecond
ThusthemaximumI/Oinstructionexecutionrateis106x0.05=50,000instructionspersecond.
TheI/Otransferrateistherefore=50,000/2=25000words/second.
b.ThenumberofmachinecyclesavailableforDMAcontrolis
106x(0.05x5+0.95x2)=2.15x106
IfweassumethattheDMAmodulecanuseallofthesecycles,andignoreanysetuporstatuschecking
time,thenthisvalueisthemaximumI/Otransferrate.
Tc = 100 ns
Tm = 1200 ns
Cc = 0.005 cents/bit
Cm = 0.0002 cents/bit
a.Costof5MBofmainmemory
Cost=CmX5MB=0.0002X5X8X106=8000=$80
b. Costof5MBofmainmemoryusingcache
Cost=CcX5MB=0.005X5X8X106=200000=$2000
c. FromtheEquationTs=HT1+(1H)(T1+T2)=T1+T2HT2
H=
(T1+T2Ts)/T2
where
Ts=average(system)accesstime=20%T1=(20/100)100=20ns
T1=accesstimeofM1(e.g.,cache,diskcache)=100ns
T2=accesstimeofM2(e.g.,mainmemory,disk)=1000ns
H=hitratio(fractionoftimereferenceisfoundinM1)=?
H=(100+100020)/1000=1080/1000=1.08
-------------------------XXXXXXXXXXXXXXXXXXXX----------------------------------
4. A computer has a cache, main memory, and a disk used for virtual memory. If a referenced word
is in the cache, 20 ns are required to access it. If it is in main memory but not in the cache, 60 ns are
needed to load it into the cache (this includes the time to originally check the cache), and then the
reference is started again. If the word is not in main memory, 12 ms are required to fetch the word
from disk, followed by 60 ns to copy it to the cache, and then the reference is started again. The
cache hit ratio is 0.9(90%) and the main-memory hit ratio is 0.6 (60%). What is the average time in
ns required to access a referenced word on this system?
Answer:
Processor
12ms
Main Memory
Disk
Tc=20nsTm=60ns
Cache
Hc=0.9(90%)Hm=0.6(60%)
Left=0.1(10%)Left=0.4(40%)
Therearethreecasestoconsider:
Locationofreferencedword
Probability
Totaltimeforaccessinns
0.9
20
Notincache,butinmainmemory
(0.1)(0.6)=0.06
60+20=80
Notincacheormainmemory
(0.1)(0.4)=0.04
12ms+60+20=12,000,080
Incache
Sotheaverageaccesstimewouldbe:
Avg=(0.9)(20)+(0.06)(80)+(0.04)(12000080)=480026ns