Computer Organization
I/O Systems
Polling wastes CPU, interrupts improve it, DMA moves blocks — match the method to the transfer size.
GATE CSE I/O — programmed I/O, interrupts, DMA, cycle stealing, memory-mapped vs port-mapped I/O, with samples and drills.
Learning outcomes
- Compare polling, interrupt-driven I/O, and DMA by CPU overhead and transfer size
- Explain vectored, maskable, and non-maskable interrupt ideas at GATE depth
- Distinguish memory-mapped vs I/O-mapped (port) device addressing
- Describe DMA setup, cycle stealing / burst modes, and completion interrupts
Polling, interrupts, DMA
- Programmed I/O / polling: the CPU repeatedly reads a device status register until ready, then transfers data. Simple hardware, but the CPU burns cycles busy-waiting.
- Interrupt-driven I/O: the device asserts an interrupt when it needs service; the CPU saves state, runs an Interrupt Service Routine (ISR), then returns. CPU can do useful work between events.
- DMA (Direct Memory Access): a DMA controller transfers a block between memory and a device after the CPU programs start address, count, and direction. CPU is free during the bulk move.
- Maskable interrupts can be disabled by software; Non-Maskable Interrupts (NMI) are for critical events and cannot be ordinarily masked.
- Vectored interrupts provide an address/vector that selects the ISR; non-vectored schemes may jump to a fixed handler that must poll devices.
- Priority / nested interrupts: higher-priority devices can preempt lower-priority ISRs — GATE usually stays at the vocabulary level.
| Method | CPU involvement | Best for |
|---|---|---|
| Polling | High (busy-wait) | Simple/slow devices |
| Interrupts | Medium (per event / per byte or packet) | Moderate rates, interactive I/O |
| DMA | Low (setup + completion interrupt) | Bulk / block transfers |
Worked example
Problem. Transferring a 1 MB file from disk into a buffer — polling, interrupts-per-byte, or DMA?
Solution. DMA. Polling or per-byte interrupts would waste enormous CPU time on a large block.
DMA mechanics & bus use
- CPU setup: write DMA registers (memory address, device, byte/word count, direction), then start the transfer.
- During DMA, the controller becomes bus master for data movement. CPU may be stalled briefly when both need the bus.
- Cycle stealing: DMA takes the bus for one (or a few) transfers at a time, interleaved with CPU memory cycles — lower latency for CPU, slower DMA throughput.
- Burst / block mode: DMA holds the bus for a longer contiguous transfer — higher DMA bandwidth, longer CPU wait.
- On completion, DMA typically raises an interrupt so the CPU can handle bookkeeping — DMA is not “zero CPU forever”.
- DMA does not remove the need for device controllers; it removes the CPU from the inner copy loop.
Worked example
Problem. Does DMA mean the CPU never talks to the device?
Solution. No. The CPU still programs the DMA controller (and often the device) and usually handles a completion interrupt.
Addressing devices
- Memory-mapped I/O: device control/status/data registers appear in the regular memory address map. Ordinary load/store instructions read/write them — no special IN/OUT opcode required.
- I/O-mapped / port-mapped I/O: a separate I/O address space accessed with special instructions (classic IN/OUT). Keeps device addresses out of the memory map.
- Memory-mapped I/O can use the full instruction set on device registers (including ALU ops on status bits) but consumes memory address space.
- Either scheme can still use polling, interrupts, or DMA — addressing style ≠ transfer method.
| Style | How CPU talks to device regs | Trade-off |
|---|---|---|
| Memory-mapped | Normal load/store | Uses memory address space |
| Port-mapped | Special I/O instructions | Separate I/O space |
GATE exam tricks — I/O
- Large block transfer ⇒ DMA. Per-character interactive I/O ⇒ interrupts (or polling only for tiny/simple systems).
- DMA still needs CPU for setup and usually a completion interrupt — “CPU never involved” is a trap.
- Memory-mapped ≠ “only DMA can talk to devices”. Mapping describes address space, not DMA.
- Polling wastes CPU even when the device is idle-but-watched; interrupts waste CPU only when events occur (plus ISR overhead).
- NMI ≠ ordinary maskable IRQ — critical faults/events.
- Cycle stealing vs burst: steal = interleaved; burst = hold bus longer.
Exam tips
- Match method to transfer size and CPU budget.
- DMA = block mover; interrupts = event notifier; polling = busy-wait.
- Memory-mapped uses normal load/store encodings.
- Always mention setup + completion when describing DMA.
- Don’t confuse address-space style with DMA vs interrupt.
10 GATE-style MCQs for I/O Systems with full explanations. Attempt each question before revealing the answer.
Best for large block transfers with minimal CPU data movement:
Show answer & explanation
Answer: C
DMA moves blocks after setup.
Memory-mapped I/O means:
Show answer & explanation
Answer: A
Device regs in memory map.
Polling I/O characteristic:
Show answer & explanation
Answer: B
Busy-wait on status.
Interrupt-driven I/O improves over polling by:
Show answer & explanation
Answer: B
CPU runs other work until interrupt.
Vectored interrupt provides:
Show answer & explanation
Answer: B
Points to ISR entry.
DMA setup is done by:
Show answer & explanation
Answer: B
CPU configures addresses/counts.
NMI means:
Show answer & explanation
Answer: B
Cannot be masked off ordinarily.
Cycle stealing in DMA:
Show answer & explanation
Answer: B
Interleaved bus use.
I/O-mapped (port) addressing uses:
Show answer & explanation
Answer: B
Distinct from memory map.
After DMA block completes, CPU often gets:
Show answer & explanation
Answer: B
Completion interrupt is common.
Extra page-specific practice beyond the GATE samples. Attempt all 10, then reveal answers to check your reasoning.
Lowest CPU data-movement for 100 MB file to disk buffer:
Show answer & explanation
Answer: C) DMA block transfer
DMA moves the block.
ISR stands for:
Show answer & explanation
Answer: B) Interrupt Service Routine
Handler for the interrupt.
Busy-wait is characteristic of:
Show answer & explanation
Answer: B) Programmed polling
CPU spins on status.
Maskable interrupt can be:
Show answer & explanation
Answer: B) Disabled by masking
Can be masked off.
DMA needs the system bus because:
Show answer & explanation
Answer: B) It transfers between memory and device
Bus carries the block.
Memory-mapped device access uses:
Show answer & explanation
Answer: A) Ordinary load/store to device addresses
Same instruction encodings.
Interrupt latency is roughly:
Show answer & explanation
Answer: B) Time until ISR starts useful work
Response delay to interrupt.
Burst DMA mode:
Show answer & explanation
Answer: A) Transfers a run of words holding the bus
Burst holds bus for multiple transfers.
Programmed I/O moves data using:
Show answer & explanation
Answer: B) CPU instructions
CPU executes IN/OUT or mmio loads/stores.
Device status register is checked in:
Show answer & explanation
Answer: A) Polling loops
CPU reads status until ready.
Topic FAQs
When is DMA preferred?
Bulk/block transfers where the CPU should not move every word or byte itself.
What is memory-mapped I/O?
Device registers accessed via ordinary memory-space loads and stores.
What is a vectored interrupt?
An interrupt mechanism that supplies a vector/address identifying which ISR to run.
What is cycle stealing in DMA?
The DMA controller briefly takes the system bus for a transfer, interleaved with CPU memory cycles.
Hover a card to reveal the answer with a 3D flip. On touch devices, tap the card or use Show answer.