When pshared is nonzero, the semaphore can be shared by other processes.
#include <semaphore.h> sem_t sem; int ret; int count = 4; /* to be shared among processes */ ret = sem_init(&sem, 1, count);