Asynchronous memcpy on linux?

Is there any asynchronous memcpy function in linux? I want him to work with DMA and notify me when it is complete.

+7
c linux dma
source share
3 answers

As far as I know, the CPU does not / cannot perform DMA on its own. Therefore, you need external equipment on the bus to do the trick for you.

However, most hardware cannot address all physical memory, so an exact memcpy clone is not possible unless you have very strict definitions of ranges of memory addresses in your use case. Otherwise, the kernel would have to memcpy block its own memory block, which would kill the memcpy clone target first :)

But if you want to create a β€œclone” of the memory block without using memcpy (still a bad idea, since access to DMA memory is usually slower than that of the processor), you can send the memory block to the video card and return it to another buffer. You can even place the block in the video memory (putbitmap ()? :)) and perform hardware acceleration bitblt () to create a copy on the fly.

Do you mind sharing your actual goal so that maybe people can come up with smart / better tricks?

+7
source share

In a multi-core processor or even just a hyper-threading processor, you can have what you want by executing a regular (synchronous) memcpy in a separate thread. I'm not saying this is a good idea, just pointing out the obvious.

+3
source share

You can do some games with mremap. Or you can hack FFmpeg to use different buffers for different frames.

+1
source share

All Articles