Issue
My Develop Environment is Android Studio with NDK. Min SDK level is 26 for use NDK shared mem header. https://developer.android.com/ndk/reference/group/memory
I succeed in using shared memory between child and parents. but problem is, I need to make file descriptor before fork()
. Below is how I did it.
- Make File Descriptor(
AsharedMemory_create
) from parents. - fork()
- mmap from child using parents file descriptor. Work some stuff on a buffer.
- mmap from parents for sync and get buffer.
It works fine but it needs to pre-make from parents before the fork. I don't want it. Also, I don't want to use Parcel file descriptor in Java.
I want to make shared memory wherever I want and share with other process But not using pass it. Is there a way for using 'same' shared memory between child and parents? or between different processes (kinds like the child with child)?
I tried make File descriptor that has Same name, Same size in child and parents for shared memory, But it doesn't works. Also tried to make File descriptor and mmap in parents after child did the same thing but it didn't works either even I didn't munmap or close in a child. All I can get is NULL
in parents or other child. is it just impossible?
//========================(11.15.2018 Update)
================================
- Making fd in child and close. Open it from parents (X)
- Making fd in child and sleep. Open it from parents (X)
- Making fd in child and msync. Open it from parents (X)
Solution
I checked many things but it can't achieved. There is no magic solution. If i want to use shared memory that using other process's FD, i need to FD get that via IPC. Also android suggest Unix Domain Socket to pass fd.
Answered By - Js Choi
0 comments:
Post a Comment
Note: Only a member of this blog may post a comment.