28.1 Semaphores

The GNU C Library implements the semaphore APIs as defined in POSIX and System V. Semaphores can be used by multiple processes to coordinate shared resources. The following is a complete list of the semaphore functions provided by the GNU C Library.

28.1.1 System V Semaphores

Function: int semctl (int semid, int semnum, int cmd)

Preliminary: | MT-Safe | AS-Safe | AC-Unsafe corrupt/linux | See POSIX Safety Concepts.

Function: int semget (key_t key, int nsems, int semflg)

Preliminary: | MT-Safe | AS-Safe | AC-Safe | See POSIX Safety Concepts.

Function: int semop (int semid, struct sembuf *sops, size_t nsops)

Preliminary: | MT-Safe | AS-Safe | AC-Safe | See POSIX Safety Concepts.

Function: int semtimedop (int semid, struct sembuf *sops, size_t nsops, const struct timespec *timeout)

Preliminary: | MT-Safe | AS-Safe | AC-Safe | See POSIX Safety Concepts.

28.1.2 POSIX Semaphores

The GNU C Library provides POSIX semaphores as well. These functions’ names begin with sem_ and they are declared in semaphore.h. See POSIX Semaphores.