Let , x= Data preparation time or CPU time and y= Data transfer time
When to use which formula: to find % of cpu time consume , that depends on the exact wordings in question .
In Cycle Stealing Mode -
In this case we use ( x/y )
In cycle stealing mode we always follow pipelining concept that means when one byte is getting transferred then at the same time Device is parallel way preparing the next byte.So we use concept of x/y .
example - explicitly mention it is in cycle stealing mode
Example problem :
Consider a device 1 MBPS is operating in a cycle mode of DMA. Whenever 16 B word is available it is transferred into memory in 4 microsecond.What is the ℅ of time the processor is blocked due to DMA ?
For Cycle Steal Mode :
Data is transferred word by word from DMA to memory .
Here total data size is 16 Bytes . And 1 word = 16 Bytes ( given )
so for 16 B data we need to transfer in 1 word means 1 time bus access is require by DMA.
each cycle time is 4 micro second, to transfer 16 Bytes it takes 1 * 4 =4 micro seconds to transfer 16 Bytes data .
Hence Data preparation time is 4 microseconds .
Now, hard disk transfer rate is 1 MBPS = 10^6 Bytes/sec
so (10^6 * 8 ) bits is sending in 1 sec
1 bit is sending 1/(10^6 * 8 ) sec
so , 16 * 8 bits data is sending in 16 * 8 /(10^6 * 8 ) seconds = ( 16 * 8 /10^6 * 8 ) * 10^6 micro secs = 16 micro secs
so, to transfer 16 Bytes data hard disk needs 16 micro secs ( data transfer time )
Then, % of CPU time consume for DMA operation is : ( 4/16 ) * 100 = 0.25 * 100 = 25%
Ans is 25% CPU time is consumed in Cycle Steal Mode .
In Burst Mode -
In this case we use ( x/x+y )
default is burst mode, when no mode mention explicitly , we use Burst mode .
example : burst mode in both cases ,
Burst mode example problem :
A hard disk with a transfer rate of 10 Mbytes/second is constantly transferring data to memory using DMA. The processor runs at 600 MHz, and takes 300 and 900 clock cycles to initiate and complete DMA transfer respectively. If the size of the transfer is 20 Kbytes," Then what is the percentage of processor time consumed for the transfer operation ?
Clock cycle time = 600 MHz =1/ (600 x 106 ) seconds
total cycle time for processor is (300+900)=1200 and each cycle time is 1/ (600 x 106 ) seconds
So data preparation time = x , which is 1200 * 1/ (600 x 106 ) * 106 microsecs = 2 microsec. This 2 microsec is x .
Now coming to y = data transfer time
here data transfer rate from disk is 10 MB/sec , total data to transfer is 20 KB .
so, Disk Transfer data at a rate of 10 Mbytes/sec
1 byte transfer in 1/107 sec
20 Kbytes transfer in 2 milisec = 2000 micro sec .. this 2000 microsec is data transfer time of y .
now here nothing is mention so we use formula for burst that is x/x+y
so put x and y value and we get the answer.
Percentage of processor time consumed for the transfer operation is (2/2+2000) * 100 = 0.0999 = 0.1% .
See how those questions are framed, then only you understand which mode to use where . In cycle steal they always mention it explicitly.