7.5 Direct Memory Access

COS2621 - Computer Organisation · 7. Input/Output

Direct Memory Access

Overview of Direct Memory Access (DMA)

Direct Memory Access (DMA) is a method that allows certain hardware subsystems to access main system memory independently of the central processing unit (CPU). This enables devices to transfer data to or from memory without involving the CPU, improving system performance.

How DMA Works

In a typical DMA operation, several steps occur:

  1. The CPU initiates the DMA transfer by sending a request to the DMA controller.
  2. The DMA controller takes control of the system bus.
  3. The DMA controller reads data from the source device and writes it to the destination in memory.
  4. Once the transfer is complete, the DMA controller sends an interrupt signal to the CPU to indicate that the operation is finished.

Example of DMA Operation

Consider a scenario where a hard drive needs to transfer a block of data to memory:

  1. The CPU sends a command to the DMA controller to start the transfer.
  2. The DMA controller requests control of the bus.
  3. The DMA controller reads the data from the hard drive.
  4. Data is transferred directly to the specified memory location.
  5. After the transfer, the DMA controller releases the bus and sends an interrupt to the CPU.

Advantages of DMA

  • Efficiency: DMA reduces CPU overhead by allowing data transfers to occur without CPU intervention.
  • Speed: Direct transfers can be faster than programmed I/O, where the CPU must manage each byte.
  • Concurrent Operations: While the DMA controller transfers data, the CPU can execute other instructions.

Disadvantages of DMA

  • Complexity: The DMA controller adds complexity to the system design.
  • Cost: Additional hardware is required, which can increase system costs.

Watch out: Ensure that the DMA controller is properly configured to avoid data corruption or loss during transfers.

Types of DMA

There are two main types of DMA:

  • Burst Mode DMA: The DMA controller transfers a block of data in one go and then relinquishes control of the bus.
  • Cycle Stealing DMA: The DMA controller transfers one byte or word at a time and allows the CPU to use the bus in between transfers.

DMA Controller

The DMA controller is crucial in managing DMA operations. It contains registers that hold the source address, destination address, and the number of bytes to transfer. When the CPU sends a request, the DMA controller takes over the data transfer process.

Summary

  • DMA allows devices to transfer data directly to memory without CPU involvement.
  • It improves system performance by freeing the CPU for other tasks.
  • There are various modes of DMA, including burst mode and cycle stealing.

Check your understanding

  • What is the primary function of a DMA controller?
  • Explain the difference between burst mode DMA and cycle stealing DMA.
  • List two advantages and two disadvantages of using DMA.
  • Describe the steps involved in a DMA transfer operation.

Test yourself

5 quick questions on this lesson. Pick an answer to see if you're right.

  1. 1. Which of the following is an advantage of using DMA?

  2. 2. What is a disadvantage of using DMA?

  3. 3. The __________ module transfers the entire block of data, one word at a time, directly to or from memory

  4. 4. What is the primary function of a DMA controller?

  5. 5. In burst mode DMA, how does the DMA controller operate?