Input Output Devices Interview Questions and Answers: Controllers, Interrupts and DMA

Prepare clear technical answers about the complete I/O path. Compare programmed I/O, interrupts and DMA, then calculate address, latency, bus and buffer costs.

KnowledgeGate Team

Exam prep & CS education

Updated 30 Nov 20266 min read
Input Output Devices Interview Questions and Answers: Controllers, Interrupts and DMA

Many candidates can list a keyboard, monitor and printer, but stall when asked what sits between a device and the CPU, when interrupts cost more than polling, or why DMA can slow a processor. These model answers explain the path and quantify trade-offs instead of repeating definitions. Each numerical example uses a simplified teaching machine and states the architecture assumptions that control the result.

Start with the path: device, controller, registers and CPU

What is an input/output device? It is a hardware endpoint through which a computer receives data, sends data, or does both. Direction is relative to the computer, so a touchscreen is both input and output. Human-facing use does not determine the classification.

Does the CPU communicate directly with a keyboard? It reaches controller registers through an interconnect. The controller translates peripheral protocol and timing, buffers data, reports status and raises configured interrupt requests. Data carries the payload, status reports state, and control holds commands or enable bits. Review Input Output Organisation in Computer Architecture. That post owns the architecture overview; this guide applies the path to interview comparisons and worked trade-offs.

In this teaching transaction, software sets CONTROL.IRQ_ENABLE = 1. The keyboard supplies byte 0x1C, so the controller sets DATA = 0x1C and STATUS = {READY:1, ERROR:0, IRQ_PENDING:1}. Reading DATA acknowledges the byte in this model and changes STATUS to {READY:0, ERROR:0, IRQ_PENDING:0}.

Programmed I/O, interrupt-driven I/O and DMA

How do the three methods differ? Programmed I/O keeps the CPU checking and moving data. Interrupt-driven I/O lets it work until the controller requests service. DMA transfers a configured block between a device and memory, then notifies the CPU.

Assume a device produces 50,000 32-bit words/s and a 1 GHz CPU. Polling every 2 microseconds gives 1 / 0.000002 = 500,000 checks/s. At 20 cycles/check, this is 500,000 x 20 = 10,000,000 cycles/s, or 1.00% of the CPU. One interrupt per word at 600 cycles/interrupt costs 50,000 x 600 = 30,000,000 cycles/s, or 3.00%. DMA blocks of 1,000 words give 50,000 / 1,000 = 50 blocks/s. At 2,000 setup-plus-completion cycles per block, control costs 50 x 2,000 = 100,000 cycles/s, or 0.01%.

This compares control overhead only; it excludes application copying, device wait time and bus contention. Use interrupts for sparse, unpredictable events, DMA for sustained blocks, and polling for a tiny deterministic loop. Event rate, block size, latency target and bus cost determine the choice.

Diagram compares CPU control overhead for polling, per-word interrupts, and DMA, showing 1.00%, 3.00%, and 0.01% CPU shares.

Memory-mapped versus isolated I/O

What is memory-mapped I/O? Device registers occupy addresses in the processor's normal address space and use ordinary load/store forms under device-memory rules. Isolated I/O uses a separate address space or control signals with dedicated I/O instructions.

Take a byte-addressed teaching CPU with a 16-bit address bus. The range 0x0000 to 0xFFFF has 2^16 = 65,536 byte addresses. Reserving 0xFF00 through 0xFFFF takes 0x100 = 256 addresses, leaving 65,536 - 256 = 65,280 for ordinary memory. A 32-bit DATA register can occupy 0xFF00-0xFF03, STATUS can occupy 0xFF04-0xFF07, and CONTROL can occupy 0xFF08-0xFF0B.

Is memory-mapped I/O automatically faster? No. Instruction form, interconnect, ordering and controller design determine access cost. Treat device-register accesses as protocol operations: use device-memory or volatile access and the platform's ordering primitives rather than cached-RAM assumptions.

Interrupt vectoring, masking, latency and service time

What happens when a device raises an interrupt? The controller asserts a request. Interrupt logic applies enable, mask and priority rules. At an architecture-defined point, the CPU accepts it, saves enough context, reaches the handler, identifies or acknowledges the source, services it and returns.

