Linked List in Shared Memory

  • Thread starter C Programmer , MFC
  • Start date
C

C Programmer , MFC

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
 
P

Pascal J. Bourguignon

C Programmer said:
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.
 
M

Michael Doubez

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

Chris M. Thomasson

I don't know what a satheesh is.
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.
 
M

Michael Doubez

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

Ask a Question

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

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Members online

No members online now.

Forum statistics

Threads
473,768
Messages
2,569,574
Members
45,051
Latest member
CarleyMcCr

Latest Threads

Top