sem_init on OS X
A better solution (these days) than named semaphores on OS X is Grand Central Dispatch's dispatch_semaphore_t. It works very much like the unnamed POSIX semaphores.
Initialize the semaphore:
#include <dispatch/dispatch.h>dispatch_semaphore_t semaphore;semaphore = dispatch_semaphore_create(1); // init with value of 1
Wait & post (signal):
dispatch_semaphore_wait(semaphore, DISPATCH_TIME_FOREVER);...dispatch_semaphore_signal(semaphore);
Destroy:
dispatch_release(semaphore);
The header file is well documented and I found it quite easy to use.