A topic in the Open Knowledge Graph — a free, open map of 15,290 topics and the order to learn them in.

Interrupts and Direct Memory Access (DMA)

College Depth 96 in the knowledge graph ☐ I know this ☆ Set as goal
38topics build on this
362prerequisites beneath it
See this on the map →
I/O Systems and BusesCPU Control Unit→→Device Drivers and I/O ControllersDirect Memory Access (DMA) Controllers and Design+4 more
interrupts DMA interrupt-handler polling IO

Core Idea

An interrupt is a hardware signal that causes the CPU to suspend the current program, save its state, and execute an interrupt service routine (ISR) to handle a device event. Interrupts are far more efficient than polling (repeatedly checking device status), freeing the CPU for other work between I/O events. Direct Memory Access (DMA) allows a specialized controller to transfer large data blocks directly between a device and memory without per-byte CPU involvement, generating a single interrupt on completion. Together, interrupts and DMA form the foundation of efficient I/O in operating systems.

How It's Best Learned

Trace the full interrupt handling cycle: device signals interrupt → CPU saves PC and registers → ISR executes → context restored. Compare polling, interrupt-driven, and DMA-based I/O for a disk read operation in terms of CPU utilization and latency.

Common Misconceptions

Explainer

From your study of I/O systems, you know that the CPU must somehow communicate with external devices — disks, keyboards, network cards. The simplest approach is polling: the CPU repeatedly checks a device's status register in a tight loop, asking "are you ready yet?" This works, but it is enormously wasteful. Imagine standing at your front door checking every second whether a package has arrived, unable to do anything else. Interrupts solve this problem by inverting the relationship: the device notifies the CPU when it needs attention, freeing the processor to execute other instructions in the meantime.

When a device raises an interrupt, it sends an electrical signal to the CPU's interrupt pin. The CPU finishes its current instruction, saves the program counter and key registers onto a stack (so it can return later), and jumps to a pre-defined interrupt service routine (ISR) — a small handler written specifically for that device. The ISR does whatever the device needs (reads a byte from a keyboard buffer, acknowledges a completed disk transfer), then executes a "return from interrupt" instruction that restores the saved state and resumes the original program exactly where it left off. The entire process is transparent to the interrupted program. This is why your understanding of the control unit matters: it is the control unit that orchestrates the save-jump-restore sequence.

There is an important distinction between interrupts and exceptions. Interrupts are asynchronous — they arrive from external hardware at unpredictable times, unrelated to the instruction currently executing. Exceptions are synchronous — they are triggered by the instruction itself (a divide-by-zero, an invalid opcode, a page fault). Both use similar handler mechanisms, but their causes and timing are fundamentally different.

Even with interrupts, transferring large blocks of data byte-by-byte through the CPU is inefficient. Consider reading a 4 KB block from disk: with interrupt-driven I/O, the CPU would handle 4,096 separate interrupts, each copying one byte. Direct Memory Access (DMA) eliminates this bottleneck by offloading bulk transfers to a dedicated DMA controller. The CPU sets up the transfer by telling the DMA controller the source address, destination address, and byte count, then goes back to running programs. The DMA controller takes over the memory bus, moves the data directly between the device and RAM, and generates a single interrupt when the entire transfer is complete. The CPU's involvement drops from thousands of interrupts to one setup operation and one completion interrupt. The tradeoff is that the DMA controller and CPU must share the memory bus — a technique called cycle stealing — so there is some minor slowdown of CPU memory accesses during the transfer, but the net efficiency gain is dramatic.

Practice Questions 5 questions

Prerequisite Chain

Understanding Zero → The Number Zero → Counting to Five → Counting to 10 → Counting to 20 → Counting a Set of Objects Up to 20 → Cardinality: The Last Number Counted → Matching Numerals to Quantities → Subitizing Small Quantities → Addition Within 10 → Number Bonds to 10 → Addition Within 20 → Doubles and Near Doubles → Doubles Facts Within 10 → Near Doubles Facts Within 20 → Mental Math Strategies for Addition → Mental Math: Adding and Subtracting Tens → Addition Within 100 → Repeated Addition as Multiplication → Multiplication as Equal Groups → Multiplication: Arrays → Basic Multiplication Facts (0s, 1s, 2s, 5s, 10s) → Multiplication Facts Within 100 → Division as Equal Sharing → Division as Grouping (Measurement Division) → Division: Grouping (Repeated Subtraction) Model → Division: Fair Sharing Model → Division as Equal Sharing → Division as Grouping → Basic Division Facts → Division Facts Within 100 → Multiplication and Division Fact Families → Relationship Between Multiplication and Division → Division Facts as Inverse of Multiplication → Remainders and Quotients in Division → Division Word Problems → Multi-Step Word Problems → Solving Multi-Step Word Problems → Multiplication Word Problems → Division Word Problems → Introduction to Long Division → Factors and Multiples → Prime and Composite Numbers → Equivalent Fractions → Relating Fractions and Decimals → Decimal Place Value → Integers and the Number Line → Comparing and Ordering Integers → Absolute Value → Adding Integers → Subtracting Integers → Multiplying Integers → Introduction to Exponents → Order of Operations → Integer Order of Operations → Variable Expressions → The Distributive Property → Variables and Expressions Review → Introduction to Polynomials → Adding and Subtracting Polynomials → Multiplying Polynomials → Factorial → Permutations → Combinations → Counting Principles: Addition and Multiplication Rules → Introduction to Graph Theory → Propositional Logic Foundations → Logical Equivalences → Boolean Algebra → Boolean Type and Truth Values → Comparison Operators and Boolean Tests → Logical Operators and Boolean Algebra → Boolean Algebra and Fundamental Laws → Logic Gates Fundamentals → Implementing Boolean Functions with Gates → Karnaugh Map Simplification → Combinational Circuit Design → Flip-Flops and Latches → Binary Counters: Design and Analysis → Binary Arithmetic → Fixed-Point Number Representation → Two's Complement Representation → Overflow and Underflow Detection → Binary Adders: Half-Adders and Full-Adders → Full Adder and Carry Propagation → Carry Lookahead Adder Design → Half Adder Circuit Design → Multiplication Circuit Design → Sequential Circuit Design → Registers and Register Files → Instruction Set Architecture (ISA) → Assembly Language Basics → Memory Organization and Addressing → Memory Address Decoding → Memory Bus Architecture and Interconnect → I/O Systems and Buses → Interrupts and Direct Memory Access (DMA)

Longest path: 97 steps · 362 total prerequisite topics

Prerequisites (2)

Leads To (6)