Solved

Use of shared memory accross processes ..

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

Highfive Gives IT Their Time Back

Highfive is so simple that setting up every meeting room takes just minutes and every employee will be able to start or join a call from any room with ease. Never be called into a meeting just to get it started again. This is how video conferencing should work!

Join & Write a Comment

Using libpcap/Jpcap to capture and send packets on Solaris version (10/11) Library used: 1.      Libpcap (http://www.tcpdump.org) Version 1.2 2.      Jpcap(http://netresearch.ics.uci.edu/kfujii/Jpcap/doc/index.html) Version 0.6 Prerequisite: 1.      GCC …
FreeBSD on EC2 FreeBSD (https://www.freebsd.org) is a robust Unix-like operating system that has been around for many years. FreeBSD is available on Amazon EC2 through Amazon Machine Images (AMIs) provided by FreeBSD developer and security office…
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…
In a previous video, we went over how to export a DynamoDB table into Amazon S3.  In this video, we show how to load the export from S3 into a DynamoDB table.

707 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

Need Help in Real-Time?

Connect with top rated Experts

19 Experts available now in Live!

Get 1:1 Help Now