4 ms·
There is a third option on the table! Using DMA controller. People say what's the difference in between copying memory by CPU, or by DMA controller? The differ
by baybal2 6y ago
There is a third option on the table! Using DMA controller.
People say what's the difference in between copying memory by CPU, or by DMA controller? The difference is exactly that.
You rarely need that, but in some cases you have:
1. You do very long copies, and want to have full CPU performance.
2. You do very long copies, and want to have caches to not be flushed during it.
3. You care about power consumption, as DMA controller may let the CPU core to enter low power mode quicker.
4. On some CPU architectures, you can get wildly spread out pages quicker than with CPU/software.
- beagle3 6y agoThe DMA needs to cooperate with the MMU which is on the CPU these days (and has been for almost 3 decades now). It's a lot of work to set up DMA correctly given physical<->logical memory mapping - so it's only worth it if you have a really big chunk to copy.
- GeorgeTirebiter 6y agoThis is quite interesting. This, to me, seems like a systems bug. In the Embedded World, it is exceedingly common to use DMA for all high-speed transfers -- it's effectively a specialized parallel hardware 'MOV' instruction. Also, I have never had an occasion on modern PC hw to need mmap; read() lseek() are clean and less complex overall. Maybe I lack imagination.
- astrange 6y agommap is being used by libraries under you; it's useful for files on internal drives, that won't be deleted, and want to be accessed randomly, and you don't want to allocate buffers to copy things out of them. For instance, anytime you call a shared library it's been mmapped by dyld/ld.so.
- __turbobrew__ 6y agoEvery time you run a dynamically linked program on linux the system linker mmaps your program + libraries into memory. You may not personally see mmap used, but it is used quite often in software you use.