#include <kern/sched_prim.h>
kern/sched_prim.h
functionthread_get_current_cpuid
extern int thread_get_current_cpuid(void)
▾
claude-fable-5, 2026-08-24 · not from Apple sources
Declared in kern/sched_prim.h with no arguments, returning int. The name indicates it returns the id of the CPU on which the calling thread is currently running. Implementation not present in the available xnu sources; note that preemption can migrate the caller unless disabled.
functionthread_block_parameter
extern wait_result_t thread_block_parameter( thread_continue_t continuation, void *parameter )
▾
claude-fable-5, 2026-08-24 · not from Apple sources · verified against xnu osfmk/kern/sched_prim.c
Blocks the current thread if a wait has been asserted (assert_wait and variants), giving up the processor until the wait completes, in the manner of thread_block but recording parameter for the continuation. If continuation is not THREAD_CONTINUE_NULL, the kernel may discard the thread's stack and resume it by calling continuation(parameter, wait_result) on a fresh stack instead of returning. Returns the thread's wait result.
functionassert_wait
extern wait_result_t assert_wait(event_t event, wait_interrupt_t interruptible)
Declare thread will wait on a particular event
functionassert_wait_timeout
extern wait_result_t assert_wait_timeout( event_t event, wait_interrupt_t interruptible, uint32_t interval, uint32_t scale_factor )
Assert that the thread intends to wait with a timeout
functionassert_wait_timeout_with_leeway
extern wait_result_t assert_wait_timeout_with_leeway( event_t event, wait_interrupt_t interruptible, wait_timeout_urgency_t urgency, uint32_t interval, uint32_t leeway, uint32_t scale_factor )
Assert that the thread intends to wait with an urgency, timeout and leeway
functionassert_wait_deadline
extern wait_result_t assert_wait_deadline( event_t event, wait_interrupt_t interruptible, uint64_t deadline )
▾
claude-fable-5, 2026-08-24 · not from Apple sources · verified against xnu osfmk/kern/sched_prim.c
Asserts that the current thread is about to wait on the specified event, with the wait bounded by an absolute deadline in mach_absolute_time units and no leeway. interruptible states whether the wait may be interrupted (THREAD_UNINT, THREAD_INTERRUPTIBLE, THREAD_ABORTSAFE). The wait actually occurs at the next thread_block; returns the wait state (normally THREAD_WAITING). Panics if called with NO_EVENT.
functionassert_wait_deadline_with_leeway
extern wait_result_t assert_wait_deadline_with_leeway( event_t event, wait_interrupt_t interruptible, wait_timeout_urgency_t urgency, uint64_t deadline, uint64_t leeway )
Assert that the thread intends to wait with an urgency, deadline, and leeway
functionthread_wakeup_prim
extern kern_return_t thread_wakeup_prim( event_t event, boolean_t one_thread, wait_result_t result )
Wake up thread (or threads) waiting on a particular event
functionthread_wakeup_nthreads_prim
extern kern_return_t thread_wakeup_nthreads_prim( event_t event, uint32_t nthreads, wait_result_t result )
Wake up up to given number of threads waiting on a particular event
macrothread_wakeup
#define thread_wakeup(x) thread_wakeup_prim((x), FALSE, THREAD_AWAKENED)
macrothread_wakeup_with_result
#define thread_wakeup_with_result(x, z) thread_wakeup_prim((x), FALSE, (z))
macrothread_wakeup_one
#define thread_wakeup_one(x) thread_wakeup_prim((x), TRUE, THREAD_AWAKENED)
macrothread_wakeup_nthreads
#define thread_wakeup_nthreads(x, nthreads) thread_wakeup_nthreads_prim((x), (nthreads), THREAD_AWAKENED)
macrothread_wakeup_nthreads_with_result
#define thread_wakeup_nthreads_with_result(x, nthreads, z) thread_wakeup_nthreads_prim((x), (nthreads), (z))
functionthread_wakeup_thread
extern kern_return_t thread_wakeup_thread(event_t event, thread_t thread)
Wakeup the specified thread if it is waiting on this event
functionpreemption_enabled
extern boolean_t preemption_enabled(void)
▾
claude-fable-5, 2026-08-24 · not from Apple sources · verified against xnu osfmk/kern/sched_prim.c
Returns TRUE if the current context can be preempted: the preemption level is zero and interrupts are enabled. Useful for asserting that a code path is not within a critical section.