98#if CH_CFG_TIME_QUANTUM > 0
101#if CH_CFG_USE_MUTEXES == TRUE
105#if CH_CFG_USE_EVENTS == TRUE
108#if CH_DBG_THREADS_PROFILING == TRUE
111#if CH_CFG_USE_REGISTRY == TRUE
118#if CH_CFG_USE_WAITEXIT == TRUE
121#if CH_CFG_USE_MESSAGES == TRUE
124#if CH_DBG_STATISTICS == TRUE
131#if (CH_DBG_FILL_THREADS == TRUE) || defined(__DOXYGEN__)
144 }
while (
likely(startp < endp));
188#if (CH_DBG_ENABLE_STACK_CHECK == TRUE) || (CH_CFG_USE_DYNAMIC == TRUE)
197#if CH_CFG_SMP_MODE != FALSE
229#if CH_CFG_USE_REGISTRY == TRUE
231 "working area in use");
234#if CH_DBG_FILL_THREADS == TRUE
288#if (CH_CFG_USE_REGISTRY == TRUE) && \
289 ((CH_DBG_ENABLE_STACK_CHECK == TRUE) || (CH_CFG_USE_DYNAMIC == TRUE))
291 "working area in use");
294#if CH_DBG_FILL_THREADS == TRUE
334 (prio <=
HIGHPRIO) && (pf != NULL));
336#if (CH_CFG_USE_REGISTRY == TRUE) && \
337 ((CH_DBG_ENABLE_STACK_CHECK == TRUE) || (CH_CFG_USE_DYNAMIC == TRUE))
339 "working area in use");
342#if CH_DBG_FILL_THREADS == TRUE
354#if (CH_DBG_ENABLE_STACK_CHECK == TRUE) || (CH_CFG_USE_DYNAMIC == TRUE)
389#if (CH_CFG_USE_REGISTRY == TRUE) || defined(__DOXYGEN__)
442#if CH_CFG_USE_DYNAMIC == TRUE
444#if CH_CFG_USE_HEAP == TRUE
449#if CH_CFG_USE_MEMPOOLS == TRUE
512#if CH_CFG_USE_WAITEXIT == TRUE
519#if CH_CFG_USE_REGISTRY == TRUE
521#if CH_CFG_USE_DYNAMIC == TRUE
540#if (CH_CFG_USE_WAITEXIT == TRUE) || defined(__DOXYGEN__)
568#if CH_CFG_USE_REGISTRY == TRUE
579#if CH_CFG_USE_REGISTRY == TRUE
607#if CH_CFG_USE_MUTEXES == TRUE
#define chThdGetSelfX()
Returns a pointer to the current thread_t.
#define chSysUnlock()
Leaves the kernel lock state.
#define chSchWakeupS(ntp, msg)
Wakes up a thread.
#define chThdResumeS(trp, msg)
Wakes up a thread waiting on a thread reference object.
#define chSysLock()
Enters the kernel lock state.
#define chSchGoSleepS(newstate)
Puts the current thread to sleep into the specified state.
#define chVTGetSystemTimeX()
Current system time.
#define chThdSleepS(timeout)
Suspends the invoking thread for the specified time.
#define chTimeDiffX(start, end)
Subtracts two system times returning an interval.
#define chDbgAssert(c, r)
Condition assertion.
#define chDbgCheck(c)
Function parameters check.
#define chDbgCheckClassI()
#define CH_DBG_STACK_FILL_VALUE
Fill value for thread stack area in debug mode.
#define CH_CFG_TIME_QUANTUM
Round robin interval.
#define CH_CFG_THREAD_EXIT_HOOK(tp)
Threads finalization hook.
#define CH_CFG_THREAD_INIT_HOOK(tp)
Threads initialization hook.
#define MEM_IS_ALIGNED(p, a)
Returns whatever a pointer or memory size is aligned.
#define MEM_ALIGN_NEXT(p, a)
Aligns to the next aligned memory address.
static ch_list_t * ch_list_unlink(ch_list_t *lp)
Pops an element from the top of a stack list and returns it.
static void ch_list_init(ch_list_t *lp)
List initialization.
static void ch_queue_init(ch_queue_t *qp)
Queue initialization.
static bool ch_queue_notempty(const ch_queue_t *qp)
Evaluates to true if the specified queue is not empty.
static bool ch_list_notempty(ch_list_t *lp)
Evaluates to true if the specified list is not empty.
static void ch_queue_insert(ch_queue_t *qp, ch_queue_t *p)
Inserts an element into a queue.
struct ch_queue ch_queue_t
Type of a generic bidirectional linked list header and element.
static void ch_list_link(ch_list_t *lp, ch_list_t *p)
Pushes an element on top of a stack list.
#define threadref(p)
Safe cast of a queue pointer to a thread pointer.
#define likely(x)
Marks a boolean expression as likely true.
struct ch_os_instance os_instance_t
Type of an OS instance structure.
#define unlikely(x)
Marks a boolean expression as likely false.
thread_t * thread_reference_t
Type of a thread reference.
port_stkalign_t stkalign_t
struct ch_thread thread_t
Type of a thread structure.
void chHeapFree(void *p)
Frees a previously allocated memory block.
void chPoolFree(memory_pool_t *mp, void *objp)
Releases an object into a memory pool.
#define PORT_WORKING_AREA_ALIGN
Working Areas alignment constant.
#define PORT_STACK_ALIGN
Stack alignment constant.
#define PORT_SETUP_CONTEXT(tp, wbase, wtop, pf, arg)
Platform dependent part of the chThdCreateI() API.
#define REG_REMOVE(tp)
Removes a thread from the registry list.
#define REG_INSERT(oip, tp)
Adds a thread to the registry list.
thread_t * chRegFindThreadByWorkingArea(stkalign_t *wa)
Confirms that a working area is being used by some active thread.
#define HIGHPRIO
Highest priority.
#define CH_STATE_FINAL
Thread terminated.
void chSchRescheduleS(void)
Performs a reschedule if a higher priority thread is runnable.
#define MSG_OK
Normal wakeup message.
#define CH_FLAG_MODE_MASK
Thread memory mode mask.
thread_t * chSchReadyI(thread_t *tp)
Inserts a thread in the Ready List placing it behind its peers.
#define CH_STATE_QUEUED
On a queue.
void chSchDoYieldS(void)
Yields the time slot.
#define CH_STATE_SUSPENDED
Suspended state.
#define CH_STATE_WTSTART
Just created.
#define CH_FLAG_TERMINATE
Termination requested flag.
#define MSG_TIMEOUT
Wakeup caused by a timeout condition.
#define CH_FLAG_MODE_MPOOL
Thread allocated from a Memory Pool.
#define CH_FLAG_MODE_HEAP
Thread allocated from a Memory Heap.
#define CH_FLAG_MODE_STATIC
Static thread.
msg_t chSchGoSleepTimeoutS(tstate_t newstate, sysinterval_t timeout)
Puts the current thread to sleep into the specified state with timeout specification.
#define CH_STATE_WTEXIT
Waiting a thread.
#define currcore
Access to current core's instance structure.
void chThdExitS(msg_t msg)
Terminates the current thread.
msg_t chThdEnqueueTimeoutS(threads_queue_t *tqp, sysinterval_t timeout)
Enqueues the caller thread on a threads queue object.
thread_t * chThdCreateSuspended(const thread_descriptor_t *tdp)
Creates a new thread.
void(* tfunc_t)(void *p)
Thread function.
void chThdExit(msg_t msg)
Terminates the current thread.
msg_t chThdWait(thread_t *tp)
Blocks the execution of the invoking thread until the specified thread terminates then the exit code ...
void chThdResume(thread_reference_t *trp, msg_t msg)
Wakes up a thread waiting on a thread reference object.
msg_t chThdSuspendTimeoutS(thread_reference_t *trp, sysinterval_t timeout)
Sends the current thread sleeping and sets a reference variable.
thread_t * __thd_object_init(os_instance_t *oip, thread_t *tp, const char *name, tprio_t prio)
Initializes a thread structure.
thread_t * chThdCreateI(const thread_descriptor_t *tdp)
Creates a new thread.
void chThdResumeI(thread_reference_t *trp, msg_t msg)
Wakes up a thread waiting on a thread reference object.
tprio_t chThdSetPriority(tprio_t newprio)
Changes the running thread priority level then reschedules if necessary.
static void chThdDoDequeueNextI(threads_queue_t *tqp, msg_t msg)
Dequeues and wakes up one thread from the threads queue object.
void __thd_stackfill(uint8_t *startp, uint8_t *endp)
Stack fill utility.
void chThdSleep(sysinterval_t time)
Suspends the invoking thread for the specified time.
msg_t chThdSuspendS(thread_reference_t *trp)
Sends the current thread sleeping and sets a reference variable.
void chThdRelease(thread_t *tp)
Releases a reference to a thread object.
thread_t * chThdAddRef(thread_t *tp)
Adds a reference to a thread object.
void chThdTerminate(thread_t *tp)
Requests a thread termination.
thread_t * chThdStart(thread_t *tp)
Starts a thread created with chThdCreateSuspended().
void chThdSleepUntil(systime_t time)
Suspends the invoking thread until the system time arrives to the specified value.
void chThdDequeueNextI(threads_queue_t *tqp, msg_t msg)
Dequeues and wakes up one thread from the threads queue object, if any.
thread_t * chThdCreateStatic(void *wsp, size_t size, tprio_t prio, tfunc_t pf, void *arg)
Creates a new thread.
void chThdYield(void)
Yields the time slot.
static stkalign_t * chThdGetWorkingAreaX(thread_t *tp)
Returns the working area base of the specified thread.
thread_t * chThdCreate(const thread_descriptor_t *tdp)
Creates a new thread.
#define THD_WORKING_AREA_SIZE(n)
Calculates the total Working Area size.
systime_t chThdSleepUntilWindowed(systime_t prev, systime_t next)
Suspends the invoking thread until the system time arrives to the specified value.
thread_t * chThdCreateSuspendedI(const thread_descriptor_t *tdp)
Creates a new thread.
void chThdDequeueAllI(threads_queue_t *tqp, msg_t msg)
Dequeues and wakes up all threads from the threads queue object.
uint64_t systime_t
Type of system time.
static bool chTimeIsInRangeX(systime_t time, systime_t start, systime_t end)
Checks if the specified time is within the specified time range.
#define TIME_IMMEDIATE
Zero interval specification for some functions with a timeout specification.
uint64_t sysinterval_t
Type of time interval.
void chTMObjectInit(time_measurement_t *tmp)
Initializes a TimeMeasurement object.
tprio_t prio
Priority of this element.
union ch_thread::@065317322233202114332352372014266163076165303275 hdr
Shared list headers.
time_measurement_t stats
Thread statistics.
msg_t rdymsg
Thread wakeup code.
tprio_t realprio
Thread's own, non-inherited, priority.
void * mpool
Memory Pool where the thread workspace is returned.
const char * name
Thread name or NULL.
struct ch_mutex * mtxlist
List of the mutexes owned by this thread.
eventmask_t epending
Pending events mask.
ch_list_t list
Threads lists element.
ch_list_t waiting
Termination waiting list.
thread_reference_t * wttrp
Pointer to a generic thread reference object.
stkalign_t * wabase
Working area base address.
msg_t exitcode
Thread exit code.
tslices_t ticks
Number of ticks remaining to this thread.
tstate_t state
Current thread state.
volatile systime_t time
Thread consumed time in ticks.
ch_priority_queue_t pqueue
Threads ordered queues element.
ch_queue_t msgqueue
Messages queue.
trefs_t refs
References to this thread.
union ch_thread::@250330312022121344252011223135034045240103044261 u
State-specific fields.
tmode_t flags
Various thread flags.
os_instance_t * owner
OS instance owner of this thread.
Type of a thread descriptor.
stkalign_t * wbase
Pointer to the working area base.
const char * name
Thread name.
stkalign_t * wend
Pointer to the working area end.
void * arg
Thread argument.
tprio_t prio
Thread priority.
tfunc_t funcp
Thread function pointer.
os_instance_t * instance
OS instance affinity or NULL for current one.