Solved

Use of shared memory accross processes ..

Posted on 1999-01-05
2
226 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

Optimize your web performance

What's in the eBook?
- Full list of reasons for poor performance
- Ultimate measures to speed things up
- Primary web monitoring types
- KPIs you should be monitoring in order to increase your ROI

Question has a verified solution.

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

Hello fellow BSD lovers, I've created a patch process for patching openjdk6 for BSD (FreeBSD specifically), although I tried to keep all BSD versions in mind when creating my patch. Welcome to OpenJDK6 on BSD First let me start with a little …
I promised to write further about my project, and here I am.  First, I needed to setup the Primary Server.  You can read how in this article: Setup FreeBSD Server with full HDD encryption (http://www.experts-exchange.com/OS/Unix/BSD/FreeBSD/A_3660-S…
Learn how to get help with Linux/Unix bash shell commands. Use help to read help documents for built in bash shell commands.: Use man to interface with the online reference manuals for shell commands.: Use man to search man pages for unknown command…
This video shows how to set up a shell script to accept a positional parameter when called, pass that to a SQL script, accept the output from the statement back and then manipulate it in the Shell.
Suggested Courses

635 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