We help IT Professionals succeed at work.

Shared Memory (Ansi C- Sco Unix), shmat address

vangel
vangel asked
on
I have a clients - server setup that are both attaching to a shared memory segment created by the server.
If I use shmat on the clients process, using ofcourse the same shmid, shmat is returning a differnce
address than the server one.
e.g Server address=80C00000 and client address=81000000
Comment
Watch Question

Commented:
It's not that unexpected. By using shared memory, the OS maps a portion of memory into each process' data space. The place in the process's data space that the memory is mapped into may be different. The data at a given offset to the address returned is the same.

Example:

Assume we have a shared memory segment that is four bytes long, and the contents of the memory are 0x01020304.

On the server process, the value at address 80c00001 should be 2. The client process should see the value 2 at 81000001.

Author

Commented:
That means then that each child process will have to consume x amount of data space for making the memory mapping?
CERTIFIED EXPERT

Commented:
no, the child process wont actually consume any more pyhisical memory, it will just map the region into its virtual memory

Explore More ContentExplore courses, solutions, and other research materials related to this topic.