Shared Memory and Distributed Objects
Shared Memory and Distributed Objects
- Subject: Shared Memory and Distributed Objects
- From: Dan Bernstein <cocoa-dev%email@hidden>
- Date: Sun, 16 Feb 2003 13:37:13 +0200
Hi,
I'm taking my first steps with distributed objects, and I'm looking for
an *efficient* way to make a large (~1MB) area of one process's memory
available to a second process for reading. Here's what I've tried so
far:
1. Using a shared memory object, opened with shm_open() and mapped with
mmap().
Problem: no matter what I did, I couldn't get mmap() to accept the fd
shm_open() had returned.
2. Using a shared memory area obtained with shmget() and mapped with
shmat().
Problems: a. shmget() didn't work with large values of size. I don't
want to separate the memory into chunks.
b. How am I supposed to pick a value for key? Try a random value and
hope it's free?
It would be even better if I could wrap my memory in an NSData and vend
it, however I'm concerned that this is implemented in such a (clever)
way that even though the entire area of memory isn't copied as soon as
the object is vended, whenever the vending process writes to the area
afterwards the relevant memory page is duplicated and the writing
appears only in that process's space, so that the client keeps seeing
the memory as it was at the time the NSData was vended.
Is there a way to do what I want using DOs? If not, can the problems in
1. or 2. above be overcome?
Many thanks in advance,
-- Dan Bernstein
_______________________________________________
cocoa-dev mailing list | email@hidden
Help/Unsubscribe/Archives:
http://www.lists.apple.com/mailman/listinfo/cocoa-dev
Do not post admin requests to the list. They will be ignored.