Dave,
Thanks, I wrote a program(running as a server) which allocates ashmem
by MemoryHeapBase, from your advice. There are also clients as well to
get shared memory segments from the server through binder. In my
program, MemoryHeapBase objects were created several times and I just
found their file descriptor were same. Does ashmem_create_region()
apply just once per one thread? I thoguht fd is unique just inside
same context. Is ashmem fd system-wide?
On Feb 24, 7:14 pm, Dave Sparks <
davidspa...@android.com> wrote:
> For security reasons, you cannot access shared memory by name. You
> pass a file descriptor through the binder interface. See the IMemory
> implementations for examples of howashmemis used.
>
> On Feb 24, 6:34 pm, sienna <
copil...@gmail.com> wrote:
>
>
>
> > Hello,
>
> > I'm trying to create a shared memory region which is shared between
> > processes. Since shmget() and shm_open() are not implemented,ashmem
> > and mmap looks good for this purpose, like below :
>
> > fd = ashmem_create_region("my_shm_region", size);
> > if(fd < 0)
> > return -1;
>
> > data = mmap(NULL, size, PROT_READ | PROT_WRITE, MAP_SHARED, fd,
> > 0);
> > if(data == MAP_FAILED)
> > goto out;
>
> > What I'm wondering is how other processes find out the named memory
> > block. I have looked at the ashmem_create_region() but it always
> > returns fd of /dev/ashmem, regardless of the name of segment
> > (my_shm_region). What if more than two processes have shared segments
> > at the same time. Plus, there's only region creation function, but not
> > segment opening function, which is unlike shm_open. How can other
> > processes access same segment with the same name? Is there a user
> > lever function to open the existed segment?
>
> > Even if the name is 'anonymous' but it is described as it can be
> > shared between processes. I'd like to know how to.. Thank you.
>
> > Sienna- Hide quoted text -
>
> - Show quoted text -