Direct Memory Access (DMA)
|
Differ from Programmed I/O and Interrupt-Driven I/O, Direct Memory Access is a technique for transferring data within main memory and external device without passing it through the CPU. DMA is a way to improve processor activity and I/O transfer rate by taking-over the job of transferring data from processor, and letting the processor to do other tasks. This technique overcomes the drawbacks of other two I/O techniques which are the time consuming process when issuing command for data transfer and tie-up the processor in data transfer while the data processing is neglected. It is more efficient to use DMA method when large volume of data has to be transferred. For DMA to be implemented, processor has to share its’ system bus with the DMA module. Therefore, the DMA module must use the bus only when the processor does not need it, or it must force the processor to suspend operation temporarily. The latter technique is more common to be used and it is referred to as cycle stealing.
Figure 5 shows an add-on DMA module cycles in an Instruction Cycle.
Figure 5 shows an add-on DMA module cycles in an Instruction Cycle.
Basic Operation of DMA
|
|
When the processor wishes read or send a block of data, it issues a command to the DMA module by sending some information to DMA module. The information includes:
|
After the information are sent, the processor continues with other work. The DMA module then transfers the entire block of data directly to or from memory without going through the processor. When the transfer is complete, the DMA module sends an interrupt signal to the processor to inform that it has finish using the system bus.
Configurations of DMA
|
|
DMA mechanism can be configured in a variety of ways, which are:
- Single-bus, detached DMA
- Single-bus, integrated DMA-I/O
- I/O bus
Single-bus, detached DMA
All modules share the same system bus. The DMA module is acting as a surrogate processor, which uses programmed I/O to exchange data between memory and an I/O module through the DMA module. This configuration is inexpensive, but is inefficient. This is because each transfer of a word consumes two bus cycles.
All modules share the same system bus. The DMA module is acting as a surrogate processor, which uses programmed I/O to exchange data between memory and an I/O module through the DMA module. This configuration is inexpensive, but is inefficient. This is because each transfer of a word consumes two bus cycles.
Single-bus, integrated DMA
In this configuration, there is a path between the DMA module and one or more I/O module that does not include the system bus. The DMA logic can be a part of an I/O module, or a separate module that controls one or more I/O modules. Therefore, the number of required bus cycles can be cut substantially. The system bus that the DMA module shares with the processor and memory is used by the DMA module only to exchange data with memory. The exchange of data between the DMA and I/O modules takes place off the system bus.
In this configuration, there is a path between the DMA module and one or more I/O module that does not include the system bus. The DMA logic can be a part of an I/O module, or a separate module that controls one or more I/O modules. Therefore, the number of required bus cycles can be cut substantially. The system bus that the DMA module shares with the processor and memory is used by the DMA module only to exchange data with memory. The exchange of data between the DMA and I/O modules takes place off the system bus.
I/O bus
In this configuration, the concept is further improves from the previous configuration, which is single-bus, integrated DMA. I/O modules are connected to the DMA module using an I/O bus. This can reduce the number of I/O interfaces in the DMA module to one and provides for an easily expandable configuration. The system bus that the DMA module shares with the processor and memory is used by the DMA module only to exchange data with memory. The exchange of data between the DMA and I/O modules takes place off the system bus.
In this configuration, the concept is further improves from the previous configuration, which is single-bus, integrated DMA. I/O modules are connected to the DMA module using an I/O bus. This can reduce the number of I/O interfaces in the DMA module to one and provides for an easily expandable configuration. The system bus that the DMA module shares with the processor and memory is used by the DMA module only to exchange data with memory. The exchange of data between the DMA and I/O modules takes place off the system bus.
Summary Flows of Using DMA by Processor
|
Advantages & Disadvantages of DMA
|
|
Advantages |
-
allows a peripheral device to read from/write to memory without going through
the CPU |
-
allows for faster processing since the processor can be working on
something else while the peripheral can be populating memory |
|
Disadvantages |
-
requires a DMA controller to carry out the operation, which increases
the cost of the system |
-
cache coherence problems |