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.
int
semctl (int semid, int semnum, int cmd);
¶Preliminary: | MT-Safe | AS-Safe | AC-Unsafe corrupt/linux | See POSIX Safety Concepts.
int
semget (key_t key, int nsems, int semflg);
¶Preliminary: | MT-Safe | AS-Safe | AC-Safe | See POSIX Safety Concepts.
int
semop (int semid, struct sembuf *sops, size_t nsops);
¶Preliminary: | MT-Safe | AS-Safe | AC-Safe | See POSIX Safety Concepts.
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.
int
sem_init (sem_t *sem, int pshared, unsigned int value);
¶Preliminary: | MT-Safe | AS-Safe | AC-Unsafe corrupt | See POSIX Safety Concepts.
int
sem_destroy (sem_t *sem);
¶Preliminary: | MT-Safe | AS-Safe | AC-Safe | See POSIX Safety Concepts.
sem_t
*sem_open (const char *name, int oflag, ...);
¶Preliminary: | MT-Safe | AS-Unsafe init | AC-Unsafe init | See POSIX Safety Concepts.
int
sem_close (sem_t *sem);
¶Preliminary: | MT-Safe | AS-Unsafe lock | AC-Unsafe lock | See POSIX Safety Concepts.
int
sem_unlink (const char *name);
¶Preliminary: | MT-Safe | AS-Unsafe init | AC-Unsafe corrupt | See POSIX Safety Concepts.
int
sem_wait (sem_t *sem);
¶Preliminary: | MT-Safe | AS-Safe | AC-Unsafe corrupt | See POSIX Safety Concepts.
int
sem_timedwait (sem_t *sem, const struct timespec *abstime);
¶Preliminary: | MT-Safe | AS-Safe | AC-Unsafe corrupt | See POSIX Safety Concepts.
int
sem_trywait (sem_t *sem);
¶Preliminary: | MT-Safe | AS-Safe | AC-Safe | See POSIX Safety Concepts.
int
sem_post (sem_t *sem);
¶Preliminary: | MT-Safe | AS-Safe | AC-Safe | See POSIX Safety Concepts.
int
sem_getvalue (sem_t *sem, int *sval);
¶Preliminary: | MT-Safe | AS-Safe | AC-Safe | See POSIX Safety Concepts.