|
shmat()
maps the shared memory segment associated with the shared memory identifier
specified by
shmid into the data segment of the calling process. Upon successful completion,
the address of the mapped segment is returned.
The shared memory segment is mapped at the address specified
by one of the following criteria:
-
- If
shmaddr is equal to zero, the segment is mapped at an address selected by the
system. Ordinarily, applications should invoke
shmat()
with
shmaddr equal to zero so that the operating system may make the best
use of available resources.
-
- If
shmaddr is not equal to zero and
(shmflg &
SHM_RND) is ``true'', the segment is mapped at the address given by
(shmaddr - (shmaddr modulus
SHMLBA)).
-
- If
shmaddr is not equal to zero and
(shmflg &
SHM_RND) is ``false'', the segment is mapped at the address given by
shmaddr.
The segment is mapped for reading if
(shmflg &
SHM_RDONLY) is ``true''
[READ], otherwise it is mapped for reading and writing
[READ/WRITE] (see
shmctl(2)). shmdt()
unmaps from the calling process's address space
the shared memory segment that is mapped at the address specified by
shmaddr. The shared memory segment must have been mapped with a prior
shmat()
function call. The segment and contents are retained until explicitly
removed by means of the
IPC_RMID
function (see
shmctl(2)). |