Linked List in Shared Memory

Discussion in 'C++' started by C Programmer , MFC, Oct 5, 2009.

  1. Hi,
    I am Satheesh asking a question
    how can i implement a LinkedList (singly/doubly) in a Shared Memory in
    C++.
    Bcse In interprocess communication 2/more process can share the add/
    delete/update the values in the object in the Linkedlist via
    pointer's.how can i achieve this.


    Plz Give me an example.
    Regards
    Satheesh.S
     
    C Programmer , MFC, Oct 5, 2009
    #1
    1. Advertising

  2. "C Programmer , MFC" <> writes:
    > I am Satheesh asking a question
    > how can i implement a LinkedList (singly/doubly) in a Shared Memory in
    > C++.


    Carefully.


    > Bcse In interprocess communication 2/more process can share the add/
    > delete/update the values in the object in the Linkedlist via
    > pointer's.how can i achieve this.


    Basically, you would use a lock or semaphore to prevent two processes
    to access the data at the same time.

    Unfortunately, this is not strictly a C++ question, but mostly an OS
    question. Determine on what OS you're working, and go ask how to do
    on the relevant newsgroup.

    You might be able to find a portable C++ library to let you do that,
    but I don't know of any. The portable C++ IPC libraries I know are
    all more directed to network programming rather than shared memory
    IPC.


    --
    __Pascal Bourguignon__
     
    Pascal J. Bourguignon, Oct 5, 2009
    #2
    1. Advertising

  3. On 5 oct, 13:29, "C Programmer , MFC" <> wrote:
    > Hi,
    >        I am Satheesh asking a question


    I don't know what a satheesh is.

    > how can i implement a LinkedList (singly/doubly) in a Shared Memory in
    > C++.
    > Bcse In interprocess communication 2/more process can share the add/
    > delete/update the values in the object in the Linkedlist via
    > pointer's.how can i achieve this.


    Boost has an interprocess module that implemtents the standard
    containers in shared memory. You can look them up.

    The trick is to work in a contiguous memory area using offsets instead
    of pointers.

    --
    Michael
     
    Michael Doubez, Oct 5, 2009
    #3
  4. "Michael Doubez" <> wrote in message
    news:...
    On 5 oct, 13:29, "C Programmer , MFC" <> wrote:
    > > Hi,
    > > I am Satheesh asking a question


    > I don't know what a satheesh is.


    > > how can i implement a LinkedList (singly/doubly) in a Shared Memory in
    > > C++.
    > > Bcse In interprocess communication 2/more process can share the add/
    > > delete/update the values in the object in the Linkedlist via
    > > pointer's.how can i achieve this.


    > Boost has an interprocess module that implemtents the standard
    > containers in shared memory. You can look them up.


    How does the interprocess module handle the scenario in which a process dies
    while it is manipulating a STL container's state? It is based on
    transactions?




    > The trick is to work in a contiguous memory area using offsets instead
    > of pointers.


    Indeed this approach does cover the most bases; I recommend it as well.
    Although, one can certainly use pointer values if the address space for each
    interested process will always be mapped from a _common_ base address.
     
    Chris M. Thomasson, Oct 6, 2009
    #4
  5. On 6 oct, 05:31, "Chris M. Thomasson" <> wrote:
    > "Michael Doubez" <> wrote in message
    >
    > news:...
    > On 5 oct, 13:29, "C Programmer , MFC" <> wrote:
    >
    > > > Hi,
    > > > I am Satheesh asking a question

    > > I don't know what a satheesh is.
    > > > how can i implement a LinkedList (singly/doubly) in a Shared Memory in
    > > > C++.
    > > > Bcse In interprocess communication 2/more process can share the add/
    > > > delete/update the values in the object in the Linkedlist via
    > > > pointer's.how can i achieve this.

    > > Boost has an interprocess module that implemtents the standard
    > > containers in shared memory. You can look them up.

    >
    > How does the interprocess module handle the scenario in which a process dies
    > while it is manipulating a STL container's state? It is based on
    > transactions?


    I don't know but I think not. However, if a program crashes on a
    shared data, it certainly holds a semaphore it has not released and
    nobody can access the data.

    Short of a transaction based system as you mentioned, there is no easy
    solution.

    > > The trick is to work in a contiguous memory area using offsets instead
    > > of pointers.

    >
    > Indeed this approach does cover the most bases; I recommend it as well.
    > Although, one can certainly use pointer values if the address space for each
    > interested process will always be mapped from a _common_ base address.


    It look hazardous; even using address base out of normal range, the
    system can return an error for a reason of its own.

    The Boost.interprocess details the restrictions on the usage of shared
    memory.
    I have also found the doc in pdf format:
    http://boost.cowic.de/rc/pdf/interprocess.pdf

    --
    Michael
     
    Michael Doubez, Oct 6, 2009
    #5
    1. Advertising

Want to reply to this thread or ask your own question?

It takes just 2 minutes to sign up (and it's free!). Just click the sign up button to choose a username and then you can ask your own questions on the forum.
Similar Threads
  1. Chris Ritchey
    Replies:
    7
    Views:
    491
    emerth
    Jul 10, 2003
  2. Chris Ritchey

    Generating a char* from a linked list of linked lists

    Chris Ritchey, Jul 9, 2003, in forum: C Programming
    Replies:
    7
    Views:
    487
    emerth
    Jul 10, 2003
  3. fool
    Replies:
    14
    Views:
    525
    Barry Schwarz
    Jul 3, 2006
  4. joshd
    Replies:
    12
    Views:
    683
    John Carson
    Oct 2, 2006
  5. C Programmer , MFC

    Linked List in Shared Memory

    C Programmer , MFC, Oct 5, 2009, in forum: C++
    Replies:
    0
    Views:
    359
    C Programmer , MFC
    Oct 5, 2009
Loading...

Share This Page