Skip to content
BSD syscall#275

svc · unix #275

sem_init

POSIX entry point for unnamed semaphores; explicitly unsupported on Darwin.

Prototype

int sem_init(sem_t *sem, int phsared, u_int value);

Returns: int

Arguments

NameTypeDirDescription
semsem_t-
phsaredint-
valueu_int-

Version history

XNU tagmacOS#
xnu-1456.1.26macOS 10.6 Snow Leopard275
xnu-1699.24.8macOS 10.7 Lion275
xnu-2050.18.24macOS 10.8 Mountain Lion275
xnu-2422.115.4macOS 10.9 Mavericks275
xnu-1486.2.11—275
xnu-1504.15.3—275
xnu-1504.3.12—275
xnu-1504.7.4—275
xnu-1504.9.17—275
xnu-1504.9.26—275
xnu-1504.9.37—275
xnu-1699.22.73—275
xnu-1699.22.81—275
xnu-1699.24.23—275
xnu-1699.26.8—275
xnu-1699.32.7—275
xnu-2050.22.13—275
xnu-2050.24.15—275
xnu-2050.48.11—275
xnu-2050.7.9—275
xnu-2050.9.2—275
xnu-2422.1.72—275
xnu-2422.100.13—275
xnu-2422.110.17—275
xnu-2422.90.20—275

Notes

sem_init(3) is present in <semaphore.h> for source compatibility but the implementation immediately sets errno to ENOSYS and returns -1. Cross-platform code must fall back to sem_open(3) (named), dispatch_semaphore_create() or a pthread_cond_t-based primitive on macOS.

Related APIs

sem_opensem_destroydispatch_semaphore_createpthread_cond_init