| SEMGET(2) | 21 January 1990 | SEMGET(2) |
| NAME |
| semget - get set of semaphores |
| SYNOPSIS |
|
|
| DESCRIPTION |
|
semget()
returns the semaphore identifier associated with
key. A semaphore identifier and associated data structure and set containing nsems semaphores (see intro(2)) are created for key if one of the following are true:
Upon creation, the data structure associated with the new semaphore identifier is initialized as follows:
A semaphore identifier (semid) is a unique positive integer created by a semget(2) system call. Each semid has a set of semaphores and a data structure associated with it. The data structure is referred to as semid_ds and contains the following members:
sem_perm is an ipc_perm structure that specifies the semaphore operation permission (see below). This structure includes the following members:
The value of
sem_nsems
is equal to the number of semaphores in the set.
Each semaphore in the set is referenced by a positive integer
referred to as a
sem_num. sem_num
values run sequentially from 0 to the value of
sem_nsems
minus 1.
sem_otime
is the time of the last
semop(2) operation, and
sem_ctime
is the time of the last
semctl(2) operation that changed a member of the above structure.
A semaphore is a data structure that contains the following members:
semval is a non-negative integer. sempid is equal to the process ID of the last process that performed a semaphore operation on this semaphore. semncnt is a count of the number of processes that are currently suspended awaiting this semaphore's semval to become greater than its current value. semzcnt is a count of the number of processes that are currently suspended awaiting this semaphore's semval to become zero. |
| RETURN |
| semget() returns a non-negative semaphore identifier on success. On failure, it returns -1 and sets errno to indicate the error. |
| ERRORS |
|
| SEE |
| SEMGET(2) | 21 January 1990 | SEMGET(2) |