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