Programmed I/O:
- The processor sends a request to the I/O device to transfer data.
- The I/O device responds to the request by sending or receiving data.
- The processor waits for the I/O operation to complete before moving on to the next instruction.
Interrupt-driven I/O:
Difference between Programmed I/O and Interrupt-driven I/O:
Programmed I/O vs Interrupt-driven I/O: Comparison Table
| Feature | Programmed I/O | Interrupt-driven I/O |
|---|---|---|
| What the CPU does while waiting | Busy-waits, repeatedly checking the device status flag (polling) | Runs other tasks until the device sends an interrupt |
| Who starts each transfer | The CPU, after it sees the device is ready | The device, by raising an interrupt request |
| CPU efficiency | Low: many cycles are wasted in the polling loop | High: no time is wasted waiting |
| Hardware needed | Simple, no interrupt logic | Interrupt lines and often an interrupt controller (e.g. 8259 PIC) |
| Overhead per transfer | Very small | Context save/restore and ISR call on every interrupt |
| Does data pass through the CPU? | Yes | Yes, every byte or word |
| Best for | Fast or simple devices, short transfers, small embedded systems | Slow or unpredictable devices (keyboard, mouse, printer) |
| Example | A loop that keeps reading a UART status bit until a byte arrives | A key press on a PC raising a hardware interrupt (INT 09h) |
Advantages and Disadvantages
Programmed I/O
- Advantage: Very simple to design and program.
- Advantage: No extra interrupt hardware is required.
- Advantage: Predictable timing, which is useful in simple embedded systems.
- Disadvantage: Wastes CPU time while busy-waiting.
- Disadvantage: The CPU cannot do other work during the transfer.
Interrupt-driven I/O
- Advantage: CPU time is used efficiently; no busy-waiting.
- Advantage: Allows multitasking and quick response to external events.
- Disadvantage: Needs extra hardware and more complex software (ISRs, priorities).
- Disadvantage: Each interrupt adds overhead for saving and restoring the CPU state.
- Disadvantage: The CPU still moves every byte, so it is slow for large block transfers.
How an Interrupt Is Serviced (Step by Step)
- The I/O device raises an interrupt request (IRQ) when it is ready.
- The CPU finishes the instruction it is currently executing.
- If interrupts are enabled (the IF flag in the 8086), the CPU acknowledges the request.
- The CPU saves its context. In the 8086 it pushes the FLAGS, CS and IP registers onto the stack.
- The CPU finds the address of the Interrupt Service Routine (ISR). In the 8086 this comes from the interrupt vector table at address type × 4.
- The ISR runs and transfers the data to or from the device.
- The ISR ends with
IRET, which restores IP, CS and FLAGS, and the CPU resumes the interrupted program.
What About DMA (Direct Memory Access)?
Both programmed I/O and interrupt-driven I/O move every byte through the CPU. For large blocks of data, such as reading a disk sector, that is slow. With DMA, a DMA controller (for example the Intel 8237) transfers the whole block directly between the device and memory. The CPU only sets up the transfer at the start and receives one interrupt when it is finished.
| Method | CPU involvement | Best for |
|---|---|---|
| Programmed I/O | During the whole transfer, including waiting | Simple, low-speed tasks |
| Interrupt-driven I/O | For every byte or word, but no waiting | Slow, unpredictable devices |
| DMA | Only at the start and the end | Large, high-speed block transfers |
Practice MCQs for Job and University Exams
1. In programmed I/O, the CPU:
(a) Is interrupted by the device when it is ready
(b) Repeatedly checks the status of the device
(c) Is bypassed by a DMA controller
(d) Does not take part in data transfer
Answer: (b)
2. Which I/O method wastes the most CPU time?
(a) Programmed I/O
(b) Interrupt-driven I/O
(c) DMA
(d) All waste equal time
Answer: (a)
3. Which method lets the CPU run other instructions while waiting for a slow device?
(a) Programmed I/O
(b) Interrupt-driven I/O
(c) Polling
(d) Busy-waiting
Answer: (b)
4. The best method for transferring a large block of data from disk to memory is:
(a) Programmed I/O
(b) Interrupt-driven I/O
(c) DMA
(d) Polling
Answer: (c)
5. In the 8086, the ISR address for interrupt type n is stored at memory address:
(a) n × 2
(b) n × 4
(c) n × 8
(d) n + 4
Answer: (b)
6. Which 8086 instruction returns from an Interrupt Service Routine?
(a) RET
(b) IRET
(c) HLT
(d) INT
Answer: (b)
7. Repeatedly checking a device status flag in a loop is called:
(a) Polling
(b) Vectoring
(c) Masking
(d) Nesting
Answer: (a)
8. In interrupt-driven I/O, data between the I/O device and memory passes through:
(a) The DMA controller
(b) The CPU
(c) The cache only
(d) The interrupt controller
Answer: (b)
Frequently Asked Questions (FAQs)
Q: Is polling the same as programmed I/O?
A: Almost. Programmed I/O normally uses polling: the CPU keeps reading the device status register until the device is ready, then transfers the data.
Q: Which is faster, programmed I/O or interrupt-driven I/O?
A: For a single short transfer with a fast device, polling can respond slightly faster because there is no context-saving overhead. For the system as a whole, interrupt-driven I/O is better because the CPU is not stuck waiting.
Q: Why do we need DMA if interrupts already exist?
A: With interrupts, the CPU still moves every byte and handles an interrupt each time. For large blocks this overhead is too high, so a DMA controller moves the data directly to memory.
Q: What is an Interrupt Service Routine (ISR)?
A: An ISR is a short program that runs when an interrupt occurs. It handles the device (for example, reads the received byte) and then returns control to the interrupted program.
Q: What is interrupt latency?
A: Interrupt latency is the time between a device raising an interrupt and the CPU starting to execute its ISR. Lower latency means faster response to external events.

