OS

Direct Memory Access (DMA)

Direct Memory Access (DMA) is a technique for optimizing I/O operations, offering improved efficiency compared to programmed I/O and interrupt-driven I/O.

The DMA unit is capable of mimicking the processor and, indeed, of taking over control of the system bus just like a processor. It needs to do this to transfer data to and from memory over the system bus.

  • Processor delegates I/O operation to the DMA
  • DMA module transfers data directly to or from memory
  • When transfer is complete, DMA module sends an interrupt signal to the processor

When the processor wishes to read or write a block of data, it issues a command to the DMA module by sending to the DMA module the following information:

  •  Whether a read or write is requested, using the read or write control line be- tween the processor and the DMA module
  •  The address of the I/O device involved, communicated on the data lines
  •  The starting location in memory to read from or write to, communicated on the data lines and stored by the DMA module in its address register
  •  The number of words to be read or written, again communicated via the data lines and stored in the data count register

Different configurations possible:

  • In the first example, all modules share the same system bus.
    • DMA module, acting as a surrogate processor, uses programmed I/O to exchange data between memory and an I/O module through the DMA module.
    • This configuration, while it may be inexpensive, is clearly inefficient:
      • Each transfer of a word consumes two bus cycles
  • The DMA logic may actually be a part of an I/O module, or it may be a separate module that controls one or more I/O modules. This concept can be taken one step further by connecting I/O modules to the DMA module using an I/O bus
    • Reduces the number of I/O interfaces in the DMA module to one
    • Provides for an easily expandable configuration.

The exchange of data between the DMA and I/O modules takes place off the system bus.

Programmed I/O involves the processor actively checking the status of an I/O module, causing system performance degradation. Interrupt-driven I/O allows the processor to perform other tasks while waiting for an I/O module to signal readiness, but data transfer still relies on processor intervention.

How DMA works

In contrast, DMA delegates the I/O operation to a separate DMA module. When the processor initiates a read or write operation, it sends relevant information (operation type, I/O device address, memory start location, and word count) to the DMA module. The processor then continues its work, while the DMA module independently transfers the entire data block directly to or from memory without involving the processor. Once the transfer is complete, an interrupt signal is sent to the processor, minimizing its involvement to the start and end of the operation.

While DMA is more efficient for large data transfers, it may temporarily compete with the processor for bus usage, causing the processor to slow down during DMA transfers. Despite this drawback, DMA remains significantly more efficient than interrupt-driven or programmed I/O for multiple-word I/O transfers.