#include <mach/semaphore.h>

mach/semaphore.h Kernel.framework

Forward Declarations The semaphore creation and deallocation routines are defined with the Mach task APIs in <mach/task.h>. kern_return_t semaphore_create(task_t task, semaphore_t *new_semaphore, sync_policy_t policy, int value); kern_return_t semaphore_destroy(task_t task, semaphore_t semaphore);
includes: mach/port.h, mach/mach_types.h, Kernel/mach/kern_return.h, Kernel/mach/sync_policy.h, sys/cdefs.h
2 functions

functionsemaphore_wait_deadline

extern kern_return_t semaphore_wait_deadline(semaphore_t semaphore, uint64_t deadline)
claude-fable-5, 2026-08-24 · not from Apple sources · verified against xnu osfmk/kern/sync_sema.c
Waits on the semaphore for in-kernel clients, blocking until the semaphore is signaled or the given deadline (mach absolute time) passes. Returns KERN_SUCCESS when the wait is satisfied, KERN_OPERATION_TIMED_OUT if the deadline expires first, KERN_TERMINATED if the semaphore is destroyed while waiting, KERN_ABORTED if the waiting thread is awakened abnormally, and KERN_INVALID_ARGUMENT if semaphore is SEMAPHORE_NULL.

functionsemaphore_wait_noblock

extern kern_return_t semaphore_wait_noblock(semaphore_t semaphore)
claude-fable-5, 2026-08-24 · not from Apple sources · verified against xnu osfmk/kern/sync_sema.c
Non-blocking semaphore wait for in-kernel clients: attempts to decrement the semaphore without waiting (SEMAPHORE_TIMEOUT_NOBLOCK). Returns KERN_SUCCESS if the semaphore was available, KERN_OPERATION_TIMED_OUT if it was not, and KERN_INVALID_ARGUMENT if semaphore is SEMAPHORE_NULL.