A teaching request arrives at 12.0 microseconds; the current instruction finishes at 12.4. Context entry takes 0.8, reaching 13.2, and dispatch takes 0.3, so the first device-register read is at 13.5. Latency is 13.5 - 12.0 = 1.5 microseconds. Service takes 2.0 microseconds and context restoration 0.7, so code resumes at 13.5 + 2.0 + 0.7 = 16.2. Request-to-resume time is 16.2 - 12.0 = 4.2 microseconds. Latency and total handling time differ.

Vectored or non-vectored? Vectored delivery provides a vector or source-specific entry. Non-vectored delivery uses a fixed or shared entry; software identifies the source when requests share that entry. Masking defers selected requests, while priority chooses among eligible ones. Neither makes the peripheral faster.

DMA setup, bus cycles and cache coherence

How does DMA work? The CPU programs destination 0x8000, count 4,096 bytes, width 4 bytes, direction device to memory, then starts the channel. DMA moves 4,096 / 4 = 1,024 32-bit beats into 0x8000-0x8FFF, updates status and raises one completion interrupt. The CPU still owns setup, buffer lifetime, completion and error handling.

What is cycle stealing? Assume an idealised bus carries 100,000,000 32-bit beats/s. One DMA grant in every ten beats gives 10,000,000 beats/s = 40,000,000 bytes/s. Transfer time is 4,096 / 40,000,000 s = 0.0001024 s = 102.4 microseconds. The CPU keeps the other 90% of bus slots during this interval. Burst mode instead holds the bus for the configured sequence of transfers.

Can DMA data be stale in the CPU cache? Yes, when I/O is non-coherent or ownership rules are violated. Follow the platform's DMA mapping, synchronisation and cache-maintenance primitives rather than inventing a flush sequence. The linked numerical set focuses on alternate GATE-style calculations; this guide places DMA in the broader I/O path. Work through DMA, Interrupts and Programmed I/O for GATE.

Diagram traces device-to-memory DMA from a device FIFO through a controller and system bus to 0x8000-0x8FFF, showing 1,024 beats and one completion interrupt.

Buffering, caching and spooling

How are they different? Buffering absorbs a timing or rate mismatch while data is in transit. Caching keeps a reusable copy to avoid slower access. Spooling queues complete jobs for a serially shared device. Later reuse does not define a buffer.

For audio, 48,000 samples/s x 2 channels x 2 bytes = 192,000 bytes/s. One 20 ms buffer holds 192,000 x 0.020 = 3,840 bytes. With two buffers, the device consumes one while software fills the other. Missing the refill deadline causes an underrun even when average throughput is sufficient.

A print spool holds job A of 12 MiB, then job B of 4 MiB, while one printer drains them serially. A cache retains a repeatedly read disk block. Ask whether the mechanism smooths time, exploits reuse, or serialises queued ownership.

Rapid-fire input output device questions

  • Should a keyboard always use interrupts? Interrupts fit a general-purpose keyboard; polling fits a deterministic embedded loop.

  • Is programmed I/O always bad? No. For tiny, rare transfers, it is the simplest method.

  • What if interrupts outrun the handler? Work grows until coalescing, batching, flow control, backpressure or dropping intervenes.

  • Why not cache device registers like RAM? Side effects, stale values or reordered access can break the protocol.

  • Does DMA make the CPU irrelevant? No. The CPU manages ownership, setup, completion, errors and platform-required cache synchronisation.

A touchscreen is both input and output. A storage device is better explained through its controller, transfer path and access behaviour than a one-word human-I/O label. Use 12 solved Input Output Devices MCQs as a self-check.

The short version: a 60-second answer and next step

Use this path: device endpoint -> controller registers -> programmed I/O, interrupt or DMA -> bus and memory effects -> software completion. Give a one-sentence answer, name the path, state the comparison axis, quantify one cost, then state the relevant architecture assumption.

Study Computer Architecture and Organisation, polish delivery with the Interview & Resume Preparation Course, and browse Placement Preparation & Coding: Exams, Eligibility & Courses. Recheck 1.00%, 3.00%, 0.01%, 65,280 addresses, 1.5 microseconds, 4.2 microseconds and 102.4 microseconds.