Find number of tasks blocking on a POSIX semaphore
问题 Is there any way by which I can know the number of processes or threads waiting on a particular semaphore? Like a API to check the value. Sem_getvalue() only returns 0 and not a negative number whose absolute value is the number of tasks blocking on the semaphore as mentioned on a few sites. Any help would be great. Thanks in advance!! 回答1: There is no way to do this in the POSIX API other than sem_getvalue , which semantics, as you have seen, are optional. That said, Linux implements named