Is there a trade-off for memory to memory DMA transfer when the data size is small?

孤者浪人 提交于 2020-05-16 03:16:24

问题


As my understanding and research, I know that if the data size is small (that is, the device uses DMA to generate or consume a small amount of data), the overhead is increased because DMA transfer requires the DMA controller to perform operations, thereby unnecessarily increasing system cost.

Is that correct and is there any more description to my question?


回答1:


As @Vinci and @P__J__ already pointed out,

  1. A DMA controller works autonomously and doesn't create overhead on the CPU it supplements (at least not by itself). But:

  2. The CPU/software must perform some instructions to configure the DMA and to trigger it or have it triggered by some peripheral. For this, it needs CPU time and program memory space (usually ROM). Besides, it usually needs some additional RAM in variables to manage the software around the DMA.

    Hence, you are right, using a DMA comes with some kinds of overhead.

And furthermore,

  1. The DMA transfers make use of the memory bus(es) that connect the involved memories/registers/peripherals to the DMA controller. That is, while the DMA controller does its own work, it may cause the CPU which it tries to offload to stall in the meantime, at least for short moments when the data words are transferred (which in turn sum up for longer transfers...).

On the other hand, a DMA doesn't only help you to reduce the CPU load (regarding total CPU time to implement some feature). If used "in a smart way", it helps you to reduce software latencies to implement different functions because one part of the implementation can be "hidden" behind the DMA-driven data transfer of another part (unless, both rely on the same bus resources - see above...).



来源:https://stackoverflow.com/questions/61723561/is-there-a-trade-off-for-memory-to-memory-dma-transfer-when-the-data-size-is-sma

标签
易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!