Chapter 7

I/O interfaces, interrupts and DMACS

An I/O interface exposes data, status and control registers. Separate the mechanism that requests service from the mechanism that transfers data. The CPU, device and memory may have different speeds and must agree on each transfer.

7.1 Programmed and interrupt-driven I/OCS

Past papers · CS 2014–2026 (23 papers): 1 question, 1 mark

Programmed I/O executes instructions to test device status and transfer data. With polling, the processor repeatedly tests ready/busy; polling does not mean the device writes the CPU's registers automatically. Interrupt-driven I/O lets the CPU do other work until a device requests service, but a programmed handler still transfers data through CPU instructions unless DMA is also used.

Interface choiceAddressing and synchronisation
Memory-mapped I/ODevice registers occupy memory addresses; ordinary addressing mechanisms access them, subject to device rules
Isolated I/OSeparate I/O address space and I/O instructions or bus control signals
Synchronous transferTiming follows a shared clock and specified cycles
Asynchronous handshakeRequest/data-valid and acknowledge/ready coordinate a transfer

In a handshake, the sender keeps data valid until the receiver's acceptance condition is met. A strobe alone assumes enough timing information to sample correctly. Memory-mapped device registers may have read/write side effects, so normal caching or speculative access cannot be assumed.

7.2 Interrupt recognition, priority and returnCS

Past papers · CS 2014–2026 (23 papers): 4 questions, 4 marks

For a conventional precise interrupt accepted between instructions: finish the current instruction; preserve the return PC and required status; obtain/load the handler PC; execute the handler; restore state and return. Hardware may save only part of the context and software the rest. An exception caused by an instruction may save a different restart PC; use the ISA's rule.

MechanismSource identification and priority
Vectored interruptSource supplies or identifies a vector used to find its handler
Non-vectored interruptCommon entry or fixed handler; software may need to identify the source
Software pollingHandler checks devices in an explicit order
Daisy-chain priorityAcknowledge passes through devices; the nearest requesting device captures it
Parallel priorityHardware encoder chooses among pending requests
Masking/nestingA mask disables selected sources; higher-priority requests may pre-empt if enabled

A vector can be an index into a table, not necessarily the entire handler address. Daisy chaining determines priority in hardware; it is not CPU polling of every device. A distant device can starve under persistent higher-priority requests. Handler return must restore enough status for the interrupted computation to continue correctly.

7.3 Direct memory access and bus ownershipCS

Past papers · CS 2014–2026 (23 papers): 5 questions, 6 marks

The CPU programs DMA source/destination addresses, direction and transfer count. DMA requests the shared bus; after grant, it drives that bus and transfers data between device and memory. Only one master drives a single shared bus at a time. The CPU may still execute work that does not require that occupied bus; DMA does not universally halt every part of the CPU.

ModeTransfer scheduleMain trade-off
BurstRetain bus for a blockHigh bulk throughput, longer CPU memory wait
Cycle stealingTake an individual transfer opportunity, then releaseInterleaves CPU and DMA accesses
Transparent/idle-cycleUse bus only when CPU does not need itLess CPU interference, lower guaranteed DMA rate

A DMA read of memory must see recent CPU writes; dirty cache lines may need cleaning before the transfer. A DMA write can leave stale CPU cache copies; invalidate or use a coherent DMA mechanism according to the system contract. Write-through alone does not prevent stale cached data after an external write. Synchronisation and cache maintenance are distinct from granting the bus.

Last-minute recall

  • Polling repeatedly reads status; interrupt-driven I/O requests attention when needed.
  • A vectored source identifies a handler; daisy chaining establishes hardware priority.
  • Save the return state before overwriting it with handler state.
  • DMA transfers bulk data without a CPU copy instruction for each item.
  • CPU and DMA cannot simultaneously drive one shared bus as masters.
  • Count registers may encode count or count minus one; check the convention.
  • Multiply DMA bytes/s by eight to obtain bits/s.
  • DMA can require cache cleaning or invalidation even when transfer timing is correct.

Revise offline: the whole Computer Organization and Architecture handbook as one PDF

36 pages · 2.5 MBFree to read online. Sign in to download the PDF.We save the handbook, version and request time in My downloads. Privacy policy

All chapters · Corrections