Lably
Skip to content

Direct memory access

Feature of computer systems

  • 15 min read
  • 6 chapters

Related on Lably

Through Multi-core processor and Word (computer architecture)

Without DMA, programmed input–output must be used to transfer data which typically fully occupies the CPU for the entire duration of the transfer, and is thus unavailable to perform other work. With DMA, the CPU first initiates the transfer, then it does other operations while the transfer is in progress, and it finally receives an interrupt from the direct memory access controller (DMAC) when the operation is done. This feature is useful at any time that the CPU cannot keep up with the rate of data transfer, or when the CPU needs to perform work while waiting for a relatively slow data transfer.

Many hardware systems use DMA, including disk drive controllers, graphics cards, network cards, sound cards and dedicated DMA controllers (acting on behalf of the aforementioned device types). DMA is also used for intra-chip data transfer in some multi-core processors. Computers that have DMA capability can transfer data to and from devices with much less CPU overhead than computers without DMA.

DMA can also be used for memory-to-memory transfers. DMA can offload expensive memory operations, such as large copies or scatter-gather operations, from the CPU to a DMA controller. An implementation example is the I/O Acceleration Technology. DMA is of interest in network-on-chip and in-memory computing architectures.

While hardware acceleration is usually vendor-specific, direct memory access can be used by the class driver.

Principles

Third-party

Standard DMA, also called third-party DMA, uses a DMA controller. A DMA controller can generate memory addresses and initiate memory read or write cycles. It contains several hardware registers that can be written and read by the CPU. These include a memory address register, a count register, and one or more control registers. Depending on what features the DMA controller provides, these control registers might specify some combination of the source, the destination, the direction of the transfer (reading from the I/O device or writing to the I/O device).

To carry out an input, output or memory-to-memory operation, the host processor initializes the DMA controller with a count of the number of words to transfer, and the memory address to use. The CPU then commands the peripheral device to initiate a data transfer. The DMA controller then provides addresses and read/write control lines to the system memory. Each time a byte of data is ready to be transferred between the peripheral device and memory, the DMA controller increments its internal address register until the full block of data is transferred.

Bus mastering

In a bus mastering system, also known as a first-party DMA system, the CPU and peripherals can each be granted control of the memory bus. Where a peripheral can become a bus master, it can directly write to system memory without the involvement of the CPU, providing memory address and control signals as required. Some measures must be provided to put the processor into a hold condition so that bus contention does not occur. The peripheral itself may have hardware registers, such as address and count registers, to control the DMA operation.

Sign in to keep reading

5 more chapters are free with a Lably account.

More in Computing and communication