Realtime Library sem_init(3R)NAME
sem_init - initialize an unnamed semaphoreSYNOPSIS
cc [ flag ... ] file ... -lposix4 [ library ... ] #include <semaphore.h> int sem_init(sem_t *sem, int pshared, unsigned int value );DESCRIPTION
The sem_init() function is used to initialize the unnamed semaphore referred to by sem to value. This semaphore may be used in subsequent calls to sem_wait(3R), sem_trywait(3R), sem_post(3R), and sem_destroy(3R). This semaphore remains usable until the semaphore is destroyed. If pshared is non-zero, then the semaphore is sharable between processes. If the semaphore is not being shared between processes, the application should set pshared to 0.RETURN VALUES
If successful, sem_init() returns 0 and initializes the semaphore in sem; otherwise it returns -1 and sets errno to indicate the error condition.ERRORS
EINVAL The value argument exceeds SEM_VALUE_MAX. ENOSPC A resource required to initialize the semaphore has been exhausted, or the resources have reached the limit on semaphores (SEM_NSEMS_MAX). ENOSYS The sem_init() function is not supported. EPERM The calling process lacks the appropriate privileges to initialize the semaphore.ATTRIBUTES
See attributes(5) for descriptions of the following attri- butes: __________________________________ | ATTRIBUTE TYPE| ATTRIBUTE VALUE| |_______________|__________________|_ | MT-Level | MT-Safe | |_______________|_________________|SEE ALSO
sem_destroy(3R), sem_post(3R), sem_wait(3R), attributes(5)