Your posts are very informative and easy to understand
ReplyDeleteGreat and that i have a neat offer: Where To Remodel House split level home remodel
ReplyDeleteRespect and I have a nifty provide: How Long Renovate House average cost to renovate a house
ReplyDeleteThat sounds great! If you want, .Vaporgorilla smoke shop in pune can help refine your comment to make it more engaging and professional. Could you share what you wrote or give me an idea of what you want to say? https://vaporgorilla.marketgrow.in/😊
ReplyDeleteAbsolutely loved this insightful blog! The detailed information and creativity shared really showcase the beauty and versatility of iron work. As an avid admirer of quality craftsmanship, I can definitely appreciate the skill involved in iron fabrication. For those in Pune, it's always a pleasure to see how skilled iron fabricators can transform spaces with intricate iron grill designs. The elegance and strength of wrought iron truly make a statement, and this blog perfectly highlights that. Keep up the fantastic work! Best Fabricator company in pune. https://maps.app.goo.gl/RExuzQNSB2NbroQ46
ReplyDeleteWant to dominate local search results? 🌟 Market Grow offers professional Google My Business management services in Delhi NCR to improve rankings, enhance visibility, and attract more customers. From keyword optimization to review management, we do it all! ✅ Let’s take your business to the next level today. 🚀📍best google my business expert in Delhi NCR
ReplyDeleteGreat job on this insightful blog! The way you've discussed mental health and online counseling is truly commendable. As someone deeply involved in providing counseling services in Pune, I can appreciate how helpful your content is for people seeking guidance. It's fantastic that you're highlighting the importance of online counselling for depression in India. Offering free online counselling for depression in India is a wonderful initiative, and your post will surely inspire many to seek the help they need. Keep up the excellent work! Best Counseling service in pune. https://maps.app.goo.gl/JELYS9Ttqjd6zdDfA
ReplyDelete