This is the mail archive of the mailing list for the GCC project.

Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]
Other format: [Raw text]

Re: Placement into shared memory?

>>>>> "Niko" == Niko Matsakis <> writes:

    >> What is the current correct approach to instantiating objects
    >> in shared memory so that multiple processes can access the C++
    >> objects?

    Niko> I don't know the answer to your question.  However, I am
    Niko> wondering, are your two processes executing the same
    Niko> executable?

    Niko> I'm sure you're assumption is correct: the C++ object
    Niko> contains pointers to its virtual table (if it has virtual
    Niko> functions).

    Niko> My guess is that if you running the same executable, and
    Niko> you're having problems, then the virtual dispatch tables are
    Niko> dynamically allocated and you're screwed unless there is
    Niko> some magic g++ option I don't know about.

My goal  is to run separate  executables which both  access objects in
shared memory.   Stroustrup's 3rd  Edition implies that  shared memory
allocators for C++  are possible in Sect. 19.4.  I  have had this type
of mechanism  running with earlier  gcc/g++ versions.  I am  still not
sure  that  I  am  not  simply  making some  type  of  mistake  in  my

    Niko> However, you could also work around this by using function
    Niko> pointers stored in the class instances (if you are using the
    Niko> same executable in which case I *think* the functions would
    Niko> be loaded at the same spots in the two processes memory
    Niko> space), or, more robustly, indexes into a table of function
    Niko> pointers shared by the two processes.

I am  working toward an upgrade  of a shared memory  allocator for the

Thanks for your suggestions,


Marc Ronell, PhD CSE, PE EE

Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]