Skip to main content

Programmed I/O disadvantages; DMA

Short answer

Programmed I/O wastes CPU time polling and transferring each byte, reducing throughput and preventing computation overlap. DMA uses a controller to transfer blocks directly between memory and device, interrupting only when done, offloading the CPU.

What are the disadvantages of programmed I/O? Explain about DMA.

Programmed I/O (PIO)

In programmed I/O the CPU itself does all the data transfer. It polls the device status again and again (busy waiting) until the device is ready, then moves one byte/word at a time between memory and the device register.

Disadvantages of programmed I/O

  • The CPU is kept busy in a polling loop, so CPU time is wasted, since devices are slow compared with the CPU.
  • No other process can use the CPU during the transfer, so system throughput falls.
  • The CPU must handle every byte, so large transfers are slow.
  • Computation cannot overlap with I/O.
  • It is poor for devices that supply data at unpredictable times.

Direct Memory Access (DMA)

DMA lets special hardware, the DMA controller, transfer a whole block of data between memory and a device directly, without the CPU handling each byte. The CPU only starts the transfer and receives one interrupt at the end.

 CPU <----> Memory <----> Device ctrl
  |           ^  |            ^
  |           |  +--- bus ----+
  +--> DMA controller (address, count, control regs)

Steps of a DMA read

  1. The CPU programs the DMA controller with the memory address, byte count, direction and device, and then carries on with other work.
  2. The DMA controller asks the disk controller to transfer the data it has read into its buffer.
  3. The disk controller transfers the data over the bus to the given memory address.
  4. The DMA address register is incremented and the count decremented after each transfer.
  5. When the count reaches zero, the DMA controller interrupts the CPU to say that the transfer is complete.

Modes: cycle stealing (one word at a time; the controller steals a bus cycle from the CPU) and burst mode (the controller holds the bus and transfers a whole block).

PointProgrammed I/ODMA
CPU involvementDuring the whole transferOnly at start and end
Speed for big blocksSlowFast
InterruptsNone (the CPU polls)One per block
HardwareSimpleNeeds a DMA controller

DMA is therefore the best choice for fast devices like disks.

✓ Answer checked by Claude Opus 5.5 (high effort)

All Operating System chapter 6 questions →