The main limitation of programmed I/O and interrupt driven I/O is given below:
Each instructions selects one I/O device (by number) and transfers a single character (byte)
Example: microprocessor controlled video terminal.
Four registers: input status and character, output status and character.
Primary disadvantage of programmed I/O is that CPU spends most of its time in a tight loop waiting for the device to become ready. This is called busy waiting.
With interrupt-driven I/O, the CPU starts the device and tells it to generate an interrupt when it is finished.
Done by setting interrupt-enable bit in status register.
Still requires an interrupt for every character read or written.
Interrupting a running process is an expensive business (requires saving context).
Requires extra hardware (DMA controller chip).
All these limitation can be overcome by the Introduction of DMA (Direct Memory Access)
To write block of 32 bytes from memory address 100 to device 4
1. CPU writes 32, 100, 4 into the first three DMA registers (memory address, count, device number)
2. CPU puts code for WRITE (say 1) into fourth (direction) DMA register, which signals DMA controller to begin operation
3. Controller reads (via bus request as CPU would) byte 100 from memory
4. Controller makes I/O request to write to device 4
5. Controller increments memory address register and decrements count register
6. Controller continues this loop until count decrements to 0
7. When count becomes 0 I/O is complete and controller asserts interrupt line on bus.
8. With DMA the CPU only has to start the I/O and respond to the final interrupt
9. There is only one interrupt per block of bytes input or output
10. Some DMA controllers can do two or more simultaneous I/O operations
11. DMA process is not free
– When controller wants to read/write via the bus it must make the CPU wait (DMA controller always has higher priority on bus). This process is called cycle stealing
- DMA I/O is used on PCs and minicomputers.