Velocity Reviews - Computer Hardware Reviews

Velocity Reviews > Newsgroups > Programming > C++ > Linked List in Shared Memory

Reply
Thread Tools

Linked List in Shared Memory

 
 
C Programmer , MFC
Guest
Posts: n/a
 
      10-05-2009
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
 
Reply With Quote
 
 
 
 
Pascal J. Bourguignon
Guest
Posts: n/a
 
      10-05-2009
"C Programmer , MFC" <(E-Mail Removed)> 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__
 
Reply With Quote
 
 
 
 
Michael Doubez
Guest
Posts: n/a
 
      10-05-2009
On 5 oct, 13:29, "C Programmer , MFC" <(E-Mail Removed)> 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
 
Reply With Quote
 
Chris M. Thomasson
Guest
Posts: n/a
 
      10-06-2009
"Michael Doubez" <(E-Mail Removed)> wrote in message
news:(E-Mail Removed)...
On 5 oct, 13:29, "C Programmer , MFC" <(E-Mail Removed)> 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.

 
Reply With Quote
 
Michael Doubez
Guest
Posts: n/a
 
      10-06-2009
On 6 oct, 05:31, "Chris M. Thomasson" <(E-Mail Removed)> wrote:
> "Michael Doubez" <(E-Mail Removed)> wrote in message
>
> news:(E-Mail Removed)...
> On 5 oct, 13:29, "C Programmer , MFC" <(E-Mail Removed)> 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
 
Reply With Quote
 
 
 
Reply

Thread Tools

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are Off


Similar Threads
Thread Thread Starter Forum Replies Last Post
Linked List in Shared Memory C Programmer , MFC C++ 0 10-05-2009 11:29 AM
Linked list within a linked list joshd C++ 12 10-02-2006 08:57 AM
Linked list, New try (was:Linked list, no out put,help) fool C Programming 14 07-03-2006 12:29 AM
Generating a char* from a linked list of linked lists Chris Ritchey C++ 7 07-10-2003 10:12 PM
Generating a char* from a linked list of linked lists Chris Ritchey C Programming 7 07-10-2003 10:12 PM



Advertisments