c - How to use Shared Memory (IPC) in Android -
i've written simple shared memory c program in linux.
how can use shared memory (or should call "ashmem?") in android?
hope can give me step-by-step guide.
here worked me:
1) open memoryfile object: mfile;
2) create service map ashem using mmap;
3) return native file descriptor (fd) client binds service using parcelfiledescriptor pfd;
4) create jni client takes fd , map ashes using mmap;
5) create inputstream using fd , client can read/write same memory area using inputstream object.
link shows how map memoryfile ashem. link shows how send native file descriptor (fd) client through aidl , parcelfiledescriptor client.
on server side, need create:
1) service & aidl passes native fd client through parcelfiledescriptor; 2) jni on service side mapping.
on client: 1) methods bind service , call service native fd; 2) jni maps fd ashem.
the mapped memory region can read/write service & client.
Comments
Post a Comment