Direct Memory Access is an infrsatructure used for communications between CPU memory and hardware. The advantage of it over regular IO is, while using DMA, CPU is mostly not a part of the communication and thus the transfer is not consuming much CPU cycles. That changes focus of the CPU cycles away from IO operations, effectively raising throughput of both processor and the IO transfer.
An Example of DMA
For example, modern ethernet modules are used over it. NIC cards were used over regular CPU IO before usage of DMA. So, in order to get a decent connection, you’ve needed to dedicate one of the CPU cores just for this job. Also, your connection was limited to your CPU performance, rather than your peripheral’s physical limitations. But now, CPU allocates a DMA channel for the NIC card on memory, effectively freeing a CPU core and move limitation to the ethernet module. CPU is almost completely bypassed through communication.
How Does DMA Work?
So how does DMA works? This is how:
- A need for data transfer to/from memory rises
- The transfer request is passed to the CPU, including transfer meta-data(payload length, source and destination info, etc.).
- CPU instructs DMA to perform the requested data transfer.
- Processor gets interrupted when the transfer is over.
- Processor unit either closes the channel, or passes a new instruction to it, depending on the circumstances.
As seen, CPU is only started and finished the transfer, leaving a lot of free time to focus on different tasks.
How many Direct Memory Access Channels Can I Have?
According to this resource, x86 CPU’s by default include 8 DMA channels, with a possibility of extension to 14.
So, this is all. That’s Direct Memory Access and how it works. See more on my homepage. See y’all on different posts of mine!