What is DMA (direct memory access)?
A mechanism that transfers data directly between peripherals and memory without going through the CPU, so the CPU can do other work during large transfers.
Japanese name: DMA(ダイレクトメモリアクセス)
A mechanism that transfers data directly between peripherals and memory without going through the CPU, so the CPU can do other work during large transfers.
Japanese name: DMA(ダイレクトメモリアクセス)
In programmed I/O the CPU moves every word itself with load and store instructions. With direct memory access (DMA), the CPU instead programs a DMA controller, or the device's own DMA engine, with a source, a destination, a length and a trigger, then goes back to other work. The controller takes control of the bus, moves the data and raises a completion interrupt. In a microcontroller, for example, a timer can trigger an ADC conversion at fixed intervals and DMA can store each result into an array, waking the CPU only when the buffer is full.
Network cards and NVMe SSDs use descriptor rings: circular tables in main memory whose entries give a buffer address and length. The CPU fills free descriptors and writes once to a device register, often called a doorbell, to say how far it has written. The device reads the descriptors by DMA, performs the transfers itself and marks finished entries complete. CPU and device thus advance many transfers without waiting for each other, and lists of scattered buffers can be handled in one operation, known as scatter-gather.
On some systems DMA bypasses the CPU caches, so the two views of memory can disagree. Where hardware does not keep them coherent, the driver writes dirty cache lines back to memory before a device reads a buffer, and invalidates the cached range before the CPU reads data a device has written, so stale values are not used. The operating system may also move or swap out ordinary pages at any time, so buffers for DMA are pinned in place; pinned host memory lets a GPU transfer data without an intermediate copy and overlap transfers with computation.
Because DMA reads and writes memory directly, a faulty or malicious device could overwrite kernel data or read encryption keys, a particular concern for devices attached through fast external ports. An IOMMU (input-output memory management unit) does for devices what the MMU does for the CPU: it translates the addresses devices use into physical addresses and blocks access outside the regions the operating system has granted. It also lets scattered physical pages appear contiguous to a device and makes it safe to assign a device directly to a virtual machine.
Answer: B. The CPU only writes addresses and lengths into descriptors and notifies the device, which reads them and carries out the transfers itself
A descriptor ring is a table in main memory, used in a circular way, where each entry says which address to transfer and how many bytes. The CPU fills free descriptors and tells the device once, through a register, how far it has written. The device reads the descriptors by DMA, transfers the data and either marks finished descriptors as complete or writes completions to a separate completion ring (such as an NVMe completion queue). CPU and device can advance many transfers without waiting for each other.
Answer: C. The CPU need not read each result in an interrupt; DMA stores them in memory, reducing CPU load
If the CPU reads each conversion in an interrupt, at tens of thousands of samples per second the overhead of entering and leaving interrupts alone can consume a large share of its time. With DMA, each completed conversion is written in turn into an array in memory, and the CPU is notified only when the array is full. Combined with a timer that triggers conversions, precisely spaced sampling continues without the CPU.
DMA stands for direct memory access, a mechanism that lets peripherals transfer data to and from main memory without the CPU copying each word, so the CPU can do other work during the transfer.
In programmed I/O the CPU reads or writes every data word to the device itself. With DMA the CPU only sets up the transfer and is notified when it finishes, which saves CPU time for large or frequent transfers.
On systems without hardware cache coherence, the CPU's cache may still hold old copies of that memory range. Invalidating it forces the CPU to read the new data the device wrote.
DMA (direct memory access) appears in 7 practice questions across 6 topics, including CPUs and architecture, I/O Interfaces & Buses, Embedded Systems & Firmware.
As an Amazon Associate I earn from qualifying purchases.
This page was drafted with AI and fact-checked by a separate AI review before publication. Our Editorial policy explains how we write and check content. If you spot an error, please tell us on our Contact page.