Solved

Use of shared memory accross processes ..

Posted on 1999-01-05
2
218 Views
Last Modified: 2013-12-06
I am using shared memory in my application. The shared memory will be accessed by many processes. In the shared memory, I build simple linked lists. Assume that Process A is building this linked list and Process B
will read the linked list at a later point of time.
Consider Process A has built this :
         
            --------------       --------------
           |         |  .--|--->|         |  .--|-----
            --------------       --------------       |
                 Node 1              Node 2           -
                                                      -

My question is will Process B understand the pointer
stored in Node 1 (when it tries to traverse the linked list)? Because that pointer is virtual and
should be understood only by Process A.
0
Comment
Question by:srivatsa_v
[X]
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
2 Comments
 
LVL 84

Expert Comment

by:ozo
ID: 2008643
I'd make the pointers relative to the shared memory block.
0
 
LVL 3

Accepted Solution

by:
elfie earned 100 total points
ID: 2008644
A recommended way of doing is, put all your 'pointers' in a struct at the beginning of the shared memory. Then when building the shared memory, put the offset to the  start of the shared memory inside this struct.

Then for each program working with this shared memory you have to create a local copy inside your program that will contain the real pointers. Once connected to the shared memery you know the starting address of the SM. Then fill up your local copy of the struct of pointers.

When you're only workiing  on HP-UX you can put the pointers inside the shared memory, as the shared memory will have the same starting for all connecting programs.
When working on other platforms, the SM can received different addresses depending on the size(data/code) of the connect program. So for these OS's it needed that you have a local copy of the pointers.

So the most generic way is add a header to your SM, that contains the offset to each part inside the SM, and when connecting to the SM, fill a local struct with pointers, adding the offset the start address of the SM
0

Featured Post

Industry Leaders: We Want Your Opinion!

We value your feedback.

Take our survey and automatically be enter to win anyone of the following:
Yeti Cooler, Amazon eGift Card, and Movie eGift Card!

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

Suggested Solutions

Installing FreeBSD… FreeBSD is a darling of an operating system. The stability and usability make it a clear choice for servers and desktops (for the cunning). Savvy?  The Ports collection makes available every popular FOSS application and packag…
I have been running these systems for a few years now and I am just very happy with them.   I just wanted to share the manual that I have created for upgrades and other things.  Oooh yes! FreeBSD makes me happy (as a server), no maintenance and I al…
Learn several ways to interact with files and get file information from the bash shell. ls lists the contents of a directory: Using the -a flag displays hidden files: Using the -l flag formats the output in a long list: The file command gives us mor…
Learn how to navigate the file tree with the shell. Use pwd to print the current working directory: Use ls to list a directory's contents: Use cd to change to a new directory: Use wildcards instead of typing out long directory names: Use ../ to move…

738 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question