Next: Controlling and Deallocating Shared
Up: Shared Memory
Previous: Allocation
Contents
- To make the shared memory segment available, a process must use shmat, (SHared Memory ATtach).
- Pass the shared memory segment identifier SHMID returned by shmget.
- The second argument is a pointer that specifies where in your process's address space you want to map the shared memory; if you specify NULL, Linux will choose an available address.
- The third argument is a flag, which can include the following:
- SHM_RND indicates that the address specified for the second parameter should be rounded down to a multiple of the page size.
- SHM_RDONLY indicates that the segment will be only read, not written.
- If the call succeeds, it returns the address of the attached shared segment. Children created by calls to fork inherit attached shared segments; they can detach the shared memory segments, if desired.
Cem Ozdogan
2007-05-16