in CO and Architecture retagged by
2,102 views
1 vote
1 vote

Consider x = CPU time or data preparation time = 1 microsecond 

and y = data transfer time from DISK to DMA = 21 microseconds.

% of memory cycles stolen =  1/(21) * 100  = 4.76%

Doubt - For each 21 memory cycle, 1 memory cycle will be taken to transfer data. CPU can do its own work for 20 memory cycles and 1 memory cycle it will remain idle.

What does this CPU cycle stealing means ?

in CO and Architecture retagged by
by
2.1k views

8 Comments

edited by

For future readers : Don't read it..instead check the links attached here https://gateoverflow.in/250088/cycle-stealing-dma-doubt?show=285767#c285767

A bit of background:

The hard disk has to send some data to MM. It should take the help of processor to do so. When CPU gets an interrupt signal from any I/O device, then it asks the DMA controller to handle the interrupts and transfer data b/w the I/O device and the memory. For that CPU has to surrender it's control over memory bus for some time.

Then you might think what will CPU do now without the bus..will it sit idle...if yes then what is the use handing bus control to DMA..if no then what keeps CPU engaged?

CPU can carry out other instructions which do not require memory like ADD/SUB two register variables. So at this time parallely the DMA works on the transferring b/w I/O and main memory while the CPU handles instructions which do not require MM.

But there might arrive a situation where CPU may require the MM for eg to execute LOAD/STORE instructions. But since DMA has the control over the memory bus CPU has to wait till it gets it back. So at this time the CPU activity gets slowed down by some amount.

Note that while data is being transferred from I/O to DMA buffer we don't need memory bus and only I/O bus is required. Once the buffer is full meaning that DMA is ready to transfer data to MM, it asks the CPU to give the control over memory bus.

So steps are :

1) I/O generates interrupt.

2) CPU asks DMA to handle it.

3) I/O transfers data to DMA using I/O bus.

4) Once DMA buffer is full (data ready) it asks CPU to relinquish the memory bus.

5) CPU gives the memory bus to DMA.

6) After DMA finishes transferring it gives back the control to CPU.

There are some modes in which CPU and DMA work. One of them is cycle stealing mode.

Initially CPU is having control over MM through MM bus. Now data is ready in DMA buffer. It has to take the bus from CPU. Meanwhile CPU cannot carry out it's tasks which involved MM. So CPU is slowed down a bit as the DMA "stole" it's cycles. "Stealing a cycle" means taking control over the bus. DMA transfers 1B per cycle and then releases the bus.

Other mode is Burst mode where DMA possesses the bus as long as the whole data in buffer is not transferred to MM. Another is transparent mode(not reqd for Gate i guess).

This topic has troubled me a lot and all these are my conclusions after going through various resources. If you find anything wrong then point it out.

 

 

 

 

5
5

MiNiPanda Thanks a lot mate, god bless you! Thanks again :)

2
2
Awesome answer
0
0

@MiNiPanda 

Suppose buffer has 10B of data then will it alternate like, 1 cycle dma -> 1 cycle Cpu so on till buffer get empty ?

1B / cycle is default or will be mentioned in exam that how much data dma transfers in 1 cycle ?

0
0

@MiNiPanda Is it Only 1 Byte /Cycle or As much data DMA controller can send in one cycle? Kindly clarify

0
0

@iarnav  @Mk Utkarsh   @neeraj33negi   @HeadShot   @Ajit J  @prashant jha 1

I would request all of you to please check these links

1)https://gateoverflow.in/116524/coa-dma-doubt?show

2)https://gateoverflow.in/?qa=blob&qa_blobid=18388358629298189207

I was kind of under wrong impression about this topic so some things which I said was not right. Please accept my apology _/\_ :(

 

0
0

@MiNiPanda 

Please kindly edit the points in your answer where you feel you were wrong coz rest is beautifully written.

Ping after done . Thanks for the correction. :)

0
0

@HeadShot

I found these links today morning and realized I have to revise this part again..There is a lot of confusion and sums related to this concept are often difficult for me to solve..I can't edit my previous comment because I am not sure what I'll write now might be found wrong some other day :P

Instead I am adding a note there so that other users don't get misled in future..

1
1

Please log in or register to answer this question.

Related questions