Well, that is a really nice question. Let me try to explain as much as I know.
Whenever a process needs to transfer some data from / to an input device, such a operation is known as I/O operation.
- If the process (of transfer of data from / to device) is performed under the control a program, that is it sets the registers of input / output device, then such a mode is called Programmed I/O. In such a mode, the CPU initiates the (driver) program, to transfer the bytes from / to device. And it waits for the operation to complete. However, the program does not tell CPU that the operation has completed. CPU has to query the status of (certain) registers to get the information. So, CPU has to continously Poll to get the status. This severly degrades the performance of system.
In short CPU waits while program completes IO.
- If the process (of transfer of data from / to device) is performed in such a way that after the transfer is complete , the program interrupts CPU to tell that the action is completed, then such a mode is called Interrupt driven I/O. In such case, CPU issues the command for transfer and continues to work on something else. During this time, IO module gets data form device and once it gets, it interrupts CPU. On getting interrupt, CPU transfers data to memory.
In short, CPU is able to do other things while IO in progress
- If the process (of transfer of data from / to device) is performed in such a way that after the transfer is carried out entirely to memory by device other than CPU, it is called DMA mode. In such a mode, CPU tells DMA that it needs some data from IO device. And then CPU continues doing something else. DMA, interrupts CPU, to get a bus (for memory) to transfer data to / from memory from / to IO. CPU grants bus and then does something else.
In short, CPU is able to do other things here also while IO is in progress. In this mode, CPU performs good.
Request others to add / share insights to this