android - SHM replacement based on ASHMEM -
i'm working on library port *nix android, , library uses shared memory or shm
. android not have system v shm
. instead uses ashmem
.
is aware of shim library map shm
calls ashmem
? google has not been helpful.
this how worked me while working similar problem of porting:
instead of using shmfd = open(shm_path, o_rdwr) creating , getting file descriptor replaced with
int fd = ashmem_create_region("sharedregionname", size);
and used file descriptor base address:
int base_address = mmap(null, size, prot_read | prot_write, map_shared, fd, 0);
you can pass base_address java code native code using native function returns descriptor.
android has wrapper class ashmem named memoryfile. can have in that.
the following links helped me create own wrapper:
- http://notjustburritos.tumblr.com/post/21442138796/an-introduction-to-android-shared-memory
- http://grepcode.com/file/repository.grepcode.com/java/ext/com.google.android/android/2.2_r1.1/android/os/memoryfile.java
- https://github.com/cozybit/aosp-frameworks-base/blob/master/core/jni/android_os_memoryfile.cpp
Comments
Post a Comment