93 #if CH_CFG_TIME_QUANTUM > 0 96 #if CH_CFG_USE_MUTEXES == TRUE 100 #if CH_CFG_USE_EVENTS == TRUE 103 #if CH_DBG_THREADS_PROFILING == TRUE 106 #if CH_CFG_USE_REGISTRY == TRUE 107 tp->
refs = (trefs_t)1;
113 #if CH_CFG_USE_WAITEXIT == TRUE 116 #if CH_CFG_USE_MESSAGES == TRUE 119 #if CH_DBG_STATISTICS == TRUE 126 #if (CH_DBG_FILL_THREADS == TRUE) || defined(__DOXYGEN__) 138 while (startp < endp) {
184 #if (CH_DBG_ENABLE_STACK_CHECK == TRUE) || (CH_CFG_USE_DYNAMIC == TRUE) 190 PORT_SETUP_CONTEXT(tp, tdp->
wbase, tp, tdp->
funcp, tdp->
arg);
219 #if CH_CFG_USE_REGISTRY == TRUE 221 "working area in use");
224 #if CH_DBG_FILL_THREADS == TRUE 226 (uint8_t *)tdp->
wend,
283 #if (CH_CFG_USE_REGISTRY == TRUE) && \ 284 ((CH_DBG_ENABLE_STACK_CHECK == TRUE) || (CH_CFG_USE_DYNAMIC == TRUE)) 286 "working area in use");
289 #if CH_DBG_FILL_THREADS == TRUE 291 (uint8_t *)tdp->
wend,
324 tprio_t prio,
tfunc_t pf,
void *arg) {
331 (prio <=
HIGHPRIO) && (pf != NULL));
333 #if (CH_CFG_USE_REGISTRY == TRUE) && \ 334 ((CH_DBG_ENABLE_STACK_CHECK == TRUE) || (CH_CFG_USE_DYNAMIC == TRUE)) 336 "working area in use");
339 #if CH_DBG_FILL_THREADS == TRUE 341 (uint8_t *)wsp + size,
350 tp = (
thread_t *)((uint8_t *)wsp + size -
353 #if (CH_DBG_ENABLE_STACK_CHECK == TRUE) || (CH_CFG_USE_DYNAMIC == TRUE) 355 tp->
wabase = (stkalign_t *)wsp;
359 PORT_SETUP_CONTEXT(tp, wsp, tp, pf, arg);
389 #if (CH_CFG_USE_REGISTRY == TRUE) || defined(__DOXYGEN__) 440 #if CH_CFG_USE_DYNAMIC == TRUE 442 #if CH_CFG_USE_HEAP == TRUE 447 #if CH_CFG_USE_MEMPOOLS == TRUE 510 #if CH_CFG_USE_WAITEXIT == TRUE 517 #if CH_CFG_USE_REGISTRY == TRUE 520 #if CH_CFG_USE_DYNAMIC == TRUE 521 if ((tp->
refs == (trefs_t)0) &&
526 if (tp->
refs == (trefs_t)0) {
539 #if (CH_CFG_USE_WAITEXIT == TRUE) || defined(__DOXYGEN__) 566 #if CH_CFG_USE_REGISTRY == TRUE 577 #if CH_CFG_USE_REGISTRY == TRUE 604 #if CH_CFG_USE_MUTEXES == TRUE 605 oldprio =
currp->realprio;
607 currp->prio = newprio;
609 currp->realprio = newprio;
611 oldprio =
currp->prio;
612 currp->prio = newprio;
void chThdExitS(msg_t msg)
Terminates the current thread.
thread_t * chThdAddRef(thread_t *tp)
Adds a reference to a thread object.
static systime_t chVTGetSystemTimeX(void)
Current system time.
#define CH_STATE_WTEXIT
Waiting a thread.
#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.
uint64_t systime_t
Type of system time.
uint64_t sysinterval_t
Type of time interval.
eventmask_t epending
Pending events mask.
msg_t chThdSuspendTimeoutS(thread_reference_t *trp, sysinterval_t timeout)
Sends the current thread sleeping and sets a reference variable.
static void chSysLock(void)
Enters the kernel lock state.
tprio_t prio
Thread priority.
struct ch_mutex * mtxlist
List of the mutexes owned by this thread.
void chPoolFree(memory_pool_t *mp, void *objp)
Releases an object into a memory pool.
thread_t * chThdCreateSuspendedI(const thread_descriptor_t *tdp)
Creates a new thread into a static memory area.
void chThdExit(msg_t msg)
Terminates the current thread.
thread_t * chSchReadyI(thread_t *tp)
Inserts a thread in the Ready List placing it behind its peers.
Type of a thread descriptor.
void chThdDequeueAllI(threads_queue_t *tqp, msg_t msg)
Dequeues and wakes up all threads from the threads queue 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.
#define CH_STATE_WTSTART
Just created.
trefs_t refs
References to this thread.
#define CH_STATE_SUSPENDED
Suspended state.
msg_t chThdEnqueueTimeoutS(threads_queue_t *tqp, sysinterval_t timeout)
Enqueues the caller thread on a threads queue object.
Generic threads bidirectional linked list header and element.
stkalign_t * wbase
Pointer to the working area base.
static sysinterval_t chTimeDiffX(systime_t start, systime_t end)
Subtracts two system times returning an interval.
#define currp
Current thread pointer access macro.
void(* tfunc_t)(void *p)
Thread function.
msg_t rdymsg
Thread wakeup code.
void chThdTerminate(thread_t *tp)
Requests a thread termination.
#define CH_CFG_THREAD_INIT_HOOK(tp)
Threads initialization hook.
static void chSysUnlock(void)
Leaves the kernel lock state.
static bool chTimeIsInRangeX(systime_t time, systime_t start, systime_t end)
Checks if the specified time is within the specified time range.
void chThdResumeS(thread_reference_t *trp, msg_t msg)
Wakes up a thread waiting on a thread reference object.
#define CH_FLAG_MODE_HEAP
Thread allocated from a Memory Heap.
threads_queue_t msgqueue
Messages queue.
static void list_init(threads_list_t *tlp)
Threads list initialization.
void chHeapFree(void *p)
Frees a previously allocated memory block.
stkalign_t * wend
End of the working area.
void _thread_memfill(uint8_t *startp, uint8_t *endp, uint8_t v)
Memory fill utility.
static stkalign_t * chThdGetWorkingAreaX(thread_t *tp)
Returns the working area base of the specified thread.
static void chSchDoYieldS(void)
Yields the time slot.
#define REG_INSERT(tp)
Adds a thread to the registry list.
msg_t chThdWait(thread_t *tp)
Blocks the execution of the invoking thread until the specified thread terminates then the exit code ...
stkalign_t * wabase
Working area base address.
#define MEM_IS_ALIGNED(p, a)
Returns whatever a pointer or memory size is aligned.
static void chThdDoDequeueNextI(threads_queue_t *tqp, msg_t msg)
Dequeues and wakes up one thread from the threads queue object.
thread_t * chRegFindThreadByWorkingArea(stkalign_t *wa)
Confirms that a working area is being used by some active thread.
#define HIGHPRIO
Highest priority.
void chDbgCheckClassI(void)
I-class functions context check.
#define MSG_TIMEOUT
Wakeup caused by a timeout condition.
void chSchRescheduleS(void)
Performs a reschedule if a higher priority thread is runnable.
const char * name
Thread name or NULL.
static bool list_notempty(threads_list_t *tlp)
Evaluates to true if the specified threads list is not empty.
tprio_t chThdSetPriority(tprio_t newprio)
Changes the running thread priority level then reschedules if necessary.
volatile systime_t time
Thread consumed time in ticks.
threads_list_t waiting
Termination waiting list.
#define CH_STATE_FINAL
Thread terminated.
systime_t chThdSleepUntilWindowed(systime_t prev, systime_t next)
Suspends the invoking thread until the system time arrives to the specified value.
tslices_t ticks
Number of ticks remaining to this thread.
void chSchGoSleepS(tstate_t newstate)
Puts the current thread to sleep into the specified state.
static void chThdSleepS(sysinterval_t ticks)
Suspends the invoking thread for the specified number of ticks.
static void queue_init(threads_queue_t *tqp)
Threads queue initialization.
#define chDbgCheck(c)
Function parameters check.
void chThdResumeI(thread_reference_t *trp, msg_t msg)
Wakes up a thread waiting on a thread reference object.
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.
tfunc_t funcp
Thread function pointer.
const char * name
Thread name.
thread_t * list_remove(threads_list_t *tlp)
Pops a thread from the top of a stack list and returns it.
void * arg
Thread argument.
#define MSG_OK
Normal wakeup message.
void chThdDequeueNextI(threads_queue_t *tqp, msg_t msg)
Dequeues and wakes up one thread from the threads queue object, if any.
void queue_insert(thread_t *tp, threads_queue_t *tqp)
Inserts a thread into a queue.
void * mpool
Memory Pool where the thread workspace is returned.
#define chDbgAssert(c, r)
Condition assertion.
tstate_t state
Current thread state.
#define CH_FLAG_MODE_MASK
Thread memory mode mask.
void chThdYield(void)
Yields the time slot.
void chThdResume(thread_reference_t *trp, msg_t msg)
Wakes up a thread waiting on a thread reference object.
msg_t chThdSuspendS(thread_reference_t *trp)
Sends the current thread sleeping and sets a reference variable.
time_measurement_t stats
Thread statistics.
union ch_thread::@0 u
State-specific fields.
#define CH_CFG_TIME_QUANTUM
Round robin interval.
void chThdSleep(sysinterval_t time)
Suspends the invoking thread for the specified time.
#define TIME_IMMEDIATE
Zero interval specification for some functions with a timeout specification.
thread_t * _thread_init(thread_t *tp, const char *name, tprio_t prio)
Initializes a thread structure.
static thread_t * chThdGetSelfX(void)
Returns a pointer to the current thread_t.
static bool queue_notempty(const threads_queue_t *tqp)
Evaluates to true if the specified threads queue is not empty.
thread_t * chThdCreate(const thread_descriptor_t *tdp)
Creates a new thread into a static memory area.
void chSchWakeupS(thread_t *ntp, msg_t msg)
Wakes up a thread.
thread_t * chThdStart(thread_t *tp)
Resumes a thread created with chThdCreateI().
#define CH_STATE_QUEUED
On a queue.
#define REG_REMOVE(tp)
Removes a thread from the registry list.
#define CH_FLAG_MODE_STATIC
Static thread.
void list_insert(thread_t *tp, threads_list_t *tlp)
Pushes a thread_t on top of a stack list.
void chThdRelease(thread_t *tp)
Releases a reference to a thread object.
void chThdSleepUntil(systime_t time)
Suspends the invoking thread until the system time arrives to the specified value.
void chTMObjectInit(time_measurement_t *tmp)
Initializes a TimeMeasurement object.
thread_reference_t * wttrp
Pointer to a generic thread reference object.
#define THD_WORKING_AREA_SIZE(n)
Calculates the total Working Area size.
ChibiOS/RT main include file.
thread_t * chThdCreateSuspended(const thread_descriptor_t *tdp)
Creates a new thread into a static memory area.
tmode_t flags
Various thread flags.
#define MEM_ALIGN_NEXT(p, a)
Aligns to the next aligned memory address.
#define CH_FLAG_TERMINATE
Termination requested flag.
tprio_t realprio
Thread's own, non-inherited, priority.
#define CH_DBG_STACK_FILL_VALUE
Fill value for thread stack area in debug mode.
msg_t exitcode
Thread exit code.
tprio_t prio
Thread priority.
Structure representing a thread.