Boost logo

Boost Users :

From: Gaier, Bjoern (Bjoern.Gaier_at_[hidden])
Date: 2020-03-17 07:02:08


Hey degski,

sorry for the late reply. Things are kinda stressful here.

In general your idea is good – but in the future I wanted to replace the vector with a list. I just wanted to start easy and wondered if there is a generic solution.

Kind greetings
Björn

From: Boost-users <boost-users-bounces_at_[hidden]> On Behalf Of degski via Boost-users
Sent: 26 February 2020 13:56
To: Boost users list <boost-users_at_[hidden]>
Cc: degski <degski_at_[hidden]>
Subject: Re: [Boost-users] [Newbie][Interprocess] Placing a boost interprocess vector in an existing (not managed) shared memory



On Thu, 13 Feb 2020 at 22:28, Ion Gaztañaga via Boost-users <boost-users_at_[hidden]<mailto:boost-users_at_[hidden]>> wrote:
On 30/01/2020 9:19, Gaier, Bjoern via Boost-users wrote:
> Hello Boost-Mailing-List,
>
> I have a question about the boost interprocess library - and I hope I
> can explain it correctly.
>
> I looked at the "Quick guide for the impatient" about the interprocess
> library - but I'm not sure if I can use this for our purpose.
>
> The main goal is to insert a STL vector (or different container) in a
> predefined portion of an already existing shared memory. The main
> problem is, that we cannot use the managed_shared_memory code from
> boost, because we rely on a different API to allocate the shared memory
> between Windows and other devices. Also the container should be placed
> at a fixed offset inside the created shared memory.
>
> I'm a complete newbie with boost and the interprocess library, that is
> why I'm not sure which interface I have to provide for the interprocess
> vector to be setup correctly. I hoped I could do something like:
>
> new (srh_mem_base + offset) boost::interprocess::vector<allocator>;
>
> I tried looking into the headers of the library to get an idea of that,
> but I honestly got lost.
>
> I'm really sorry if this a stupid or obvious question - and I thank for
> any help in advance!

Unfortunatelly does not going to work. A shared memory vector expects a
shared memory allocator that relies on the segment_manager class.

In the specific case of a vector, wouldn't it be simpler to allocate directly (a wrapper around VM) from Virtual Memory(i.e. without the segment manager, as there don't have to be segments, and there is nothing to manage), and there is nothing to relocate (ever, if you make the virtual reserved space adequately large)?

This is just an idea I've been thinking about (for my own purposes). What would be against this approach?

degski

That
class expects a managed shared memory (or mapped file) that resolves
allocation requests looking for free space in the managed shared memory
segment.

You would need to define a new allocator and managed shared memory (as
you need to handle the allocation requests from the vector) that
fulfills your needs. Not an easy task at all.

For fixed offsets, you'd better avoid Interprocess and use an array or
similar with no dynamic allocations.

Best,

Ion
_______________________________________________
Boost-users mailing list
Boost-users_at_[hidden]<mailto:Boost-users_at_[hidden]>
https://lists.boost.org/mailman/listinfo.cgi/boost-users


--
@realdegski
https://brave.com/google-gdpr-workaround/
"We value your privacy, click here!" Sod off! - degski
"Anyone who believes that exponential growth can go on forever in a finite world is either a madman or an economist" - Kenneth E. Boulding
"Growth for the sake of growth is the ideology of the cancer cell" - Edward P. Abbey
Als GmbH eingetragen im Handelsregister Bad Homburg v.d.H. HRB 9816, USt.ID-Nr. DE 114 165 789 Geschäftsführer: Dr. Hiroshi Nakamura, Dr. Robert Plank, Markus Bode, Heiko Lampert, Takashi Nagano, Takeshi Fukushima. Junichi Tajika



Boost-users list run by williamkempf at hotmail.com, kalb at libertysoft.com, bjorn.karlsson at readsoft.com, gregod at cs.rpi.edu, wekempf at cox.net