I/O control question

Fistandantilis

Senior member
Aug 29, 2004
845
0
0
Programmed I/O is where I/O is handled only once per cycle, at the very beggining, before the normal fetch, decode and execution of data.
Interupt I/O is handled at any point during the clock cycle, whenever the I/O device needs data processing.
Direct Memory Access(DMA) is when the CPU sends all I/O requests to the DMA and the DMA handles all I/O processing and then reports back to the CPU.
(I hope that makes sence)

I wonder, does the DMA interupt the CPU when it is done with the I/O request?, does it give the CPU a memory address for the values or does it give the CPU the actual value?

Wow my first HT post.
 

Matthias99

Diamond Member
Oct 7, 2003
8,808
0
0
Originally posted by: Fistandantilis
Programmed I/O is where I/O is handled only once per cycle, at the very beggining, before the normal fetch, decode and execution of data.
Interupt I/O is handled at any point during the clock cycle, whenever the I/O device needs data processing.
Direct Memory Access(DMA) is when the CPU sends all I/O requests to the DMA and the DMA handles all I/O processing and then reports back to the CPU.
(I hope that makes sence)

I wonder, does the DMA interupt the CPU when it is done with the I/O request?, does it give the CPU a memory address for the values or does it give the CPU the actual value?

Wow my first HT post.

It's not interrupt-driven from the process perspective, but I think it usually is from the CPU's perspective. The CPU programs whatever piece of hardware to transfer X bytes and put it starting at memory address Y, and then when it's done, the hardware sends the CPU an interrupt and says 'hey, I'm done with that DMA job'. That's assuming you're actually talking about hardware-level DMA (as with hard drives), where something other than the CPU is actually doing the work.

From a programming standpoint, you pass whatever routine you are calling a pointer to a memory location where the status of the job should be updated when it is done (along with what you want transferred and where the actual data should go), and then you can poll at your leisure to see if the transfer has completed (or failed, or whatever). Internally, it could be done by either software or hardware (maybe the OS is just using the CPU to copy the data between memory locations), and it wouldn't make a difference to what the program sees.
 

Peter

Elite Member
Oct 15, 1999
9,640
1
0
Programmed I/O uses the CPU to pump the data. Interrupts are not involved - the code running on the CPU obviously knows when it's done transferring.

DMA uses other hardware to pump the data. The CPU sets the transfer up and starts it, and then either polls the the DMAing hardware for transfer completion, or continues to do other stuff until the DMAing hardware fires an "I'm done" interrupt.

DMA can either be "busmaster", wherein the data source/sink itself pumps the data, or via a system core DMA pump that addresses generic I/O hardware. Examples of the latter are floppy and ECP parallel port DMA, while everything PCI is busmaster DMA. IDE/SATA is the exception, this uses a PCI DMA engine, while the I/O device is in the drive itself.
 

Fistandantilis

Senior member
Aug 29, 2004
845
0
0
Originally posted by: Peter
DMA uses other hardware to pump the data. The CPU sets the transfer up and starts it, and then either polls the the DMAing hardware for transfer completion, or continues to do other stuff until the DMAing hardware fires an "I'm done" interrupt.

OK so, thats where my thought it but, is DMA considered a programed I/O or an interupt I/O?

If the CPU is "polling" the DMA, I would think that it would be programmed I/O, but if it is interupted by the DMA then dont that make it an interupt I/O?

I thought that there were 3 types of I/O handling, Programmed, interupt, and DMA, is DMA a combination of both? would a CPU waste time polling the DMA if it is the job of the DMA to interupt the CPU?

OR

Am I just not seeing the preverbial "forest between the trees"?

thanks

 

Peter

Elite Member
Oct 15, 1999
9,640
1
0
DMA and programmed I/O are the two possible methods of transfer. Either the CPU is doing it actively (PIO), or it's just waiting for the DMA agent to complete it.

Within the DMA method, there's a difference in how that waiting for completion is done. The CPU can either poll for end-of-DMA or wait for the DMA engine to send an interrupt. Of course, using interrupts is more effective in that no CPU time and no bus bandwidth is used for polling. However, interrupt usage is interesting only if the operating system can send the CPU off to do other things while the DMA transfer is running - will say, in multitasking environments.
 

blahblah99

Platinum Member
Oct 10, 2000
2,689
0
0
DMA transfers can get initiated by a external DMA request IO (for example, pulling a pin from 3.3V to 0), by software (programmed), or by interrupts (which can be external, or internal). In either case, at the very least the CPU has to setup the the source address registers, destination address registers, and # of bytes to move. On top of that, the CPU can set the DMA controller to generate an interrupt once the transfer is finish.

DMA can only transfer data when it has control of the data/address bus... ie, when the CPU isn't using the bus. The DMA controller can be programmed to generate an interrupt, or simply programmed to move data on its own time and finish without generating interrupts.

I think you're mixing up DMA, interrupts, and polling. But to answer your question, DMA is both Programmed IO and interrupt IO. The reason is that you can use DMA to generate an interrupt when it's done doing its task. Or you can use an interrupt to setup a DMA transfer. Or you can just setup the DMA transfer without generating an interrupt when finished, or requiring an interrupt to setup the DMA transfer.
 

Peter

Elite Member
Oct 15, 1999
9,640
1
0
And you wonder why he's confused?

It's only programmed I/O if the CPU is doing the actual transfer. DMA is DMA, regardless of whether the CPU polls for completion or gets an interrupt.

Bus ownership is arbitrated for; the CPU is one possible bus owner amongst all others.
 

Peter

Elite Member
Oct 15, 1999
9,640
1
0
WTF? NO IT'S NOT. Programmed I/O and DMA I/O are exact opposites of each other.

Obviously ANYTHING the machine does involve programming, but that's nothing to do with the answer to your question.

And no, I'm not going to explain it a sixth time. Just accept that the terminology is the way it is, thank you.
 

CycloWizard

Lifer
Sep 10, 2001
12,348
1
81
I think the gist is that programmed I/O is when the CPU actively gets the data directly from the source. DMA I/O is when the CPU tells the device to get its own data and lets the device do the work.