http://www.cs.cmu.edu/afs/cs/project/mach/public/www/doc/publications.html
http://wiki.osx86project.org/wiki/index.php/Vmware
http://en.wikipedia.org/wiki/Darwin_(operating_system)#PureDarwin
https://developer.apple.com/library/mac/#documentation/Darwin/Conceptual/KernelProgramming/synchronization/synchronization.html
http://docs.huihoo.com/darwin/kernel-programming-guide/synchronization/chapter_15_section_4.html
https://developer.apple.com/library/mac/#releasenotes/Darwin/RN-KernelExtensions
busy-wait |
Spinlock |
lck_spin_t |
sleepable |
Mutex |
lck_mtx_t |
sleepable |
RW lock |
lck_rw_t |
sleepable |
Semaphore |
semaphore_t |
sleepable |
Lockset (user-mode only) |
lock_set_t |
Each lock belongs to lock group, usually defined as one or more per component. Lock group collects statistics.
lck_grp_t* lck_grp_alloc_init(const
char* grp_name, lck_grp_attr_t* attr)
void lck_grp_free(lck_grp_t* group)
In most cases attributes are default and allocated with lck_grp_attr_alloc_init()... use it for lck_grp_alloc_init(), then lck_grp_attr_free(attr).
splx functions are no-op. Interrupts are not disabled in kernel except in minor special chunks of code.
Spinlocks,
mutexes and rw-locks (?) are kernel-mode only.
Locksets and semaphores are available in user-mode in addition to kernel mode.
Lockset is a set of mutexes. Individual locks can be handed off by holder
thread to another thread.
Conditional variables are not implemented , must use sleep/wakeup instead.
Sleep/wakeup:
Cannot try sleeping with preemption disabled, incl. spinlocks
held.
Note: there is no sleep variants temporarily releasing spinlocks or RW
locks; only mutexes.
#include <sys/proc.h>
int sleep(void* chan, int pri)
int tsleep(void* chan, int pri, const char* wmesg, int
timo)
int msleep(void* chan, lck_mtx_t* mtx, int pri, const
char* wmesg, struct timespec* ts)
int msleep1(void* chan, lck_mtx_t* mtx, int pri, const
char* wmesg, u_int64_t abstime)
void wakeup(void* chan)
void wakeup_one(void* chan)
wmesg is for debugging only
timo is interval in ticks (hz per second)
ts is interval (defined by tv->tv_sec and ts->tv_nsec)
abstime is machine-dependent mach abstim (not interval), see mach_absolute_time()
and mach_timebase_info()
pri is a priority while in wait queue:
#define PSWP 0
#define PVM 4
#define PINOD 8
#define PRIBIO 16
#define PVFS 20
#define PZERO 22
#define PSOCK 24
#define PWAIT 32
#define PLOCK 36
#define PPAUSE 40
#define PUSER 50
#define MAXPRI 127
(see more next page)
with OR'ed flags:
#define PRIMASK 0x0ff
#define PCATCH 0x100 /* OR'd with pri for sleep to abort if any signal is received */
#define PDROP 0x400 /* OR'd with pri to not re-aquire mutex upon wakeup */
#define PSPIN 0x800 /* OR'd with pri to acquire mutex upon wakeup via lck_mtx_lock_spin */
Result:
0 event was signal by wakeup
EWOULDBLOCK wait timeout expired
EINTR waked up by signal (only if PCATCH)
ERESTART operation should be restarted entirely (only if PCATCH)
There are also other sleep functions unaccessible from kernel extensions: thread_sleep_lock_write,
thread_sleep_mutex, thread_sleep_mutex_deadline, thread_sleep_usimple_lock (exported
from kernel, but not declared in kext headers).
*************************************************************************
* 127 Reserved (real-time)
* A
* +
* (32 levels)
* +
* V
* 96 Reserved (real-time)
* 95 Kernel mode only
* A
* +
* (16 levels)
* +
* V
* 80 Kernel mode only
* 79 System high priority
* A
* +
* (16 levels)
* +
* V
* 64 System high priority
* 63 Elevated priorities
* A
* +
* (12 levels)
* +
* V
* 52 Elevated priorities
* 51 Elevated priorities (incl. BSD +nice)
* A
* +
* (20 levels)
* +
* V
* 32 Elevated priorities (incl. BSD +nice)
* 31 Default (default base for threads)
* 30 Lowered priorities (incl. BSD -nice)
* A
* +
* (20 levels)
* +
* V
* 11 Lowered priorities (incl. BSD -nice)
* 10 Lowered priorities (aged pri's)
* A
* +
* (11 levels)
* +
* V
* 0 Lowered priorities (aged pri's / idle)
*************************************************************************
#define BASEPRI_RTQUEUES (BASEPRI_REALTIME
+ 1) /* 97 */
#define BASEPRI_REALTIME (MAXPRI - (NRQS / 4) + 1) /* 96 */
#define MAXPRI_KERNEL (BASEPRI_REALTIME - 1) /* 95 */
#define BASEPRI_PREEMPT (MAXPRI_KERNEL - 2) /* 93 */
#define BASEPRI_KERNEL (MINPRI_KERNEL + 1) /* 81 */
#define MINPRI_KERNEL (MAXPRI_KERNEL - (NRQS / 8) + 1) /* 80 */
#define MAXPRI_RESERVED (MINPRI_KERNEL - 1) /* 79 */
#define MINPRI_RESERVED (MAXPRI_RESERVED - (NRQS / 8) + 1) /* 64 */
#define MAXPRI_USER (MINPRI_RESERVED - 1) /* 63 */
#define BASEPRI_CONTROL (BASEPRI_DEFAULT + 17) /* 48 */
#define BASEPRI_FOREGROUND (BASEPRI_DEFAULT + 16) /* 47 */
#define BASEPRI_BACKGROUND (BASEPRI_DEFAULT + 15) /* 46 */
#define BASEPRI_DEFAULT (MAXPRI_USER - (NRQS / 4)) /* 31 */
#define MAXPRI_THROTTLE (MINPRI + 4) /* 4 */
#define MINPRI_USER MINPRI /* 0 */
Spinlock:
Only lck_spin_t is accessible from kernel
extensions, other spinlock kinds are more basic and do not provide association
with group lock.
Non-recursive.
Does not disable interrupts, but disables preemption on local cpu by
incrementing cpu_data.cpu_preemption_level.
Panic if cannot be acquired within LockTimeOutTSC, default is 1/4 sec, overridable
with boot parameter "slto_us".
Cannot sleep with spinlock held (will panic).
Cannot try to acquire sleepable locks with spinlock held (will panic).
No built-in lock ordering checks, i.e. no witness-like facility.
void lck_spin_init(lck_spin_t* lck, lck_grp_t* grp, lck_attr_t* attr);
void lck_spin_destroy(lck_spin_t* lck, lck_grp_t* grp);
lck_spin_t* lck_spin_alloc_init(lck_grp_t* grp, lck_attr_t* attr);
void lck_spin_free(lck_spin_t* lck,lck_grp_t* grp);
Statically allocated or dynamically allocated.
attr = lck_attr_alloc_init(); ... use it to create
lock ... lck_attr_free(attr)
Note: from kernel extensions can use only lck_spin_alloc_init, not lck_spin_init.
void lck_spin_lock(lck_spin_t* lck);
void lck_spin_unlock(lck_spin_t* lck);
wait_result_t lck_spin_sleep(lck_spin_t* lck,
lck_sleep_action_t
sleep_action,
event_t event,
// wakeup channel
wait_interrupt_t interruptible);
wait_result_t lck_spin_sleep_deadline(
lck_spin_t* lck,
lck_sleep_action_t
sleep_action,
event_t event,
wait_interrupt_t interruptible,
uint64_t deadline);
Unlock, wait
(sleep), optionally relock.
Value of sleep_action:
LCK_SLEEP_DEFAULT – Release the lock while waiting for the event, then reclaim it.
LCK_SLEEP_UNLOCK – Release
the lock and return with the lock unheld.
Value of interruptible:
THREAD_UNINT sleep
should not be aborted by any signal
THREAD_INTERRUPTIBLE sleep may be aborted if SIGKILL is received
THREAD_ABORTSAFE sleep may be aborted if any signal is received
Result:
THREAD_AWAKENED event was signal by wakeup
THREAD_TIMED_OUT wait timeout expired
THREAD_INTERRUPTED waked up by signal
THREAD_RESTART (not returned for spinlocks) operation should be restarted entirely
boolean_t lck_spin_try_lock(lck_spin_t* lck);
KERNEL_PRIVATE only (exported, but not declared in kext headers)
processor_t current_processor(); // unaccessible from extensions
Mutex:
Non-recursive.
Does not disable interrupts.
Locking request can result in a sleep, so cannot hold spinlocks.
Can sleep with mutex held.
Priority propagation.
No built-in lock ordering checks, i.e. no witness-like facility.
void lck_mtx_init(lck_mtx_t* lck, lck_grp_t* grp, lck_attr_t* attr);
void lck_mtx_destroy(lck_mtx_t* lck, lck_grp_t* grp);
lck_mtx_t* lck_mtx_alloc_init(lck_grp_t* grp, lck_attr_t* attr);
void lck_mtx_free(lck_mtx_t* lck,lck_grp_t* grp);
Statically allocated or dynamically allocated.
attr = lck_attr_alloc_init(); ... use it to create
lock ... lck_attr_free(attr)
Note: from kernel extensions can use only lck_mtx_alloc_init, not lck_mtx_init.
void lck_mtx_lock(lck_mtx_t* lck);
void lck_mtx_unlock(lck_mtx_t* lck);
wait_result_t lck_mtx_sleep(lck_mtx_t* lck,
lck_sleep_action_t
sleep_action,
event_t event,
// wakeup channel
wait_interrupt_t interruptible);
wait_result_t lck_mtx_sleep_deadline(
lck_mtx_t* lck,
lck_sleep_action_t
sleep_action,
event_t event,
wait_interrupt_t interruptible,
uint64_t deadline);
Unlock, wait
(sleep), optionally relock.
Value of sleep_action:
LCK_SLEEP_DEFAULT – Release the lock while waiting for the event, then reclaim it.
LCK_SLEEP_UNLOCK – Release
the lock and return with the lock unheld.
Value of interruptible:
THREAD_UNINT sleep
should not be aborted by any signal
THREAD_INTERRUPTIBLE sleep may be aborted if SIGKILL is received
THREAD_ABORTSAFE sleep may be aborted if any signal is received
Result:
THREAD_AWAKENED event
was signal by wakeup
THREAD_TIMED_OUT wait timeout expired
THREAD_INTERRUPTED waked up by signal
THREAD_RESTART (not returned for mutexes) operation should be restarted entirely
void lck_mtx_assert(lck_mtx_t* lck, LCK_MTX_ASSERT_OWNED or LCK_MTX_ASSERT_NOTOWNED);
Panic on assertion failure.
boolean_t lck_mtx_try_lock(lck_mtx_t* lck);
void lck_mtx_yield (lck_mtx_t* lck);
boolean_t lck_mtx_try_lock_spin(lck_mtx_t* lck);
void lck_mtx_lock_spin_always(lck_mtx_t* lck);
void lck_mtx_lock_spin(lck_mtx_t* lck);
void lck_mtx_convert_spin(lck_mtx_t* lck);
KERNEL_PRIVATE only (exported, but not declared in kext
headers)
lck_mtx_lock_spin – at entry preemption must be enabled, at return preemption
is disabled, no sleep but can do thread_block()
lck_mtx_lock_spin_always – like lck_mtx_lock_spin, but at entry preemption
can either be enabled or disabled
RW locks:
Non-recursive.
Does not disable interrupts.
Locking request can result in a sleep, so cannot hold spinlocks (but there is
internal field lck_rw_can_sleep).
Can sleep with rw lock held.
No priority propagation.
No built-in lock ordering checks, i.e. no witness-like facility.
Read locks can be upgraded to write. Write locks can be downgraded to read.
Upgrades are favored over write requests (to prevent deadlock).
Second and subsequent concurrent upgrades will fail and that thread's lock will
be released (to prevent a deadlock).
void lck_rw_init(lck_rw_t* lck, lck_grp_t* grp, lck_attr_t* attr);
void lck_rw_destroy(lck_rw_t* lck, lck_grp_t* grp);
lck_rw_t* lck_rw_alloc_init(lck_grp_t* grp, lck_attr_t* attr);
void lck_rw_free(lck_rw_t* lck,lck_grp_t* grp);
Statically allocated or dynamically allocated.
attr = lck_attr_alloc_init(); ... use it to create
lock ... lck_attr_free(attr)
Note: from kernel extensions can use only lck_rw_alloc_init, not lck_rw_init.
void lck_rw_lock(lck_rw_t* lck, LCK_RW_TYPE_SHARED
/ LCK_RW_TYPE_EXCLUSIVE);
void lck_rw_lock_shared(lck_rw_t* lck);
void lck_rw_lock_exclusive(lck_rw_t* lck);
void lck_rw_unlock(lck_rw_t* lck, LCK_RW_TYPE_SHARED
/ LCK_RW_TYPE_EXCLUSIVE);
void lck_rw_unlock_shared(lck_rw_t* lck);
void lck_rw_unlock_exclusive(lck_rw_t* lck);
wait_result_t lck_rw_sleep(lck_rw_t* lck,
lck_sleep_action_t
sleep_action,
event_t event,
// wakeup channel
wait_interrupt_t interruptible);
wait_result_t lck_rw_sleep_deadline(
lck_rw_t* lck,
lck_sleep_action_t
sleep_action,
event_t event,
wait_interrupt_t interruptible,
uint64_t deadline);
Unlock, wait
(sleep), optionally relock.
Value of sleep_action:
LCK_SLEEP_DEFAULT – Release the lock while waiting for the event, then reclaim it
LCK_SLEEP_UNLOCK – Release
the lock and return with the lock unheld
LCK_SLEEP_SHARED – Release the lock, reclaim
in shared mode
LCK_SLEEP_EXCLUSIVE –
Release the lock, reclaim in exclusive mode
Value of interruptible:
THREAD_UNINT sleep
should not be aborted by any signal
THREAD_INTERRUPTIBLE sleep may be aborted if SIGKILL is received
THREAD_ABORTSAFE sleep may be aborted if any signal is received
Result:
THREAD_AWAKENED event
was signal by wakeup
THREAD_TIMED_OUT wait timeout expired
THREAD_INTERRUPTED waked up by signal
THREAD_RESTART (not returned for rw locks) operation should be restarted entirely
boolean_t lck_rw_lock_shared_to_exclusive(lck_rw_t* lck);
void lck_rw_lock_exclusive_to_shared(lck_rw_t* lck);
boolean_t lck_rw_try_lock(lck_rw_t*
lck, LCK_RW_TYPE_SHARED / LCK_RW_TYPE_EXCLUSIVE);
boolean_t lck_rw_try_lock_shared(lck_rw_t* lck); // KERNEL_PRIVATE, not exported
boolean_t lck_rw_try_lock_exclusive(lck_rw_t* lck); // KERNEL_PRIVATE, not exported
Semaphore:
Used same places where mutexes are.
#include <mach/semaphore.h>
#include <mach/task.h>
kern_return_t semaphore_create(task_t task, semaphore_t * semaphore, int policy, int value)
kern_return_t semaphore_destroy(task_t
task, semaphore_t semaphore)
kern_return_t semaphore_signal(semaphore_t semaphore)
kern_return_t semaphore_signal_all(semaphore_t semaphore)
kern_return_t semaphore_signal_thread(semaphore_t
semaphore, thread _t thread)
kern_return_t semaphore_wait(semaphore_t semaphore)
kern_return_t semaphore_wait_deadline(semaphore_t semaphore, uint64_t deadline)
kern_return_t semaphore_timedwait(semaphore_t semaphore, mach_timespec_t wait_time)
kern_return_t semaphore_wait_signal(semaphore_t wait_semaphore, semaphore_t signal_semaphore)
kern_return_t semaphore_timedwait_signal(semaphore_t
wait_semaphore,
semaphore_t signal_semaphore,
mach_timespec_t wait_time)
kern_return_t semaphore_wait_noblock(semaphore_t semaphore)
Returned values:
KERN_SUCCESS
KERN_ABORTED
KERN_OPERATION_TIMED_OUT
KERN_SEMAPHORE_DESTROYED
KERN_TERMINATED
Memory management:
Currently OS X is
64 bit, iOS is 32 bit.
64-bit uses shared K/U address space, 32-bit uses
separate spaces.
Very low-level page allocation: vm_page_alloc,
kernel_memory_allocate, cpm_allocate.
Low-level page
allocation: Mach functions kmem_alloc*/kmem_free.
Unavailable from kernel extensions.
#include <kern/kalloc.h>
void* kalloc(vm_size_t size);
void* kalloc_noblock(vm_size_t size);
void kfree(void* data, vm_size_t size);
May not call while holding a spinlock or with
preemption otherwise disabled: will not always crash, but in some cases may
result in a deadlock. Question: can call out to memory pressure servicing
daemon, which in turn can do pageout?
These functions are not available in a kernel extension (kalloc/kfree
exported but not declared in kext headers, kalloc_noblock not exported,
however mac_calloc_noblock is exported).
Layered on top of zalloc and (for large blocks) kmem_alloc.
#include <kern/zalloc.h>
void* zalloc(zone_t zone);
void* zalloc_noblock(zone_t zone);
void zfree(zone_t zone, void* elem);
zone_t zinit(vm_size_t size, /* the size of an element */
vm_size_t maxmem, /* maximum memory to use */
vm_size_t alloc, /* allocation size */
const char* name); /* a name for the zone */
May not call while holding a spinlock or with
preemption otherwise disabled.
These functions are not available in a kernel extension (exported but not
declared in kext headers, and zalloc_noblock is not even
exported).
#include <libkern/OSMalloc.h>
OSMallocTag
OSMallocTag OSMalloc_Tagalloc(const char* name, OSMT_DEFAULT
(wired) or OSMT_PAGEABLE);
void OSMalloc_Tagfree(OSMallocTag tag);
void* OSMalloc(uint32_t size, OSMallocTag tag); // kalloc or kmem_alloc_pageable
void* OSMalloc_noblock(uint32_t size, OSMallocTag tag); // kalloc_noblock
void OSFree(void* addr,uint32_t
size, OSMallocTag tag);
May not call while holding a spinlock or with
preemption otherwise disabled.
name is limited to 63 characters.
#include <IOKit/IOLib.h>
void* IOMalloc(vm_size_t size); //
calls kalloc
void IOFree(void* address, vm_size_t size); // calls kfree
void* IOMallocAligned(vm_size_t size, vm_offset_t alignment); // kalloc for small, kernel_memory_allocate for big
void IOFreeAligned(void * address, vm_size_t size); // kfree or kmem_free
void* IOMallocPageable(vm_size_t size, vm_size_t alignment);
void IOFreePageable(void * address, vm_size_t size);
May not call while holding a spinlock or with
preemption otherwise disabled.
alignment = byte count (e.g. 256)
#include <sys/malloc.h>
void * _MALLOC(size_t size, int type, int flags); //
kalloc or kalloc_noblock
void _FREE(void* addr, int type); //
kfree
void * _REALLOC(void* addr, size_t size, int type, int flags); //
_MALLOC and _FREE
void * _MALLOC_ZONE(size_t size, int type, int flags); //
zalloc, zalloc_noblock, kalloc, kalloc_noblock
void _FREE_ZONE(void* elem, size_t size,int type); //
zfree, kfree
flags: M_WAITOK, M_NOWAIT, M_ZERO
type: use M_TEMP
May not call while holding a spinlock or with preemption otherwise disabled.
no header
void* kern_os_malloc(size_t size);
void* kern_os_realloc(void * addr, size_t size);
void kern_os_free(void * addr);
size_t kern_os_malloc_size(void * addr);
Layered on top of kalloc/kfree.
Used by libkern c++ runtime.
Exported by kernel, but not defined in any header.
Timer Callout:
#include <kern/timer_call.h>
void timer_call_setup(timer_call_t call,
timer_call_func_t func, timer_call_param_t param0);
boolean_t timer_call_enter(timer_call_t call,
uint64_t deadline, uint32_t flags);
boolean_t timer_call_enter1(timer_call_t call,
timer_call_param_t param1, uint64_t deadline, uint32_t flags);
boolean_t timer_call_cancel(timer_call_t call);
Unavailable from kernel extensions (not exported from kernel).
#include <kern/thread_call.h>
typedef void* thread_call_param_t;
typedef void (*thread_call_func_t)(thread_call_param_t param0, thread_call_param_t param1);
thread_call_t thread_call_allocate(thread_call_func_t func, thread_call_param_t param0);
boolean_t thread_call_free(thread_call_t call); // must not call while queued pending or being executed
boolean_t thread_call_enter(thread_call_t call); // true if the entry was already on the queue
boolean_t thread_call_enter1(thread_call_t call, thread_call_param_t param1);
boolean_t thread_call_enter_delayed(thread_call_t call, uint64_t deadline);
boolean_t thread_call_enter1_delayed(thread_call_t call, thread_call_param_t param1, uint64_t deadline);
boolean_t thread_call_cancel(thread_call_t call);
[not exported from kernel:]
thread_call_t thread_call_allocate_with_priority(thread_call_func_t
func, thread_call_param_t param0,
thread_call_priority_t pri);
boolean_t thread_call_cancel_wait(thread_call_t call);
void thread_call_func_delayed(thread_call_func_t func, thread_call_param_t param, uint64_t deadline);
boolean_t thread_call_func_cancel(thread_call_func_t func, thread_call_param_t param, boolean_t cancel_all);
boolean_t thread_call_isactive(thread_call_t call);
Priority: THREAD_CALL_PRIORITY_HIGH/KERNEL/USER/LOW. Default
is HIGH.
HIGH – higher than anything but realtime threads (prio = BASEPRI_PREEMPT = 93).
KERNEL – similar to regular kernel threads (prio = BASEPRI_KERNEL = 81).
Wakes up processing thread or creates it if it does not exist (or additional
threads if the pending queue is long).
HIGH is executed in serial, KERNEL and all others may execute in parallel if
pending load is high.
Ok to call thread_call_enter_xxx while the item is already queued or
executing.
thread_call_cancel: If the call is on the queue and has not yet begun
executing, the pending invocation will be removed off the queue and TRUE will
be returned. If the work item has already begun executing, thread_call_cancel
will return FALSE immediately. If call is not queued at all nor executing, will
return FALSE. Thus cannot differentiate between "executing" and
"inactive" states.
thread_call_cancel_wait: If the call is on the queue and has not yet begun
executing, will remove pending invocation off the queue and return TRUE. If the
work item has already begun executing, thread_call_cancel will wait for
the invocation to finish and return FALSE. If call is inactive (neither queued
nor executing), thread_call_cancel returns FALSE.
Both cancel routines may only be used on thread calls set up with either thread_call_allocate
or thread_call_allocate_with_priority. Invocations of the thread call
after the current invocation may be in flight when thread_call_cancel_wait
returns. Neither cancel routine handles reissuing of thread_call_enter_xxx
by call handler or other code.
#include <IOKit/IOTimerEventSource.h>
see https://developer.apple.com/search/index.php?q=IOTimerEventSource
based on thread_call_xxx
Kernel also has other functions unavailable to kernel extensions: thread_set_timer, thread_set_timer_deadline, thread_cancel_timer (exported from kernel but not declared in kext headers, not present at all in LP64 kernel).
Kernel threads:
Threads belong to containing tasks ("processes").
Thread CPU affinity (thread_assign, thread_assign_default, thread_get_assignment)
is not actually implemented in OS X.
NX = not exported from kernel
#include <kern/thread.h>
#include <mach/thread_act.h>
#include <kern/task.h>
kern_return_t kernel_thread_start(thread_continue_t continuation,
void * parameter, thread_t * new_thread);
typedef void (*thread_continue_t)(void* parameter,
wait_result_t wr);
Returns KERN_SUCCESS or error status.
Caller should do thread_deallocate(), on KERN_SUCCESS only.
wr is unused (for thread startup case).
Created thread is a part of kernel_task, with initial priority of
BASEPRI_KERNEL (81).
void thread_reference(thread_t
thread); //
increment reference count (initial = 2)
void thread_deallocate(thread_t thread); // decrement reference count, on final
dereference destroy thread
thread_t current_thread(void);
kern_return_t thread_terminate(current_thread();
// only for the current
thread
kern_return_t thread_abort(thread_t thread);
// NX: destroy the thread (does not apply to kernel threads?)
kern_return_t thread_abort_safely(thread_t thread); // NX: destroy the thread if it is at
safe point (does not apply to kernel threads?)
There is no primitive exported from the kernel to wait for a thread termination, can only poll. After the thread is terminated, the following functions return KERN_TERMINATED: thread_policy_set, (the rest is NX:) thread_info, thread_get_state, thread_policy_get, thread_abort, thread_abort_safely. Once done with checking them, can do thread_deallocate().
#include <mach/thread_info.h>
kern_return_t thread_info
// NX
(
thread_t thread,
thread_flavor_t flavor,
thread_info_t info,
// pointer to the buffer
mach_msg_type_number_t* count
// in-out size in units
of natural_t (= unsigned int)
);
THREAD_BASIC_INFO => thread_basic_info (CPU usage, sched policy, suspend count, state, flags)
THREAD_SCHED_FIFO_INFO => policy_fifo_info
THREAD_SCHED_RR_INFO => policy_rr_info
THREAD_SCHED_TIMESHARE_INFO => policy_timeshare_info
kern_return_t thread_get_state // NX: retrieve x86_thread_state or arm_thread_state_t
(
thread_t thread,
thread_state_flavor_t flavor,
thread_state_t state,
mach_msg_type_number_t* stateCount
);
kern_return_t thread_get_special_port // NX
(
thread_t thread,
int which_port, // only THREAD_KERNEL_PORT
mach_port_t* special_port
);
uint64_t
thread_tid() ;
task_t current_task();
#include <sys/proc.h>
struct proc* current_proc();
(struct proc*) get_bsdtask_info(task_t
task) ; // unaccessible from extensions (exported, not declared in
kext headers)
(struct uthread*) get_bsdthread_info(thread_t thread);
// ... (not exported)
Thread priority:
#include <mach/kern_policy.h>
kern_return_t thread_policy_set // this is the only priority control function exported from kernel
(
thread_t thread,
thread_policy_flavor_t flavor,
thread_policy_t policy_info,
mach_msg_type_number_t policy_infoCnt
);
See https://developer.apple.com/library/mac/#documentation/Darwin/Conceptual/KernelProgramming/scheduler/scheduler.html.
THREAD_EXTENDED_POLICY => thread_extended_policy_data_t
THREAD_TIME_CONSTRAINT_POLICY => thread_time_constraint_policy_data_t (expected time demands)
THREAD_PRECEDENCE_POLICY => thread_precedence_policy_data_t (precedence relative to other threads in the task)
THREAD_AFFINITY_POLICY => thread_affinity_policy_data_t (co-schedule to share L2 cache)
THREAD_BACKGROUND_POLICY => thread_background_policy_data_t (embedded i.e. iOS only)
Default is STANDARD_POLICY, which is deprecated in
favor of EXTENDED_POLICY with timeshare = true.
TIME_CONSTRAINT_POLICY (period, computation, constraint, preemptible) = soft
real-time, boosts priority to real-time range.
PRECEDENCE_POLICY: importance = signed difference with task base
priority, for kernel_task the latter is BASEPRI_KERNEL.
thread_precedence_data_policy_t policy;
policy.importance = -MAXPRI ... +MAXPRI; //
MAXPRI is 127
kr = thread_policy_set(pthread_mach_thread_np(t1),
THREAD_PRECEDENCE_POLICY,
(thread_policy_t) &policy, //
delta is relative to task priority
THREAD_PRECEDENCE_POLICY_COUNT);
// result is constrained to [MINPRI (0) ... thread->max_priority], for kernel threads the latter is MAXPRI_KERNEL
// for real-time threads (TH_MODE_REALTIME), always
BASEPRI_RTQUEUES (97)
Threads started by kernel_thread_start have initial priority of BASEPRI_KERNEL (81) which can be changed in range
0 to MAXPRI_KERNEL (95). Calculated as newprio = BASEPRI_KERNEL +
policy.importance.
kern_return_t thread_policy_get // NX
(
thread_t thread,
thread_policy_flavor_t flavor, // THREAD_xxx_POLICY
thread_policy_t policy_info,
mach_msg_type_number_t* policy_infoCnt,
boolean_t* get_default // in: get default (true) or current (false)
);
#include <mach/policy.h>
kern_return_t thread_set_policy // NX: PTHREADS-like
(
thread_t thread,
processor_set_t pset,
policy_t policy, // POLICY_xxx
policy_base_t base,
mach_msg_type_number_t baseCnt,
policy_limit_t limit,
mach_msg_type_number_t limitCnt
);
kern_return_t thread_policy // NX
(
thread_t thread,
policy_t policy, // POLICY_xxx
policy_base_t base,
mach_msg_type_number_t baseCnt,
boolean_t set_limit // if true, in addition to setting base,
); // set also limits to the same as base
POLICY_TIMESHARE => policy_timeshare_base, policy_timeshare_limit, policy_timeshare_info
POLICY_RR => policy_rr_base/limit/info
POLICY_FIFO => policy_fifo_base/limit/info
Devices:
There is no interlocking protocol for cdevsw_add/remove,
however loading/unloading of extensions happens under sKextLock, so
creation and deletion of cdevsw from kext start/stop routines is effectively
interlocked against start/stop routine in other kext modules.
DevFS routines do perform internal locking.
There is no provision for subdirectories under /dev.
#include <sys/conf.h>
struct cdevsw mydev_cdevsw;
int major = cdevsw_add(-24, &mydev_cdevsw);
if (major < 0) ... cannot allocate ...
.....
cdevsw_remove(major, &mydev_cdevsw);
#include <miscfs/devfs/devfs.h>
void* handle = devfs_make_node(makedev(major, minor), DEVFS_CHAR, UID_ROOT,
GID_WHEEL, 0600, "mydev");
if (handle ==NULL) ... error ...
...
devfs_remove(handle);
Sysctl:
#include <sys/sysctl.h>
static int32_t mytest_sysctl_x = 1;
static uint64_t mytest_sysctl_y = 2;
static char mytest_sysctl_s[100] = "initial_s";
SYSCTL_NODE (_user, OID_AUTO, mytest, CTLFLAG_RD|CTLFLAG_LOCKED, NULL, "mytest data directory");
SYSCTL_INT (_user_mytest, OID_AUTO, x, CTLFLAG_RW |CTLFLAG_KERN | CTLFLAG_LOCKED, &mytest_sysctl_x, 0, "explain x");
SYSCTL_QUAD (_user_mytest, OID_AUTO, y, CTLFLAG_RW |CTLFLAG_KERN | CTLFLAG_LOCKED, &mytest_sysctl_y, 0, "explain y");
SYSCTL_NODE (_user_mytest, OID_AUTO, sub, CTLFLAG_RD|CTLFLAG_LOCKED, NULL,
"mytest data subdirectory");
SYSCTL_STRING (_user_mytest_sub, OID_AUTO, s,
CTLFLAG_RW | CTLFLAG_KERN | CTLFLAG_LOCKED,
mytest_sysctl_s,
sizeof(mytest_sysctl_s), "explain s");
sysctl_register_oid(&sysctl__user_mytest);
sysctl_register_oid(&sysctl__user_mytest_x);
sysctl_register_oid(&sysctl__user_mytest_y);
sysctl_register_oid(&sysctl__user_mytest_sub);
sysctl_register_oid(&sysctl__user_mytest_sub_s);
sysctl_unregister_oid(&sysctl__user_mytest);
sysctl_unregister_oid(&sysctl__user_mytest_x);
sysctl_unregister_oid(&sysctl__user_mytest_y);
sysctl_unregister_oid(&sysctl__user_mytest_sub);
sysctl_unregister_oid(&sysctl__user_mytest_sub_s);
Misc:
OS X kexts have only start/stop functions, no FreeBSD-like "queiescent" function.
void IOSleep(unsigned milliseconds);
void IODelay(unsigned microseconds); // spin
void IOPause(unsigned nanoseconds); // spin
void delay(int usec); // spin if usec is very short or interrupts disabled or preemption is disabled
// otherwise sleep
void Debugger(const char * reason);
#ifdef __cplusplus
class OSDictionary;
#endif
#ifdef __cplusplus
OSDictionary *
#else
struct OSDictionary *
#endif
IOBSDNameMatching( const char * name );
#ifdef __cplusplus
OSDictionary *
#else
struct OSDictionary *
#endif
IOOFPathMatching( const char * path, char * buf, int maxLen ) __attribute__((deprecated));
/* Convert between size and a power-of-two alignment */
IOAlignment IOSizeToAlignment(unsigned int size);
unsigned int IOAlignmentToSize(IOAlignment align);
OS X has work queues (workq_open etc.) but they are not
exported from kernel to extensions.
OS X has kqueue/kevent facility for kernel to send events to userland.
Exported public symbol list (excluding C++ exports):
IOLockLock = lck_mtx_lock
IOLockTryLock = lck_mtx_try_lock
IOLockUnlock = lck_mtx_unlock
IORWLockRead = lck_rw_lock_shared
IORWLockUnlock = lck_rw_done
IORWLockWrite = lck_rw_lock_exclusive
IOSimpleLockLock = lck_spin_lock
IOSimpleLockTryLock = lck_spin_try_lock
IOSimpleLockUnlock = lck_spin_unlock
ifnet_resolve_multicast = dlil_resolve_multi
in6_cksum = inet6_cksum
in_cksum = inet_cksum_simple
inet_arp_handle_input = arp_ip_handle_input
inet_arp_init_ifaddr = arp_ifinit
inet_arp_lookup = arp_lookup_ip
sha1_init = SHA1Init
sha1_loop = SHA1Update
sha1_result = SHA1Final_r
Assert
Debugger
FastUnicodeCompare
IOAlignmentToSize
IOBSDNameMatching
IOBSDRegistryEntryForDeviceTree
IOBSDRegistryEntryGetData
IOBSDRegistryEntryRelease
IOCDMatching
IOCreateThread
IODTFreeLoaderInfo
IODTGetLoaderInfo
IODelay
IODiskMatching
IOExitThread
IOFindBSDRoot
IOFindMatchingChild
IOFindNameForValue
IOFindValueForName
IOFlushProcessorCache
IOFree
IOFreeAligned
IOFreeContiguous
IOFreePageable
IOGetTime
IOIteratePageableMaps
IOKitBSDInit
IOKitResetTime
IOLibInit
IOLockAlloc
IOLockFree
IOLockGetMachLock
IOLockInitWithState
IOLockSleep
IOLockSleepDeadline
IOLockWakeup
IOLog
IOLogv
IOMalloc
IOMallocAligned
IOMallocContiguous
IOMallocPageable
IOMappedRead16
IOMappedRead32
IOMappedRead64
IOMappedRead8
IOMappedWrite16
IOMappedWrite32
IOMappedWrite64
IOMappedWrite8
IOMapperIOVMAlloc
IOMapperIOVMFree
IOMapperInsertPPNPages
IOMapperInsertPage
IOMapperInsertUPLPages
IONDRVLibrariesInitialize
IONetworkMatching
IONetworkNamePrefixMatching
IOOFPathMatching
IOPageableMapForAddress
IOPause
IOPrintPlane
IORWLockAlloc
IORWLockFree
IORWLockGetMachLock
IORecursiveLockAlloc
IORecursiveLockAllocWithLockGroup
IORecursiveLockFree
IORecursiveLockGetMachLock
IORecursiveLockHaveLock
IORecursiveLockLock
IORecursiveLockSleep
IORecursiveLockSleepDeadline
IORecursiveLockTryLock
IORecursiveLockUnlock
IORecursiveLockWakeup
IOSetProcessorCacheMode
IOSimpleLockAlloc
IOSimpleLockFree
IOSimpleLockGetMachLock
IOSimpleLockInit
IOSizeToAlignment
IOSleep
IOSpinUnlock
IOSystemShutdownNotification
IOTrySpinLock
IOZeroTvalspec
KUNCExecute
KUNCGetNotificationID
KUNCUserNotificationDisplayAlert
KUNCUserNotificationDisplayFromBundle
KUNCUserNotificationDisplayNotice
MD5Final
MD5Init
MD5Update
NDR_record
OSAddAtomic
OSAddAtomic16
OSAddAtomic64
OSAddAtomic8
OSBacktrace
OSBitAndAtomic
OSBitAndAtomic16
OSBitAndAtomic8
OSBitOrAtomic
OSBitOrAtomic16
OSBitOrAtomic8
OSBitXorAtomic
OSBitXorAtomic16
OSBitXorAtomic8
OSCompareAndSwap
OSCompareAndSwap64
OSCompareAndSwapPtr
OSDecrementAtomic
OSDecrementAtomic16
OSDecrementAtomic8
OSFree
OSIncrementAtomic
OSIncrementAtomic16
OSIncrementAtomic8
OSKernelStackRemaining
OSKextCancelRequest
OSKextLoadKextWithIdentifier
OSKextReleaseKextWithLoadTag
OSKextRequestResource
OSKextRetainKextWithLoadTag
OSMalloc
OSMalloc_Tagalloc
OSMalloc_Tagfree
OSMalloc_noblock
OSMalloc_nowait
OSPrintMemory
OSReportWithBacktrace
OSSpinLockTry
OSSpinLockUnlock
OSTestAndClear
OSTestAndSet
OSUnserializechar
OSUnserializelval
OSUnserializenerrs
OSlibkernInit
PEGetGMTTimeOfDay
PEGetMachineName
PEGetModelName
PEGetPlatformEpoch
PEHaltRestart
PESavePanicInfo
PESetGMTTimeOfDay
PE_call_timebase_callback
PE_cpu_halt
PE_cpu_machine_init
PE_cpu_machine_quiesce
PE_cpu_signal
PE_cpu_start
PE_enter_debugger
PE_halt_restart
PE_kputc
PE_parse_boot_argn
PE_poll_input
PE_state
SHA1Final
SHA1Init
SHA1Update
STRDUP
StartIOKit
VNOP_BWRITE
VNOP_FSYNC
VNOP_IOCTL
VNOP_READ
VNOP_STRATEGY
VNOP_WRITE
_FREE
_FREE_ZONE
_MALLOC
_MALLOC_ZONE
__bzero
__cxa_pure_virtual
__stack_chk_fail
__stack_chk_guard
_doprnt
_dtrace_register_anon_DOF
_giDebugLogDataInternal
_giDebugLogInternal
_giDebugReserved1
_giDebugReserved2
absolutetime_to_nanoseconds
acknowledgeSleepWakeNotification
adler32
advisory_read
advisory_read_ext
aes_decrypt_cbc
aes_decrypt_key
aes_decrypt_key128
aes_decrypt_key256
aes_encrypt_cbc
aes_encrypt_key
aes_encrypt_key128
aes_encrypt_key256
appleClut8
assert_wait
assert_wait_deadline
assert_wait_timeout
atoi
bcd2bin_data
bcmp
bcopy
bcopy_phys
bdevsw_add
bdevsw_isfree
bdevsw_remove
boot
bpf_attach
bpf_tap_in
bpf_tap_out
bpfattach
bsd_timeout
bsd_untimeout
buf_alloc
buf_bawrite
buf_bdwrite
buf_biodone
buf_biowait
buf_blkno
buf_bread
buf_breadn
buf_brelse
buf_bwrite
buf_callback
buf_clear
buf_clear_redundancy_flags
buf_clearflags
buf_clone
buf_count
buf_dataptr
buf_device
buf_dirtyend
buf_dirtyoff
buf_drvdata
buf_error
buf_flags
buf_flushdirtyblks
buf_free
buf_fromcache
buf_fsprivate
buf_fua
buf_getblk
buf_geteblk
buf_invalblkno
buf_invalidateblks
buf_iterate
buf_lblkno
buf_map
buf_markaged
buf_markclean
buf_markdelayed
buf_markeintr
buf_markfua
buf_markinvalid
buf_meta_bread
buf_meta_breadn
buf_proc
buf_rcred
buf_redundancy_flags
buf_reset
buf_resid
buf_set_redundancy_flags
buf_setblkno
buf_setcallback
buf_setcount
buf_setdataptr
buf_setdevice
buf_setdirtyend
buf_setdirtyoff
buf_setdrvdata
buf_seterror
buf_setflags
buf_setfsprivate
buf_setlblkno
buf_setresid
buf_setsize
buf_setupl
buf_setvnode
buf_size
buf_strategy
buf_unmap
buf_upl
buf_uploffset
buf_valid
buf_vnode
buf_wcred
bzero
bzero_phys
cache_enter
cache_lookup
cache_purge
cache_purge_negatives
cdevsw_add
cdevsw_add_with_bdev
cdevsw_isfree
cdevsw_remove
clock_absolutetime_interval_to_deadline
clock_delay_until
clock_get_calendar_microtime
clock_get_calendar_nanotime
clock_get_system_microtime
clock_get_system_nanotime
clock_get_uptime
clock_interval_to_absolutetime_interval
clock_interval_to_deadline
clock_timebase_info
cluster_bp
cluster_bp_ext
cluster_copy_ubc_data
cluster_copy_upl_data
cluster_pagein
cluster_pagein_ext
cluster_pageout
cluster_pageout_ext
cluster_push
cluster_push_ext
cluster_read
cluster_read_ext
cluster_write
cluster_write_ext
cluster_zero
cons_cinput
cons_ops
conslog_putc
convert_port_entry_to_map
convert_port_entry_to_object
copyin
copyinstr
copyout
copyoutstr
copystr
cpu_number
crc32
ctl_deregister
ctl_enqueuedata
ctl_enqueuembuf
ctl_getenqueuespace
ctl_register
current_act
current_proc
current_task
current_thread
db_dumpiojunk
db_piokjunk
debug_container_malloc_size
debug_iomalloc_size
debug_ivars_size
debug_malloc_size
deflate
deflateCopy
deflateEnd
deflateInit2_
deflateInit_
deflateParams
deflateReset
deflateSetDictionary
delay
delay_for_interval
des_ecb_encrypt
des_set_key
desiredvnodes
devfs_make_node
devfs_make_node_clone
devfs_remove
device_close
device_data_action
di_root_image
dsmos_page_transform_hook
enodev
enodev_strat
enoioctl
enosys
enxio
eopnotsupp
err_access
err_advlock
err_allocate
err_blktooff
err_blockmap
err_bwrite
err_close
err_copyfile
err_create
err_exchange
err_fsync
err_getattr
err_inactive
err_ioctl
err_link
err_mkdir
err_mknod
err_mmap
err_offtoblk
err_open
err_pagein
err_pageout
err_pathconf
err_read
err_readdir
err_readdirattr
err_readlink
err_reclaim
err_remove
err_rename
err_revoke
err_rmdir
err_searchfs
err_select
err_setattr
err_strategy
err_symlink
err_whiteout
err_write
ether_add_proto
ether_check_multi
ether_del_proto
ether_demux
ether_frameout
ether_ioctl
ev_try_lock
ev_unlock
ffs
fifo_advlock
fifo_close
fifo_inactive
fifo_ioctl
fifo_lookup
fifo_open
fifo_pathconf
fifo_read
fifo_select
fifo_write
file_drop
file_flags
file_socket
file_vnode_withvid
flush_dcache
flush_dcache64
fubyte
fuibyte
fuiword
futimes
fuword
gIOAppPowerStateInterest
gIOBusyInterest
gIOCatalogue
gIOClassKey
gIOCommandPoolSizeKey
gIODTAAPLInterruptsKey
gIODTAddressCellKey
gIODTCompatibleKey
gIODTDefaultInterruptController
gIODTInterruptCellKey
gIODTInterruptParentKey
gIODTModelKey
gIODTNWInterruptMappingKey
gIODTNameKey
gIODTPHandleKey
gIODTPersistKey
gIODTPlane
gIODTRangeKey
gIODTSharedInterrupts
gIODTSizeCellKey
gIODTTypeKey
gIODTUnitKey
gIODefaultMatchCategoryKey
gIODeviceMemoryKey
gIOFirstMatchNotification
gIOFirstPublishNotification
gIOGeneralInterest
gIOInterruptControllersKey
gIOInterruptSpecifiersKey
gIOKernelConfigTables
gIOKitDebug
gIOKitDebugKey
gIOLocationKey
gIOLocationMatchKey
gIOMatchCategoryKey
gIOMatchedNotification
gIOMatchedServiceCountKey
gIOModuleIdentifierKey
gIONameKey
gIONameMatchKey
gIONameMatchedKey
gIOParentMatchKey
gIOPathMatchKey
gIOPlatformActiveActionKey
gIOPlatformQuiesceActionKey
gIOPlatformSleepActionKey
gIOPlatformWakeActionKey
gIOPowerPlane
gIOPriorityPowerStateInterest
gIOProbeScoreKey
gIOPropertyMatchKey
gIOProviderClassKey
gIOPublishNotification
gIORangeAllocatorLock
gIOResourceMatchKey
gIOResourcesKey
gIOServiceKey
gIOServicePlane
gIOTerminatedNotification
gIOUserClientClassKey
gOFVariables
gOSKextUnresolved
gOSObjectTrackList
gOSObjectTrackThread
gPEClockFrequencyInfo
gPEEFIRuntimeServices
gPEEFISystemTable
gPESerialBaud
gPlatformInterruptControllerName
get_bsdtask_info
get_task_map
getsectdatafromheader
groupmember
hashinit
hfs_addconverter
hfs_getconverter
hfs_pickencoding
hfs_relconverter
hfs_remconverter
hibernate_vm_lock
hibernate_vm_unlock
host_get_special_port
host_priv_self
host_vmxoff
host_vmxon
hz
ifaddr_address
ifaddr_address_family
ifaddr_dstaddress
ifaddr_findbestforaddr
ifaddr_ifnet
ifaddr_netmask
ifaddr_reference
ifaddr_release
ifaddr_withaddr
ifaddr_withdstaddr
ifaddr_withnet
ifaddr_withroute
iflt_attach
iflt_detach
ifmaddr_address
ifmaddr_ifnet
ifmaddr_lladdress
ifmaddr_reference
ifmaddr_release
ifnet_add_multicast
ifnet_addrlen
ifnet_allocate
ifnet_attach
ifnet_attach_protocol
ifnet_baudrate
ifnet_capabilities_enabled
ifnet_capabilities_supported
ifnet_detach
ifnet_detach_protocol
ifnet_eflags
ifnet_event
ifnet_family
ifnet_find_by_name
ifnet_flags
ifnet_free_address_list
ifnet_free_multicast_list
ifnet_get_address_list
ifnet_get_address_list_family
ifnet_get_link_mib_data
ifnet_get_link_mib_data_length
ifnet_get_multicast_list
ifnet_get_tso_mtu
ifnet_get_wake_flags
ifnet_hdrlen
ifnet_index
ifnet_input
ifnet_interface_family_find
ifnet_ioctl
ifnet_lastchange
ifnet_list_free
ifnet_list_get
ifnet_lladdr
ifnet_lladdr_copy_bytes
ifnet_llbroadcast_copy_bytes
ifnet_metric
ifnet_mtu
ifnet_name
ifnet_offload
ifnet_output
ifnet_output_raw
ifnet_reference
ifnet_release
ifnet_remove_multicast
ifnet_set_addrlen
ifnet_set_baudrate
ifnet_set_capabilities_enabled
ifnet_set_capabilities_supported
ifnet_set_eflags
ifnet_set_flags
ifnet_set_hdrlen
ifnet_set_link_mib_data
ifnet_set_lladdr
ifnet_set_metric
ifnet_set_mtu
ifnet_set_offload
ifnet_set_promiscuous
ifnet_set_stat
ifnet_set_tso_mtu
ifnet_set_wake_flags
ifnet_softc
ifnet_stat
ifnet_stat_increment
ifnet_stat_increment_in
ifnet_stat_increment_out
ifnet_touch_lastchange
ifnet_type
ifnet_unit
iftovt_tab
inet_aton
inet_ntop
inflate
inflateEnd
inflateInit2_
inflateInit_
inflateReset
inflateSetDictionary
inflateSync
inflateSyncPoint
invalidate_icache
invalidate_icache64
ipc_kernel_map
ipf_addv4
ipf_addv6
ipf_inject_input
ipf_inject_output
ipf_remove
is_file_clean
isdisk
itoa
kOSBooleanFalse
kOSBooleanTrue
kalloc
kauth_acl_alloc
kauth_acl_free
kauth_authorize_action
kauth_authorize_process
kauth_cred_create
kauth_cred_find
kauth_cred_get
kauth_cred_get_with_ref
kauth_cred_getgid
kauth_cred_getguid
kauth_cred_getntsid
kauth_cred_getrgid
kauth_cred_getruid
kauth_cred_getsvgid
kauth_cred_getsvuid
kauth_cred_getuid
kauth_cred_gid2guid
kauth_cred_gid2ntsid
kauth_cred_guid2gid
kauth_cred_guid2ntsid
kauth_cred_guid2uid
kauth_cred_ismember_gid
kauth_cred_ismember_guid
kauth_cred_issuser
kauth_cred_label_update
kauth_cred_ntsid2gid
kauth_cred_ntsid2guid
kauth_cred_ntsid2uid
kauth_cred_proc_ref
kauth_cred_ref
kauth_cred_uid2guid
kauth_cred_uid2ntsid
kauth_cred_unref
kauth_deregister_scope
kauth_filesec_alloc
kauth_filesec_free
kauth_getgid
kauth_getruid
kauth_getuid
kauth_guid_equal
kauth_listen_scope
kauth_null_guid
kauth_proc_label_update
kauth_register_scope
kauth_unlisten_scope
kdebug_enable
kdp_register_callout
kdp_register_send_receive
kdp_set_interface
kdp_set_ip_and_mac_addresses
kdp_unregister_send_receive
kern_os_free
kern_os_malloc
kern_os_malloc_size
kern_os_realloc
kernel_debug
kernel_debug1
kernel_map
kernel_pmap
kernel_task
kernel_thread_start
kernproc
kev_msg_post
kev_post_msg
kev_vendor_code_find
kfree
kmem_alloc
kmem_free
kmputc
knote
knote_attach
knote_detach
kprintf
lapic_set_perfcnt_interrupt_mask
lapic_set_pmi_func
lck_attr_alloc_init
lck_attr_free
lck_attr_setdebug
lck_attr_setdefault
lck_grp_alloc_init
lck_grp_attr_alloc_init
lck_grp_attr_free
lck_grp_attr_setdefault
lck_grp_attr_setstat
lck_grp_free
lck_mtx_alloc_init
lck_mtx_assert
lck_mtx_convert_spin
lck_mtx_destroy
lck_mtx_free
lck_mtx_init
lck_mtx_lock
lck_mtx_lock_spin
lck_mtx_sleep
lck_mtx_sleep_deadline
lck_mtx_try_lock
lck_mtx_try_lock_spin
lck_mtx_unlock
lck_rw_alloc_init
lck_rw_destroy
lck_rw_done
lck_rw_free
lck_rw_init
lck_rw_lock
lck_rw_lock_exclusive
lck_rw_lock_exclusive_to_shared
lck_rw_lock_shared
lck_rw_lock_shared_to_exclusive
lck_rw_sleep
lck_rw_sleep_deadline
lck_rw_try_lock
lck_rw_unlock
lck_rw_unlock_exclusive
lck_rw_unlock_shared
lck_spin_alloc_init
lck_spin_destroy
lck_spin_free
lck_spin_init
lck_spin_lock
lck_spin_sleep
lck_spin_sleep_deadline
lck_spin_try_lock
lck_spin_unlock
ldisc_deregister
ldisc_register
log
mach_absolute_time
mach_gss_accept_sec_context
mach_gss_accept_sec_context_v2
mach_gss_hold_cred
mach_gss_init_sec_context
mach_gss_init_sec_context_v2
mach_gss_unhold_cred
mach_make_memory_entry_64
mach_memory_entry_page_op
mach_memory_entry_range_op
mach_msg_rpc_from_kernel_proper
mach_msg_send_from_kernel_proper
mach_vm_pressure_monitor
mach_vm_region
max_mem
mbuf_adj
mbuf_adjustlen
mbuf_align_32
mbuf_alloccluster
mbuf_allocpacket
mbuf_allocpacket_list
mbuf_attachcluster
mbuf_clear_csum_performed
mbuf_clear_csum_requested
mbuf_clear_vlan_tag
mbuf_concatenate
mbuf_copy_pkthdr
mbuf_copyback
mbuf_copydata
mbuf_copym
mbuf_data
mbuf_data_to_physical
mbuf_datastart
mbuf_dup
mbuf_flags
mbuf_free
mbuf_freecluster
mbuf_freem
mbuf_freem_list
mbuf_get
mbuf_get_csum_performed
mbuf_get_csum_requested
mbuf_get_mhlen
mbuf_get_minclsize
mbuf_get_mlen
mbuf_get_traffic_class
mbuf_get_tso_requested
mbuf_get_vlan_tag
mbuf_getcluster
mbuf_gethdr
mbuf_getpacket
mbuf_inbound_modified
mbuf_inet6_cksum
mbuf_inet_cksum
mbuf_leadingspace
mbuf_len
mbuf_maxlen
mbuf_mclget
mbuf_mclhasreference
mbuf_next
mbuf_nextpkt
mbuf_outbound_finalize
mbuf_pkthdr_adjustlen
mbuf_pkthdr_header
mbuf_pkthdr_len
mbuf_pkthdr_rcvif
mbuf_pkthdr_setheader
mbuf_pkthdr_setlen
mbuf_pkthdr_setrcvif
mbuf_prepend
mbuf_pulldown
mbuf_pullup
mbuf_set_csum_performed
mbuf_set_csum_requested
mbuf_set_traffic_class
mbuf_set_vlan_tag
mbuf_setdata
mbuf_setflags
mbuf_setflags_mask
mbuf_setlen
mbuf_setnext
mbuf_setnextpkt
mbuf_settype
mbuf_split
mbuf_stats
mbuf_tag_allocate
mbuf_tag_find
mbuf_tag_free
mbuf_tag_id_find
mbuf_trailingspace
mbuf_type
mem_size
memcmp
memcpy
memmove
memory_object_page_op
memset
microtime
microuptime
mig_dealloc_reply_port
mig_get_reply_port
mig_put_reply_port
mig_strncpy
mig_user_allocate
mig_user_deallocate
minphys
ml_at_interrupt_context
ml_cpu_int_event_time
ml_get_apicid
ml_get_interrupts_enabled
ml_get_maxbusdelay
ml_get_maxsnoop
ml_io_map
ml_phys_read
ml_phys_write
ml_probe_read
ml_processor_register
ml_set_interrupts_enabled
ml_thread_policy
mountroot_post_hook
mp_rendezvous
mp_rendezvous_no_intrs
msleep
msleep1
nanoseconds_to_absolutetime
nanotime
nanouptime
nd6_lookup_ipv6
net_init_add
nop_access
nop_advlock
nop_allocate
nop_blktooff
nop_blockmap
nop_bwrite
nop_close
nop_copyfile
nop_create
nop_exchange
nop_fsync
nop_getattr
nop_inactive
nop_ioctl
nop_link
nop_mkdir
nop_mknod
nop_mmap
nop_offtoblk
nop_open
nop_pagein
nop_pageout
nop_pathconf
nop_read
nop_readdir
nop_readdirattr
nop_readlink
nop_reclaim
nop_remove
nop_rename
nop_revoke
nop_rmdir
nop_searchfs
nop_select
nop_setattr
nop_strategy
nop_symlink
nop_whiteout
nop_write
nulldev
nullop
osrelease
ostype
ovbcopy
page_mask
page_shift
page_size
panic
physio
pmCPUControl
pmKextRegister
pmap_find_phys
populate_model_name
preemption_enabled
prf
printf
proc_exiting
proc_find
proc_forcequota
proc_is64bit
proc_is_classic
proc_isinferior
proc_issignal
proc_name
proc_noremotehang
proc_pgrpid
proc_pid
proc_ppid
proc_rele
proc_self
proc_selfname
proc_selfpgrpid
proc_selfpid
proc_selfppid
proc_signal
proc_suser
proc_tbe
processor_exit
processor_info
processor_start
proto_inject
proto_input
proto_register_plumber
proto_unregister_plumber
putc
random
rc4_crypt
rc4_init
rdmsr_carefully
read_random
real_ncpus
registerPrioritySleepWakeInterest
registerSleepWakeInterest
rtc_clock_napped
securelevel
selrecord
selthreadclear
seltrue
selwait
selwakeup
semaphore_create
semaphore_dereference
semaphore_destroy
semaphore_reference
semaphore_signal
semaphore_signal_all
semaphore_wait
semaphore_wait_deadline
semaphore_wait_noblock
serial_getc
serial_init
serial_putc
set_fsblocksize
sflt_attach
sflt_detach
sflt_register
sflt_unregister
sha1_hardware_hook
sleep
snprintf
sock_accept
sock_bind
sock_close
sock_connect
sock_connectwait
sock_getpeername
sock_getsockname
sock_getsockopt
sock_gettype
sock_inject_data_in
sock_inject_data_out
sock_ioctl
sock_isconnected
sock_isnonblocking
sock_listen
sock_nointerrupt
sock_receive
sock_receivembuf
sock_release
sock_retain
sock_send
sock_sendmbuf
sock_setpriv
sock_setsockopt
sock_shutdown
sock_socket
sockopt_copyin
sockopt_copyout
sockopt_direction
sockopt_level
sockopt_name
sockopt_valsize
spec_close
spec_ebadf
spec_fsync
spec_ioctl
spec_lookup
spec_open
spec_pathconf
spec_read
spec_select
spec_strategy
spec_write
sprintf
sscanf
stack_privilege
strcasecmp
strcat
strchr
strcmp
strcpy
strlcat
strlcpy
strlen
strncasecmp
strncat
strncmp
strncpy
strnlen
strprefix
strtol
strtoq
strtoul
strtouq
subyte
suibyte
suiword
suword
sysctl__children
sysctl__debug_children
sysctl__kern_children
sysctl__machdep_children
sysctl__net_children
sysctl__sysctl_children
sysctl__vfs_children
sysctl__vfs_generic
sysctl__vfs_generic_children
sysctl__vm_children
sysctl_handle_int
sysctl_handle_int2quad
sysctl_handle_long
sysctl_handle_opaque
sysctl_handle_quad
sysctl_handle_string
sysctl_int
sysctl_mib_init
sysctl_quad
sysctl_rdint
sysctl_rdquad
sysctl_rdstring
sysctl_rdstruct
sysctl_register_all
sysctl_register_fixed
sysctl_register_oid
sysctl_register_set
sysctl_string
sysctl_struct
sysctl_unregister_oid
sysctl_unregister_set
sysctlbyname
task_deallocate
task_get_special_port
task_reference
task_resume
task_suspend
thread_block
thread_block_parameter
thread_call_allocate
thread_call_cancel
thread_call_enter
thread_call_enter1
thread_call_enter1_delayed
thread_call_enter_delayed
thread_call_free
thread_deallocate
thread_issignal
thread_notrigger
thread_policy_set
thread_reference
thread_terminate
thread_tid
thread_wakeup_prim
timevaladd
timevalfix
timevalsub
tmrCvt
tsc_get_info
tsleep
tvtoabstime
ubc_blktooff
ubc_create_upl
ubc_getcred
ubc_getsize
ubc_msync
ubc_offtoblk
ubc_page_op
ubc_pages_resident
ubc_range_op
ubc_setsize
ubc_setthreadcred
ubc_upl_abort
ubc_upl_abort_range
ubc_upl_commit
ubc_upl_commit_range
ubc_upl_map
ubc_upl_maxbufsize
ubc_upl_pageinfo
ubc_upl_unmap
uio_addiov
uio_create
uio_curriovbase
uio_curriovlen
uio_duplicate
uio_free
uio_getiov
uio_iovcnt
uio_isuserspace
uio_offset
uio_reset
uio_resid
uio_rw
uio_setoffset
uio_setresid
uio_setrw
uio_update
uiomove
uiomove64
unicode_combinable
unicode_decomposeable
upl_dirty_page
upl_page_present
upl_valid_page
useracc
utf8_decodestr
utf8_encodelen
utf8_encodestr
utf8_normalizestr
utf8_validatestr
uuid_clear
uuid_compare
uuid_copy
uuid_generate
uuid_generate_random
uuid_generate_time
uuid_is_null
uuid_parse
uuid_unparse
uuid_unparse_lower
uuid_unparse_upper
vcount
version
version_major
version_minor
version_prerelease_level
version_revision
version_stage
version_variant
vetoSleepWakeNotification
vflush
vfs_64bitready
vfs_addname
vfs_authcache_ttl
vfs_authopaque
vfs_authopaqueaccess
vfs_busy
vfs_clearauthcache_ttl
vfs_clearauthopaque
vfs_clearauthopaqueaccess
vfs_clearextendedsecurity
vfs_clearflags
vfs_context_create
vfs_context_current
vfs_context_is64bit
vfs_context_issignal
vfs_context_pid
vfs_context_proc
vfs_context_rele
vfs_context_suser
vfs_context_ucred
vfs_devblocksize
vfs_event_init
vfs_event_signal
vfs_flags
vfs_fsadd
vfs_fsprivate
vfs_fsremove
vfs_getnewfsid
vfs_getvfs
vfs_init_io_attributes
vfs_ioattr
vfs_isforce
vfs_isrdonly
vfs_isrdwr
vfs_isreload
vfs_issynchronous
vfs_isunmount
vfs_isupdate
vfs_iswriteupgrade
vfs_iterate
vfs_maxsymlen
vfs_mountedon
vfs_name
vfs_removename
vfs_rootvnode
vfs_setauthcache_ttl
vfs_setauthopaque
vfs_setauthopaqueaccess
vfs_setextendedsecurity
vfs_setflags
vfs_setfsprivate
vfs_setioattr
vfs_setlocklocal
vfs_setmaxsymlen
vfs_statfs
vfs_sysctl
vfs_typenum
vfs_unbusy
vfs_unmountbyfsid
vfs_update_vfsstat
vm_allocate
vm_deallocate
vm_map
vm_map_deallocate
vm_map_unwire
vm_map_wire
vm_protect
vm_region
vm_region_object_create
vn_bwrite
vn_default_error
vn_getpath
vn_path_package_check
vn_rdwr
vn_revoke
vnode_addfsref
vnode_authattr
vnode_authattr_new
vnode_authorize
vnode_clearfsnode
vnode_clearmountedon
vnode_clearnocache
vnode_clearnoreadahead
vnode_close
vnode_create
vnode_fsnode
vnode_get
vnode_getattr
vnode_getname
vnode_getparent
vnode_getwithref
vnode_getwithvid
vnode_hascleanblks
vnode_hasdirtyblks
vnode_isblk
vnode_ischr
vnode_isdir
vnode_isfifo
vnode_isinuse
vnode_islnk
vnode_ismount
vnode_ismountedon
vnode_isnamedstream
vnode_isnocache
vnode_isnoreadahead
vnode_israge
vnode_isrecycled
vnode_isreg
vnode_isswap
vnode_issystem
vnode_isvroot
vnode_iterate
vnode_lookup
vnode_mount
vnode_mountedhere
vnode_open
vnode_put
vnode_putname
vnode_recycle
vnode_ref
vnode_rele
vnode_removefsref
vnode_setattr
vnode_setmountedon
vnode_setmultipath
vnode_setnocache
vnode_setnoreadahead
vnode_settag
vnode_specrdev
vnode_startwrite
vnode_tag
vnode_uncache_credentials
vnode_update_identity
vnode_vfs64bitready
vnode_vfsisrdonly
vnode_vfsmaxsymlen
vnode_vfsname
vnode_vfstypenum
vnode_vid
vnode_vtype
vnode_waitforwrites
vnode_writedone
vnop_access_desc
vnop_advlock_desc
vnop_allocate_desc
vnop_blktooff_desc
vnop_blockmap_desc
vnop_bwrite_desc
vnop_close_desc
vnop_copyfile_desc
vnop_create_desc
vnop_default_desc
vnop_exchange_desc
vnop_fsync_desc
vnop_getattr_desc
vnop_getnamedstream_desc
vnop_getxattr_desc
vnop_inactive_desc
vnop_ioctl_desc
vnop_kqfilt_add_desc
vnop_kqfilt_remove_desc
vnop_link_desc
vnop_listxattr_desc
vnop_lookup_desc
vnop_makenamedstream_desc
vnop_mkdir_desc
vnop_mknod_desc
vnop_mmap_desc
vnop_mnomap_desc
vnop_offtoblk_desc
vnop_open_desc
vnop_pagein_desc
vnop_pageout_desc
vnop_pathconf_desc
vnop_read_desc
vnop_readdir_desc
vnop_readdirattr_desc
vnop_readlink_desc
vnop_reclaim_desc
vnop_remove_desc
vnop_removenamedstream_desc
vnop_removexattr_desc
vnop_rename_desc
vnop_revoke_desc
vnop_rmdir_desc
vnop_searchfs_desc
vnop_select_desc
vnop_setattr_desc
vnop_setxattr_desc
vnop_strategy_desc
vnop_symlink_desc
vnop_whiteout_desc
vnop_write_desc
vprintf
vsnprintf
vsprintf
vsscanf
vttoif_tab
wakeup
wakeup_one
xattr_protected
xattr_validatename
zError
zlibVersion
Exported private symbol list (excluding C++ exports):
_m_free = _mbuf_free
_m_freem = _mbuf_freem
_m_trailingspace = _mbuf_trailingspace
_mbuf_get_priority = _mbuf_get_traffic_class
IOGetBootKeyStoreData
SHA256_Final
SHA256_Init
SHA256_Update
acpi_install_wake_handler
acpi_sleep_kernel
add_fsevent
aes_decrypt
apic_table
apply_func_phys
b_to_q
bdevsw
boot
bsd_hostname
bsd_set_dependency_capable
buf_attr
buf_create_shadow
buf_getcpaddr
buf_setcpaddr
buf_setfilter
buf_shadow
bufattr_throttled
cdevsw
cdevsw_setkqueueok
clalloc
clfree
cons_cinput
cp_key_store_action
cp_register_wraps
cpu_to_lapic
cpuid_features
cpuid_info
cs_entitlements_blob_get
ctl_id_by_name
ctl_name_by_id
fd_rdwr
get_aiotask
hz
ifnet_clone_attach
ifnet_clone_detach
ifnet_idle_flags
ifnet_set_idle_flags
in6addr_local
inaddr_local
inet_domain_mutex
ip_mutex
ip_output
ip_protox
ipc_port_release_send
kauth_cred_getgroups
kauth_cred_grnam2guid
kauth_cred_guid2grnam
kauth_cred_guid2pwnam
kauth_cred_pwnam2guid
kdp_register_link
kdp_set_interface
kdp_unregister_link
kdp_unregister_send_receive
kext_get_vm_map
kmem_alloc_kobject
lapic_end_of_interrupt
lapic_unmask_perfcnt_interrupt
linesw
log
logwakeup
m_cat
m_get
m_gethdr
m_mtod
m_prepend_2
m_pullup
m_split
mac_proc_set_enforce
mcl_to_paddr
mountroot_post_hook
mp_broadcast
mp_cpus_call
mp_cpus_call1
need_fsevent
net_add_domain
net_add_proto
net_del_domain
net_del_proto
netboot_root
pal_efi_call_in_32bit_mode
pal_efi_call_in_64bit_mode
pal_machine_sleep
perf_monitor_register_11
perf_monitor_unregister
pffinddomain
pffindproto
pmc_accessible_from_core
pmc_config_set_interrupt_threshold
pmc_config_set_value
pmc_create_config
pmc_find_by_name
pmc_free_config
pmc_free_pmc_list
pmc_get_accessible_core_list
pmc_get_name
pmc_get_pmc_list
pmc_register
pmc_reservation_free
pmc_reservation_read
pmc_reservation_start
pmc_reservation_stop
pmc_reservation_write
pmc_reserve
pmc_reserve_task
pmc_reserve_thread
pmc_unregister
port_name_to_task
port_name_to_thread
post_sys_powersource
pru_abort_notsupp
pru_accept_notsupp
pru_bind_notsupp
pru_connect2_notsupp
pru_connect_notsupp
pru_disconnect_notsupp
pru_listen_notsupp
pru_peeraddr_notsupp
pru_rcvd_notsupp
pru_rcvoob_notsupp
pru_send_notsupp
pru_sense_null
pru_shutdown_notsupp
pru_sockaddr_notsupp
pru_sopoll_notsupp
q_to_b
register_decmpfs_decompressor
rootdev
rootvp
rtfree
sbappendaddr
sbappendrecord
sbflush
sbspace
semaphore_timedwait
smp_initialized
soabort
socantrcvmore
socantsendmore
sock_getlistener
sock_gettclassopt
sock_release
sock_retain
sock_settclassopt
sock_setupcall
sodisconnect
sofree
sofreelastref
soisconnected
soisconnecting
soisdisconnected
soisdisconnecting
sonewconn
sooptcopyin
sooptcopyout
sopoll
soreceive
soreserve
sorwakeup
sosend
termioschars
thread_clear_eager_preempt
thread_dispatchqaddr
thread_set_eager_preempt
thread_tid
throttle_info_create
throttle_info_mount_ref
throttle_info_mount_rel
throttle_info_ref_by_mask
throttle_info_rel_by_mask
throttle_info_release
throttle_info_update
throttle_info_update_by_mask
throttle_lowpri_io
throttle_set_thread_io_policy
timeout
tk_nin
tk_rawcc
tsleep
ttioctl
ttsetwater
ttspeedtab
ttwakeup
ttwwakeup
tty_lock
tty_unlock
ttyclose
ttyflush
ttyfree
ttyinput
ttymalloc
ttymodem
ttyselect
ttysleep
unmountroot_pre_hook
unputc
unregister_decmpfs_decompressor
untimeout
vfs_addtrigger
vfs_context_bind
vfs_context_get_special_port
vfs_context_set_special_port
vfs_devvp
vfs_get_notify_attributes
vfs_getattr
vfs_getbyid
vfs_istraditionaltrigger
vfs_mntlabel
vfs_resolver_auxiliary
vfs_resolver_result
vfs_resolver_sequence
vfs_resolver_status
vfs_setcompoundopen
vfs_settriggercallback
vfs_setunmountpreflight
vfs_throttle_mask
vfs_vnodecovered
vm_map_copy_copy
vm_map_copy_discard
vm_map_copyin
vm_map_copyin_common
vm_map_copyout
vn_getpath_fsenter
vn_searchfs_inappropriate_name
vnode_isdyldsharedcache
vnode_ismonitored
vnode_lookup_continue_needed
vnode_notify
vnode_trigger_update
vnop_compound_mkdir_desc
vnop_compound_open_desc
vnop_compound_remove_desc
vnop_compound_rename_desc
vnop_compound_rmdir_desc
vnop_monitor_desc
xts_decrypt
xts_done
xts_encrypt
xts_start