Skip to main content

Computer Organization

I/O Systems

Polling wastes CPU, interrupts improve it, DMA moves blocks — match the method to the transfer size.

~3 hrs ~0.5–1 mark · Moderate 10 samples · 10 practice · 10 cards

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.
MethodCPU involvementBest for
PollingHigh (busy-wait)Simple/slow devices
InterruptsMedium (per event / per byte or packet)Moderate rates, interactive I/O
DMALow (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.

Comparison of polling interrupt-driven I/O and DMA by CPU involvement
Large block transfer ⇒ DMA. Per-character interactive I/O ⇒ interrupts.

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.

DMA cycle stealing versus burst mode bus holding trade-offs
Steal = interleaved with CPU; burst = hold bus longer for bandwidth.

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.
StyleHow CPU talks to device regsTrade-off
Memory-mappedNormal load/storeUses memory address space
Port-mappedSpecial I/O instructionsSeparate I/O space
Memory-mapped I/O versus port-mapped I/O address space styles
Mapping style is not the same as poll / IRQ / DMA — do not conflate them.

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.
Exam pattern · 10 questions

GATE sample questions & answers

10 GATE-style MCQs for I/O Systems with full explanations. Attempt each question before revealing the answer.

Q1 DMA

Best for large block transfers with minimal CPU data movement:

  • A) Polling
  • B) Busy-wait only
  • C) DMA
  • D) Byte OUT loops
Show answer & explanation

Answer: C

DMA moves blocks after setup.

Q2 Memory-mapped

Memory-mapped I/O means:

  • A) Devices via memory address space loads/stores
  • B) Only DMA can access devices
  • C) Separate CPU for I/O only
  • D) Caches disabled forever
Show answer & explanation

Answer: A

Device regs in memory map.

Q3 Polling

Polling I/O characteristic:

  • A) Zero CPU
  • B) CPU repeatedly checks status
  • C) Only DMA
  • D) No device
Show answer & explanation

Answer: B

Busy-wait on status.

Q4 Interrupts

Interrupt-driven I/O improves over polling by:

  • A) Removing devices
  • B) Avoiding constant busy-wait
  • C) Deleting memory
  • D) Forcing DMA
Show answer & explanation

Answer: B

CPU runs other work until interrupt.

Q5 Vectored

Vectored interrupt provides:

  • A) Disk geometry
  • B) Handler address / vector
  • C) Cache size
  • D) Only NMI mask
Show answer & explanation

Answer: B

Points to ISR entry.

Q6 DMA setup

DMA setup is done by:

  • A) Only the disk spindle
  • B) CPU programming the DMA controller
  • C) Cache alone
  • D) ALU flags
Show answer & explanation

Answer: B

CPU configures addresses/counts.

Q7 NMI

NMI means:

  • A) Normal Memory Interface
  • B) Non-maskable interrupt
  • C) Network Map Index
  • D) Nested Mux Input
Show answer & explanation

Answer: B

Cannot be masked off ordinarily.

Q8 Cycle stealing

Cycle stealing in DMA:

  • A) Formats disk
  • B) DMA briefly uses bus, CPU waits occasionally
  • C) Deletes interrupts
  • D) Doubles clock
Show answer & explanation

Answer: B

Interleaved bus use.

Q9 Port-mapped

I/O-mapped (port) addressing uses:

  • A) Only cache tags
  • B) Separate I/O address space / special ops
  • C) Only PC-relative
  • D) No CPU
Show answer & explanation

Answer: B

Distinct from memory map.

Q10 DMA done

After DMA block completes, CPU often gets:

  • A) Nothing ever
  • B) An interrupt signaling done
  • C) A cache cold miss only
  • D) A pipeline flush only
Show answer & explanation

Answer: B

Completion interrupt is common.

Topic drill · 10 questions

10 practice questions — I/O Systems

Extra page-specific practice beyond the GATE samples. Attempt all 10, then reveal answers to check your reasoning.

P1

Lowest CPU data-movement for 100 MB file to disk buffer:

  • A) Polling each byte
  • B) Interrupt per byte
  • C) DMA block transfer
  • D) Manual ALU loops
Show answer & explanation

Answer: C) DMA block transfer

DMA moves the block.

P2

ISR stands for:

  • A) Instruction Status Register
  • B) Interrupt Service Routine
  • C) I/O Sector Read
  • D) Indexed Store Register
Show answer & explanation

Answer: B) Interrupt Service Routine

Handler for the interrupt.

P3

Busy-wait is characteristic of:

  • A) DMA burst only
  • B) Programmed polling
  • C) Cache hit
  • D) Page walk only
Show answer & explanation

Answer: B) Programmed polling

CPU spins on status.

P4

Maskable interrupt can be:

  • A) Never delayed
  • B) Disabled by masking
  • C) Only from disk
  • D) Same as NMI
Show answer & explanation

Answer: B) Disabled by masking

Can be masked off.

P5

DMA needs the system bus because:

  • A) It paints pixels
  • B) It transfers between memory and device
  • C) It fetches only opcodes
  • D) It replaces ALU
Show answer & explanation

Answer: B) It transfers between memory and device

Bus carries the block.

P6

Memory-mapped device access uses:

  • A) Ordinary load/store to device addresses
  • B) Only JMP
  • C) Only floating add
  • D) Disk firmware only
Show answer & explanation

Answer: A) Ordinary load/store to device addresses

Same instruction encodings.

P7

Interrupt latency is roughly:

  • A) Disk RPM
  • B) Time until ISR starts useful work
  • C) Cache size
  • D) Pipeline depth only
Show answer & explanation

Answer: B) Time until ISR starts useful work

Response delay to interrupt.

P8

Burst DMA mode:

  • A) Transfers a run of words holding the bus
  • B) Never uses bus
  • C) Only polls
  • D) Clears PC
Show answer & explanation

Answer: A) Transfers a run of words holding the bus

Burst holds bus for multiple transfers.

P9

Programmed I/O moves data using:

  • A) Only DMA engine
  • B) CPU instructions
  • C) Only GPU
  • D) Only TLB
Show answer & explanation

Answer: B) CPU instructions

CPU executes IN/OUT or mmio loads/stores.

P10

Device status register is checked in:

  • A) Polling loops
  • B) Only compile time
  • C) Only page faults
  • D) Only branch predict
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.

Quick revision · 10 cards

10 flashcards — I/O Systems

Hover a card to reveal the answer with a 3D flip. On touch devices, tap the card or use Show answer.

Q1 What is the main downside of programmed I/O using polling?
Q2 For which kind of transfer is DMA usually the best choice?
Q3 What does memory-mapped I/O mean for accessing device registers?
Q4 What information does a vectored interrupt provide to the CPU?
Q5 What does NMI stand for, and how does it differ from a normal interrupt?
Q6 Who is responsible for setting up a DMA transfer before data movement begins?
Q7 What is cycle stealing in the context of DMA?
Q8 How does interrupt-driven I/O improve CPU utilization compared with polling?
Q9 How does port-mapped (I/O-mapped) addressing differ from memory-mapped I/O?
Q10 What typically happens when a DMA block transfer finishes?