Open System Services System Calls Reference Manual (G06.29+, H06.08+, J06.03+)
System Functions (s and S) shmat(2)
NAME
shmat - Attaches a shared memory segment to the address space of the calling process
LIBRARY
G-series native OSS processes: /G/system/sysnn/zossksrl
H-series and J-series native Guardian processes: $SYSTEM.ZDLLnnn.ZOSSKDLL
32-bit H-series and J-series OSS processes: /G/system/zdllnnn/zosskdll
64-bit H-series and J-series OSS processes: /G/system/zdllnnn/yosskdll
SYNOPSIS
#include <sys/shm.h>
void *shmat(
int shmid,
const void *shmaddr,
int shmflag);
PARAMETERS
shmid Specifies the identifier for the shared memory segment. The identifier is usually
returned by a previous call to the shmget() function.
shmaddr Specifies the virtual address at which the process wants to attach the shared
memory segment. The process can also specify 0 (zero) to have the system
select an appropriate address.
shmflag Specifies the following attach flags:
SHM_RND If the shmaddr parameter is not a null pointer, the system rounds
off the address, if necessary.
SHM_RDONLY
The segment is attached for read-only access.
DESCRIPTION
The shmat() function attaches the shared memory segment identified by the shmid parameter to
the virtual address space of the calling process. For the shmaddr parameter, the process can
specify an explicit address, or it can pass a NULL pointer (zero) to have the system select the
address. If shmaddr is nonzero and (shmflag & SHM_RND) is not zero, the system rounds down
the specified address. For detailed information, see "Shared Memory Segment Alignment."
The segment is attached for reading if (shmflag & SHM_RDONLY) is not zero and the calling
process has read permission. If (shmflag & SHM_RDONLY) is 0 (zero) and the calling process
has read and write permission, the segment is attached for reading and writing.
Memory can be shared only within the same processor.
Shared memory uses operating system flat segments (permanently mapped shareable data seg-
ments). Refer to the Guardian Programmer’s Guide for more information about flat segments.
Address Range
An application that is using the shared memory functions shmat() and shmdt() to manage a
range of virtual addresses should use only these functions to manipulate the range.
The valid range of addresses for the shmaddr parameter can change from one release to the next.
Programs should not contain hard-coded addresses.
527186-023 Hewlett-Packard Company 7−77