You are viewing a plain text version of this content. The canonical link for it is here.
Posted to dev@apr.apache.org by Manfred Rebentisch <mr...@comparat.de> on 2007/06/15 09:23:58 UTC
SHM / RMM pointer values
Hello,
I want to store an object to shared memory (created with apr_shm_create). For
example the structure is:
struct mystr {
struct mystr* next;
char* data;
size_t dsize;
};
struct mystr* obj;
If I allocate SHM for the object, I can attached from another process to the
object. But the members of the object (SHM allocations too) have pointers
from creation process.
The process, which attached the SHM get another pointer value (using
apr_rmm_init too).
Is there any trick to get the same pointer values, the same value in
different processes?
Thank you for an idea.
Manfred
Re: SHM / RMM pointer values
Posted by "William A. Rowe, Jr." <wr...@apache.org>.
Exactly. Good call Peter.
The bottom line - shim pointers need to be apr_size_t indexes into
the defined SHM segment.
Peter Samuelson wrote:
> [Manfred Rebentisch]
>> struct mystr {
>> struct mystr* next;
>> char* data;
>> size_t dsize;
>> };
>
> I'm pretty sure you can't portably implement shared memory mapped to a
> fixed base address in all processes. Thus pointers simply _cannot_ be
> shared as pointers, you need to make them size_t values relative to the
> shm segment base address, or something.
>
> On many systems you can _request_ that a shm segment be mapped to a
> particular address, but the OS may or may not be able (and willing) to
> honor that. And on other systems you can't even do that. So apr
> doesn't support that feature.
Re: SHM / RMM pointer values
Posted by Peter Samuelson <pe...@p12n.org>.
[Manfred Rebentisch]
> struct mystr {
> struct mystr* next;
> char* data;
> size_t dsize;
> };
I'm pretty sure you can't portably implement shared memory mapped to a
fixed base address in all processes. Thus pointers simply _cannot_ be
shared as pointers, you need to make them size_t values relative to the
shm segment base address, or something.
On many systems you can _request_ that a shm segment be mapped to a
particular address, but the OS may or may not be able (and willing) to
honor that. And on other systems you can't even do that. So apr
doesn't support that feature.
--
Peter Samuelson | org-tld!p12n!peter | http://p12n.org/