What is direct memory access (DMA)?

A direct memory access (DMA) controller is a device within the system that can facilitate data transfer between input/output devices within the system and the main memory without the CPU's intervention. This is done by the operating system, which programs the DMA controller by telling where the data lives on the memory, how much to copy, and which device it should send. As a result, it completely bypasses the CPU and, in turn, lessens the load on the CPU.

Simplified I/O interaction
Simplified I/O interaction

After data transfer between the I/O devices and the memory, the DMA sends an alert to the CPU that tells it that the transfer is done and the CPU can now use the data as required.

Types

Now that we know how the DMA controller works, we will look at how data is moved.

  1. Burst mode: In this mode, the DMA controller first takes control of the system bus to transfer the entire data block in one piece, then returns the control of the bus to the system.

  2. Cycle-stealing ode: In this mode, the DMA controller again takes control of the system bus but transfers data in one-byte increments. After the first piece of data has been transferred, it gives back control of the bus. This loop keeps repeating until the entire block has been transferred. This is especially beneficial for real-time data monitoring systems. (This is also the mode we have used in our explanation below)

  3. Transparent mode: In this mode, the DMA controller only initiates the data transfer when the system bus is free, i.e., the CPU is not using it. This allows the CPU to work uninterrupted and only to transfer data when it is free. This makes the system's performance much faster, but the data transfer time increases inversely.

Explanation

Let us now look at the structure of the DMA controller to see how it performs its job.

DMA structure
DMA structure
  1. The CPU programs the DMA controller by settings its registers. Simultaneously, the CPU tells the disk controller to read the data from the drive and store it in the internal buffer. It does this because DMA can only work with data from the buffer.

  2. Next, the DMA controller's control register will request the disk controller to transfer data to memory.

  3. Afterward, the disk controller will transfer the data to the memory.

  4. After the data transfer, the disk controller will send an acknowledgment to the DMA controller and decrease the (byte) count in its respective register.

  5. If the byte count is not equal to zero, steps 2–4 will be repeated.

  6. If the byte count is zero, an interrupt will be sent to the CPU that informs it that the transfer is done.

CPU process during DMA job
CPU process during DMA job

This way, the DMA controller saves cycles of sending commands and managing data transfer by offloading this job from the CPU. Moreover, a direct link between the memory and I/O devices creates a faster process.

Conclusion

In conclusion, the DMA controller reduces CPU overhead and creates a faster data transfer process, which is particularly beneficial for a large data transfer or time-sensitive operation. Due to these reasons, the DMA controller is a commonly used hardware device in I/O devices for efficient data transfer.

Free Resources

Copyright ©2025 Educative, Inc. All rights reserved