Reputation: 2817
I have two processes, each can take the same shmid
from shmget()
.
In these two processes, shmat()
gives different memory addresses.
The addresses are always the same for each of the process:
Process1: 0x41b31000
Process2: 0x4017d000
I do not think the addresses are virtual addreses as stated the answer which is written in the question below, beside, if these addresses are virtual addresses, these have to point the same hardware address. However, the content of these addresses is not same.
I'm cross compiling for ARM Processor, my program is running without error or problem in x86 Debian Lenny.
I'm aware of that the question, but the problem is not much that ease - shmat() is returning a different "shmaddr" for same "shmkey" -
Upvotes: 2
Views: 873
Reputation: 2817
It was about memory alignment.
I have a huge data with starting 1 byte whether it is clean or not, but that 1 byte cost for 2 week.
There is no problem with Shared memory on ARM or with operating system.
One reason, my fault.
Upvotes: 0
Reputation: 223256
The addresses returned by shmat
are virtual addresses.
The same physical memory may be mapped to different virtual addresses in different processes. (It is even possible for the same physical memory to be mapped to different virtual addresses within one process; the operating system can set the virtual-to-physical translation so that multiple virtual addresses map to the same physical memory.)
If shmat
returns address a
in process A
and mapping the same shared memory segment returns address b
in process B
, then the data at a
in process A
should be the same as the data in b
in process B
. If it is not, then something is wrong, which may include: You did not actually map the same shared memory segment, you did not compare the data correctly, or (very unlikely) there is a bug in the shared-memory software or the operating system.
Upvotes: 4