Thread Enumerations and Types
include/thread/thread_types.h View source View on GitHubStructs
Section titled “Structs”thread_class_donation
Section titled “thread_class_donation” struct thread_class_donation (3 fields) source
thread_state
Section titled “thread_state” enum thread_state : uint8_t (8 variants) source
§
THREAD_STATE_IDLE_THREAD Specifically the idle thread
§
THREAD_STATE_READY Thread is ready to run but not currently running
§
THREAD_STATE_RUNNING Thread is currently executing
§
THREAD_STATE_BLOCKED Waiting on I/O, lock, or condition
§
THREAD_STATE_SLEEPING Temporarily not runnable
§
THREAD_STATE_ZOMBIE Finished executing but hasn’t been reaped it yet
§
THREAD_STATE_TERMINATED Fully done, can be cleaned up
§
THREAD_STATE_HALTED Thread manually suspended
thread_wait_type
Section titled “thread_wait_type” enum thread_wait_type : uint8_t (3 variants) source
thread_wait_status
Section titled “thread_wait_status” enum thread_wait_status : uint8_t (3 variants) source
thread_flags
Section titled “thread_flags” enum thread_flags : uint32_t (10 variants) source
thread_flags: 32 bit bitflags:
┌───────────────────────────────────────────────────────────┐Bits │ 31..28 27..24 23..20 19..16 15..12 11..8 7..4 3..0 │Use │ AAAA **** **** **** **** *adJ jRWY DEF* │ └───────────────────────────────────────────────────────────┘F - Flexible RT - realtime scheduler related stuffE - Executing APCD - DyingY - Yielded after a wait (block, sleep)W - Availabler - Realtime fault tolerancej - Joinable - someone holds a join reference on this threadJ - Joined - a join is in progress or consumed the join referenced - Diagnostic - Diagnostics enabled for this thread in debuga - Delivering APCs - In the APC delivery codeA - Unused (Available) * - Unused (Unavailable)
§
THREAD_FLAG_RESV0 = 1 §
THREAD_FLAG_FLEXIBLE_RT = 1 << 1 §
THREAD_FLAG_EXECUTING_APC = 1 << 2 §
THREAD_FLAG_DYING = 1 << 3 §
THREAD_FLAG_YIELDED = 1 << 4 §
THREAD_FLAG_RT_FAULT_TOLERANCE = 1 << 6 §
THREAD_FLAG_JOINABLE = 1 << 7 §
THREAD_FLAG_JOINED = 1 << 8 §
THREAD_FLAG_DIAG = 1 << 9 §
THREAD_FLAG_DELIVERING_APCS = 1 << 10 This is for when inside the APC subsystem, whereas THREAD_FLAG_EXECUTING_APC is for an actual APC callback
thread_prio_class
Section titled “thread_prio_class” enum thread_prio_class : uint8_t (4 variants) source
thread_resume_reason
Section titled “thread_resume_reason” enum thread_resume_reason : uint8_t (4 variants) source
thread_block_reason
Section titled “thread_block_reason” enum thread_block_reason : uint8_t (2 variants) source
thread_sleep_reason
Section titled “thread_sleep_reason”wake_reason
Section titled “wake_reason” enum wake_reason (3 variants) source
Type Aliases
Section titled “Type Aliases”thread_entry_fn_t
Section titled “thread_entry_fn_t”typedef void (*thread_entry_fn_t)(void * arg) source thread_act_reason_t
Section titled “thread_act_reason_t”typedef uint8_t thread_act_reason_t source Polymorphic type: all the THREAD_*_REASONs are uint8_t, and often, we may need just a generic reason.
This is that.
Functions
Section titled “Functions”thread_create_full
Section titled “thread_create_full”struct thread * thread_create_full(
char *cc_nonnull_ptr,
thread_entry_fn_t entry,
struct thread_create_params *params,
va_list args
) source Macros
Section titled “Macros”THREAD_STACK_SIZE
Section titled “THREAD_STACK_SIZE”THREAD_STACK_SIZE
Section titled “THREAD_STACK_SIZE”THREAD_STACKS_HEAP_START
Section titled “THREAD_STACKS_HEAP_START”#define THREAD_STACKS_HEAP_START 0xFFFFF10000000000ULL source THREAD_STACKS_HEAP_END
Section titled “THREAD_STACKS_HEAP_END”#define THREAD_STACKS_HEAP_END 0xFFFFF20000000000ULL source THREAD_PRIO_CLASS_COUNT
Section titled “THREAD_PRIO_CLASS_COUNT”#define THREAD_PRIO_CLASS_COUNT (4) source THREAD_PRIO_CLASS_BIT_COUNT
Section titled “THREAD_PRIO_CLASS_BIT_COUNT”#define THREAD_PRIO_CLASS_BIT_COUNT 2 source THREAD_PRIO_CLASS_MASK
Section titled “THREAD_PRIO_CLASS_MASK”#define THREAD_PRIO_CLASS_MASK 0x3 source THREAD_CLASS_DONATION_EMPTY
Section titled “THREAD_CLASS_DONATION_EMPTY”#define THREAD_CLASS_DONATION_EMPTY source Expansion
#define THREAD_CLASS_DONATION_EMPTY \
((struct thread_class_donation) {.target = NULL, \
.class = THREAD_PRIO_CLASS_BACKGROUND, \
.active = false})