Unix Semaphore Issue Unix Semaphore Issue unix unix

Unix Semaphore Issue


Your critical section is not locked at all, which hypothesis fits your symptoms well.

sem_init() is failing with ENOSYS. sem_wait() and sem_post() subsequently fail with EINVAL, and sem_destroy() fails as well (probably again with ENOSYS). Your worker threads are stepping on each other's increments.

Are you on OS X? That's the most common platform at present that does not support unnamed POSIX semaphores. Try the named semaphore interface, defined in the same header file, which is supported.