Skip to content

Latest commit

 

History

History
 
 

Shared_Memory

Folders and files

NameName
Last commit message
Last commit date

parent directory

..
 
 
 
 
 
 

Shared Memory IPC

So after playing around I found that it Should be possible to use the Shared Memory API, but this is not the route you want. the <android/sharedmem.h> API was designed to share memory between processes like <android/NeuralNetworks.h> where you will call ANeuralNetworksMemory_createFromFd() and the under lying Android NDK will take the file descriptor from there.

To finish this example, which I honestly will probably not do, is to share the file descriptor from the mapped memory of your ASharedMemory_create() call (which is really just a shm_open() call) and send use the Unix Domain Sockets to send the file descriptor to the other process using sendmsg(2) and recvmsg(2). Mainly because the AHardwareBuffer API already does this better

Here are some links if you still want to go this route

The better option

For the example of sending data across two seperate process, I recommend using the <android/hardware_buffer.h> API which came out with Android 8.0 as well with I assume these two purpose in mind... who knows with the NDK :D