Skip to content
GATEiit

GATE CSE · Computer Organization and Architecture

I/O interface: interrupt and DMA

How the CPU talks to devices: I/O interfaces and port addressing, programmed I/O and polling, interrupt handling and priority (daisy chain, vectored), and DMA with burst and cycle-stealing modes, with the CPU-overhead calculations GATE asks.

Before you start

  • Instruction cycle →

    Interrupts are checked at the end of the instruction cycle; DMA can take the bus between bus cycles.

  • Context saving →

    An interrupt saves the PC and status, much like a context switch.

  • Rates and units

    Overhead questions convert bytes per second into transfers per second and then into CPU time.

This topic comes before: System calls, processes and threads

Concept notes

1. I/O interfaces and addressing devices

An I/O interface (device controller) sits between the system bus and a device. It has a data register (buffer), a status register (ready, busy, error bits) and a control register (commands). The CPU reaches these registers through ports.

Memory-mapped I/O Isolated (I/O-mapped) I/O
Port addresses part of the memory address space separate I/O address space
Instructions ordinary load/store special IN/OUT
Control lines memory read/write separate I/O read/write lines
Memory space some addresses are used up by devices full address space for memory
Flexibility any addressing mode works on ports only the I/O instructions

Three ways to move data

Method Who moves the data CPU busy
Programmed I/O CPU, by polling status entire time (busy wait)
Interrupt-driven I/O CPU, inside the ISR only in the ISR, per unit transferred
DMA DMA controller only to set up and to take the completion interrupt

Programmed and interrupt I/O pass every word through a CPU register. DMA moves data directly between device and memory.

2. Polling and interrupt-driven I/O

In programmed I/O the CPU loops reading the status register until the device is ready, then moves one unit of data. If the CPU must not miss data, it has to poll at least as often as the device produces units: polls per second=data ratebytes per transfer. CPU fraction used =polls/s×cycles per pollclock rate.

In interrupt-driven I/O the device raises an interrupt request when ready, so the CPU does other work meanwhile. Each interrupt costs a fixed overhead: save state, run the interrupt service routine (ISR), restore state. The CPU fraction is computed the same way with interrupts per second and cycles (or time) per interrupt. Interrupts beat polling when the device is slow or idle often; for a very fast device the per-interrupt overhead can make it worse, which is why DMA exists.

Handling sequence

  1. The device asserts the interrupt request.
  2. The CPU finishes the current instruction and checks for pending interrupts.
  3. If interrupts are enabled, it saves PC and status (usually on the stack), disables further interrupts as needed and acknowledges.
  4. It finds the ISR address and runs the ISR.
  5. A return-from-interrupt instruction restores PC and status.

A maskable interrupt can be disabled by software; a non-maskable interrupt (NMI) cannot and is used for critical events such as power failure.

3. Identifying the source and priority

When several devices share the request line, the CPU must find which one interrupted.

  • Polling (software): a common ISR reads each device's status in a fixed order. Priority is the polling order. Simple, slow.
  • Vectored interrupts: the device puts a vector (an address, or an index into the interrupt vector table) on the bus during acknowledge, so the CPU jumps straight to the right ISR.
  • Daisy chaining (hardware, serial): the acknowledge signal INTA passes from device to device. A device that has requested keeps INTA and places its vector; one that has not passes INTA on. The device nearest the CPU has the highest priority. It is cheap, but a far device can wait a long time if nearer ones keep interrupting, and one faulty device can break the chain.
  • Parallel priority (priority encoder / interrupt controller): each device has its own request line; an encoder picks the highest-priority active one. Fast and programmable, more hardware.

Nested interrupts: an ISR may be interrupted by a higher-priority request if it re-enables interrupts. The CPU keeps a current priority level and accepts only higher ones.

CPUDevice 1Device 2Device 3INTApasspassshared interrupt request line (INTR)Priority: Device 1 (nearest the CPU) highest, Device 3 lowest
Daisy chaining: INTA passes through the devices in order, so position sets priority

4. Direct memory access (DMA)

