Multithreaded Programming Guide

Return Values

sem_init() returns zero after completing successfully. Any other returned value indicates that an error occurred. When any of the following conditions occur, the function fails and returns the corresponding value.


The value argument exceeds SEM_VALUE_MAX.


A resource required to initialize the semaphore has been exhausted. The limit on semaphores SEM_NSEMS_MAX has been reached.


The process lacks the appropriate privileges to initialize the semaphore.