Qt World Summit: Register Today!

Use DMA with Qt

  • Hi Folks,

    can anybody tell me, how can I access the OS's DMA form Qt framework on the most commonly architectures (like Pentium 4, Core Duos, Intel i3/5/7)? I'm designing a system, where I receive data via TCP and / or UDP sockets, and I would like to perform some transformation on that and put it into shared memory to be consumed by another process. As I plan, I have to copy the total amount of data twice that seems to be waste of time.


  • @moravas
    With QSharedMemory you can share the same memory between applications.

  • Hi,
    looks like you need to write a kernel module if you really want to access the kernels DMA structures.

  • @koahnig


    yes, you are right, but what about coping data from the TCP / UDP connection? In this case it would be nice that I can specify a storage place, that is used by the connection to receives frames.


  • @moravas
    There is some information on the internal buffer used by UDP/TCP sockets. UDP relies on the OS as it looks. For TCP you can set the size, but not the location.
    I do not think that it is a good route to read this buffer from different applications at the same time. There are a lot of different handling implications (removing info already read and all those counters).
    Therefore, I would read the sockets with one application and share the data through QSharedMemory. However, you need to write your own management there.
    Finally the question is if it is worth the effort. Certainly it does not make sense to retrieve the same data through Internet several times for applications at the same time. There are a couple of reasons (e.g. throughput limit, but also accounting).
    I faced such situation and simply established a QTcpSocket for retrieving the information from Internet. This application has also a QTcpServer where my applications can hook up to with their sockets. It is essentially a fork of information implemented. Any byte received is copied to an out-going QTcpSocket. The rest is done by OS.
    For small amounts of information this is possible. For vast amounts you will probably kill your machine.

Log in to reply