Menu

Marc, help for two process share memeory

Help
2002-07-26
2002-08-06
  • Nobody/Anonymous

    Marc,

    Do you have exmaple for two unrelated process share the memory through the allocator that you write?

    Thanks,
    J!M

     
    • Marc Bumble

      Marc Bumble - 2002-07-30

      J!M,

      I am working on  this.  If you can access the
      comp.lang.c++.moderated Usenet  group, I have
      tried to start a discussion under the thread
      "Type    or   Value?     Allocator   Template
      Question". I would like  to know if there are
      any  aspects  to   the  problem  I  have  not
      considered  and  whether  the  community  has
      considered the problem already and arrived at
      an acceptable general solution.  I prefer to
      follow convention if one exists.

      Marc

       
    • Nobody/Anonymous

      Marc,

      For two apps A and B, after hacked the shared_memory.cc(with static key), and both of them can attached the same share memory segment. And it raised another issue for me.
      I can not make the second process read the data that written by the first one.

      for example:
      Apps A:
      std::vector<int,allocator_ns::Pool_alloc<int> > w;
      w.push_back(1);
      w.push_back(2);

      apps B:std::vector<int,allocator_ns::Pool_alloc<int> > wb;

      wb can attached the memory that allocated by Apps A, but it can not read the data written by apps A.

      Do you have some example for that(maybe your example of parent fork a child and both of them shared the memory that allocated by parent is fine for me, but from your package I can not find such kind example).

      Maybe I am asking a stupid question, but it blocked me for a while.

      Thanks!
      J!M

       
      • Marc Bumble

        Marc Bumble - 2002-08-06

        J!M,

        I am slowly working on allowing the allocator
        to use a key passed in as a constant template
        parameter.  I think that  a pointer to a char
        is allowed under the C++ Standard (there is a
        ref from Comeau in:
        http://www.comeaucomputing.com/techtalk/templates/#stringliteral                    

        Meanwhile,   you   might   reconsider   using
        allocators at this  point altogether and just
        try using C++'s  idea of Placement and shared
        memory  in  combination.   See  Placement  in
        Strostrup.

        In my original application of this allocator,
        I  believe that  I first  created  the shared
        memory   data  structures.   Then   forked  a
        process.   Both processes  at that  point had
        access to the same shared data structure.  At
        least  that is what  I recall.   Someone else
        hopefully  might  chime   in  with  a  better
        solution.

        I am  actively working on this  issue, but it
        will take some time for an eloquent solution.
        I would  try something other  than allocators
        until then,  unless someone else  has another
        suggestion.  Your  question is not  stupid. I
        think that this issue is tough.

        Marc

         

Log in to post a comment.

Want the latest updates on software, tech news, and AI?
Get latest updates about software, tech news, and AI from SourceForge directly in your inbox once a month.