Boost logo

Boost :

Subject: Re: [boost] Need help >> Boost's managed_shared_memory usage in between two processes (C and C++)
From: Ion Gaztañaga (igaztanaga_at_[hidden])
Date: 2017-10-09 22:08:52


On 09/10/2017 7:27, vijay sharma via Boost wrote:
> Thanks Ion,
>
> So as per your suggestion I am planning:
> 1) Get the handle on application 1 and pass it to application 2.
> 2) Application 2 (a C-lang process) do shm_open with same SHM name. mmap
> will give me pointer to start.
> 3) Using [ (char *) cast on mmap's void pointer ] and [ Increment by
> <handle> ] I will reach to actual data in shm and them read it by memcpy.
>
> *This is looking possible to me. Do you this this will work??*

I haven't tested myself, but it should be close. I can't remember if the
offset is exactly from the start of the mapped region.

> I have a small doubt here :
> 1) Handle are like offset, please correct me if I am wrong. Even I am
> inserting first element in SHM still it's coming as very high value. Why is
> it like this ??
> Is it because we are using Tree (memory allocation) in boost shared memory ?
> OR we always start allocation from bottom of SHM ?

Yes, the handle is the offset between the address of the buffer and the
start of the shared memory and the allocation is based on an intrusive
red-black tree.

Best,

Ion


Boost list run by bdawes at acm.org, gregod at cs.rpi.edu, cpdaniel at pacbell.net, john at johnmaddock.co.uk