#include <sys/types.h> #include <sys/ipc.h> #include <sys/shm.h>
int shmget(key, size, shmflg) key_t key; int size, shmflg;
shmget() returns the shared memory identifier associated with key.
A shared memory identifier and associated data structure and shared memory segment of at least size bytes (see intro.2 are created for key if one of the following are true:
Upon creation, the data structure associated with the new shared memory identifier is initialized as follows:
A shared memory identifier (shmid) is a unique positive integer created by a shmget.2 system call. Each shmid has a segment of memory (referred to as a shared memory segment) and a data structure associated with it. The data structure is referred to as shmid_ds and contains the following members:
struct ipc_perm shm_perm; /* operation permission struct */ int shm_segsz; /* size of segment */ ushort shm_cpid; /* creator pid */ ushort shm_lpid; /* pid of last operation */ short shm_nattch; /* number of current attaches */ time_t shm_atime; /* last attach time */ time_t shm_dtime; /* last detach time */ time_t shm_ctime; /* last change time */ /* Times measured in secs since */ /* 00:00:00 GMT, Jan. 1, 1970 */
shm_perm is an ipc_perm structure that specifies the shared memory operation permission (see below). This structure includes the following members:
ushort cuid; /* creator user id */ ushort cgid; /* creator group id */ ushort uid; /* user id */ ushort gid; /* group id */ ushort mode; /* r/w permission */
shm_segsz specifies the size of the shared memory segment. shm_cpid is the process ID of the process that created the shared memory identifier. shm_lpid is the process ID of the last process that performed a shmop.2 operation. shm_nattch is the number of processes that currently have this segment attached. shm_atime is the time of the last shmat operation, shm_dtime is the time of the last shmdt operation, and shm_ctime is the time of the last shmctl.2 operation that changed one of the members of the above structure.
A shared memory identifier exists for key but the size of the segment associated with it is less than size and size is not equal to zero.
Created by unroff & hp-tools. © somebody (See intro for details). All Rights Reserved. Last modified 11/5/97