Re: Placement into shared memory?

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

 



>>>>> "Niko" == Niko Matsakis <niko@xxxxxxxxxxxx> 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
application.

    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
STL.  

Thanks for your suggestions,

Marc


-- 
Marc Ronell, PhD CSE, PE EE



[Index of Archives]     [Linux C Programming]     [Linux Kernel]     [eCos]     [Fedora Development]     [Fedora Announce]     [Autoconf]     [The DWARVES Debugging Tools]     [Yosemite Campsites]     [Yosemite News]     [Linux GCC]

  Powered by Linux