A DMA controller moves a block between a device and memory without the CPU touching each word. It holds an address register, a word count register and a control register (direction, mode).

Steps:

  1. The CPU programs the DMA controller: memory address, count, direction.
  2. When the device is ready, the controller asserts bus request (HOLD / BR).
  3. The CPU finishes its current bus cycle (not necessarily the instruction) and grants the bus (HLDA / BG).
  4. The controller transfers data, increments the address and decrements the count.
  5. When the count reaches zero, it raises an interrupt to tell the CPU.

The CPU can grant the bus at the end of any bus cycle, even in the middle of an instruction. It services an interrupt only at the end of an instruction.

Modes

Mode How the bus is used CPU effect
Burst (block) controller keeps the bus until the whole block is moved CPU blocked from the bus for the whole block
Cycle stealing controller takes one bus cycle per word, then returns the bus CPU slowed slightly and often
Transparent controller uses only cycles when the CPU does not need the bus no slowdown, slowest transfer

Calculations. For cycle stealing, fraction of bus time taken =(words per second)×(bus cycle time). For burst mode, fraction =time to transfer one blocktime between blocks. The CPU overhead of DMA itself is only setup plus one completion interrupt per block.

Formulas to remember

Transfers per second
ratetransfer=data rate (bytes/s)bytes per transfer
CPU fraction for polling or interrupts
f=transfers/s×cycles per transferclock rate
Cycle stealing: bus time taken
f=words/s×tbus cycle
Burst mode: CPU blocked
f=tblock transfertbetween blocks

Common mistakes

  • Saying the CPU responds to a DMA request only at the end of an instruction; it can release the bus after any bus cycle.
  • Mixing 1 MB=106 and 220 bytes; use the convention the question states.
  • Forgetting to divide the data rate by the transfer size before multiplying by the cost per transfer.
  • Charging DMA CPU overhead per word; with DMA the CPU pays per block (setup and completion interrupt).
  • Assuming daisy chaining is fair; priority is fixed by position, so far devices can starve.

Worked examples

Try each step yourself, then reveal the working.

Example 1: Cost of polling a fast device

numerical

A 1 GHz CPU uses programmed I/O for a device that delivers data at 4 MB/s (1 MB=106 bytes) in 16-byte units. Each poll (including the transfer) takes 400 clock cycles. What fraction of CPU time goes to polling if no data may be lost?

  1. Step 1: How often must the CPU poll?

    Try it on paper first.

Example 2: Interrupts versus DMA for the same device

numerical

The same device (4 MB/s, 1 GHz CPU) is now handled (a) by an interrupt per 16-byte unit costing 500 cycles, or (b) by DMA with 8000-byte blocks, where each block costs the CPU 1000 cycles to set up and 500 cycles for the completion interrupt. Find the CPU fraction in each case.

  1. Step 1: Interrupts per second and cycles.

    Try it on paper first.

Example 3: Bus time taken by cycle stealing

numerical

A device sends data at 2 MB/s (106 bytes per MB) using cycle-stealing DMA over a 32-bit bus. Each stolen bus cycle moves one 32-bit word and takes 50 ns. What fraction of bus time does the DMA use?

  1. Step 1: Words per second.

    Try it on paper first.

Example 4: Who wins in a daisy chain?

conceptual

Devices D1, D2, D3 are daisy-chained in that order from the CPU. D2 and D3 request an interrupt at the same moment. Which is serviced first, and what can go wrong for D3?

  1. Step 1: Follow INTA from the CPU.

    Try it on paper first.

Previous year questions

9 official GATE CSE questions on this topic, newest first.

Practise these 9 PYQs →

Topic test

10 questions: up to 4 official PYQs and original practice questions, with GATE marking (MCQ wrong answers lose marks). Score 60% or more to pass. A new set is drawn each time.

Mark as mastered

Loading your progress…

My revision notes

Notes written by the GATEiit team against the official GATE CSE syllabus; being checked by a reviewer. Updated 2026-11-21. Spotted a mistake? Use Report an issue on any question, or contact us.