What are the basic differences between interrupt initiated I/O and programmed I/O? Explain in detail.
What are the basic differences between interrupt initiated I/O and programmed I/O? Explain in detail.
Quick answer
Programmed I/O and interrupt-initiated I/O are two ways in which the CPU controls the transfer of data to and from an I/O device. They differ mostly in how the CPU learns that the device is ready.
Programmed I/O
The CPU runs a program that tests the status flag of the device again and again in a loop. This is called polling. When the flag shows "ready", the CPU transfers one word between the device and a CPU register. Then it goes back to polling for the next word.
The CPU does nothing useful while it waits. It is therefore tied up for the entire time the device takes. The method needs little hardware and is easy to program. It is used when the system has a single job or when the device is very fast.
Interrupt-initiated I/O
Here the CPU starts the device and then goes on with other work. When the device is ready, its interface sends an interrupt request. The CPU completes its current instruction, saves the return address and the flags, and jumps to the interrupt service routine. The routine moves one word, and the CPU returns to the interrupted program.
The CPU is not kept waiting, so it is used well when devices are slow. The cost is the time spent in saving and restoring the state for each interrupt, and the extra hardware for interrupt handling and priority.
Differences
| Point | Programmed I/O | Interrupt-initiated I/O |
|---|---|---|
| Who finds that the device is ready | CPU, by polling the flag | Device, by an interrupt signal |
| CPU use | Wasted in busy waiting | Free for other work meanwhile |
| Response time | Depends on the polling loop | Fast, as the interrupt is served at once |
| Hardware | Simple | Needs interrupt logic and priority |
| Overhead per word | Test of the flag | Saving and restoring state |
| Software | Simple loop | Needs a service routine |
| Efficiency | Poor for slow devices | Good for slow and medium devices |
| Typical use | Small embedded systems | Keyboard, mouse, timer |
Summary
Programmed I/O is simple but wasteful, because the CPU stays in a loop. Interrupt-initiated I/O uses the CPU much better because the device calls the CPU when needed. Neither is suited to moving big blocks of data at high speed. For that, DMA is used, since in both of these methods the CPU must handle every word.
Short on time? The 1, 5 and 10 mark versions of this answer, flashcards and practice sets come with a program pass.
Up nextWhat do you mean by processor organization? Explain various types of processor organizatio