Go to the previous, next section.
int semget(key_t key, int nsems, int semflg);
key: [in] the semaphore set identificator.
nsems: [in] the number of semaphore in the set.
semflg: [in] flags (see description).
Gets a semaphore set identifier. If key is IPC_PRIVATE
, a
new set is created. Otherwise, the result depends on the value of
semflg:
IPC_CREAT
IPC_EXCL
The 9 lower bits of semflg specify the permission bits of the new set. They have the same layout and meaning as those for files. However, the execute permissions are meaningless for sets.
When creating a set the system sets the appropriate parameters in the
semid_ds
structure associated with the new set. When accessing
an already existing set, the system simply check if the set can be
accessed.
On success, the call returns the new semaphore set identificator. On
error -1 is returned and errno
is set to one of the following
values:
EACCESS
: the task has no access permission to the set.
EEXIST
: IPC_CREAT
and IPC_EXCL
were specified
and the set already exists.
EIDRM
: the set no longer exists in the system.
ENOENT
: the set never existed.
ENOSPC
: the maximum number of semaphore sets for the system
has been reached.
ENOMEM
Go to the previous, next section.