Open System Services System Calls Reference Manual (G06.29+, H06.08+, J06.03+)

semget(2) OSS System Calls Reference Manual
NAME
semget - Creates a new semaphore set ID or returns the ID of an existing semaphore set
LIBRARY
G-series native OSS processes: /G/system/sysnn/zossksrl
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/sem.h>
int semget(
key_t key,
int nsems,
int semflg);
PARAMETERS
key Specifies the key that identifies the semaphore set. The IPC_PRIVATE key can
be used to ensure the return of a new (unused) semaphore set ID in the sema-
phore set table.
nsems Specifies the number of OSS semaphores to create in the semaphore set.
semflg Specifies the creation flags. Possible values are as follows:
IPC_CREAT If the key does not exist, the semget() function creates a sema-
phore set ID using the given key.
IPC_CREAT | IPC_EXCL
If the key already exists, the semget() function fails and returns
an error notification.
DESCRIPTION
The semget() function returns the semaphore set ID for the semaphore set identified by the key
parameter. If the key parameter already has a semaphore set ID associated with it and (semflg &
IPC_CREAT) is 0 (zero), that ID is returned.
A new semaphore set ID, the associated semaphore set table, and a new semaphore set of nsems
OSS semaphores are created when either of the following is true:
The value of IPC_PRIVATE is used for the key parameter.
The key parameter does not already have a semaphore set ID associated with it, and
(semflg & IPC_CREAT) is not 0 (zero).
After creating a new semaphore set ID, the semget() function initializes the semid_ds structure
associated with the ID as follows:
The sem_perm.cuid and sem_perm.uid fields are set equal to the effective user ID of
the calling process.
The sem_perm.cgid and sem_perm.gid fields are set equal to the effective group ID of
the calling process.
The low-order nine bits of the sem_perm.mode field are set equal to the low-order nine
bits of the semflg parameter.
720 Hewlett-Packard Company 527186-023