ChibiOS
21.6.0
|
Threads related APIs and services.
A thread is an abstraction of an independent instructions flow. In ChibiOS/RT a thread is represented by a "C" function owning a processor context, state informations and a dedicated stack area. In this scenario static variables are shared among all threads while automatic variables are local to the thread.
Operations defined for threads:
Threads queues | |
#define | __THREADS_QUEUE_DATA(name) {__CH_QUEUE_DATA(name)} |
Data part of a static threads queue object initializer. More... | |
#define | THREADS_QUEUE_DECL(name) threads_queue_t name = __THREADS_QUEUE_DATA(name) |
Static threads queue object initializer. More... | |
Working Areas | |
#define | THD_WORKING_AREA_SIZE(n) MEM_ALIGN_NEXT(sizeof(thread_t) + PORT_WA_SIZE(n), PORT_STACK_ALIGN) |
Calculates the total Working Area size. More... | |
#define | THD_WORKING_AREA(s, n) PORT_WORKING_AREA(s, n) |
Static working area allocation. More... | |
#define | THD_WORKING_AREA_BASE(s) ((stkalign_t *)(s)) |
Base of a working area casted to the correct type. More... | |
#define | THD_WORKING_AREA_END(s) |
End of a working area casted to the correct type. More... | |
Threads abstraction macros | |
#define | THD_FUNCTION(tname, arg) PORT_THD_FUNCTION(tname, arg) |
Thread declaration macro. More... | |
Threads initializers | |
#define | THD_DESCRIPTOR(name, wbase, wend, prio, funcp, arg) |
Thread descriptor initializer with no affinity. More... | |
#define | THD_DESCRIPTOR_AFFINITY(name, wbase, wend, prio, funcp, arg, oip) |
Thread descriptor initializer with no affinity. More... | |
Macro Functions | |
#define | chThdSleepSeconds(sec) chThdSleep(TIME_S2I(sec)) |
Delays the invoking thread for the specified number of seconds. More... | |
#define | chThdSleepMilliseconds(msec) chThdSleep(TIME_MS2I(msec)) |
Delays the invoking thread for the specified number of milliseconds. More... | |
#define | chThdSleepMicroseconds(usec) chThdSleep(TIME_US2I(usec)) |
Delays the invoking thread for the specified number of microseconds. More... | |
Typedefs | |
typedef void(* | tfunc_t) (void *p) |
Thread function. More... | |
Data Structures | |
struct | thread_descriptor_t |
Type of a thread descriptor. More... | |
Functions | |
thread_t * | __thd_object_init (os_instance_t *oip, thread_t *tp, const char *name, tprio_t prio) |
Initializes a thread structure. More... | |
void | __thd_memfill (uint8_t *startp, uint8_t *endp, uint8_t v) |
Memory fill utility. More... | |
thread_t * | chThdCreateSuspendedI (const thread_descriptor_t *tdp) |
Creates a new thread into a static memory area. More... | |
thread_t * | chThdCreateSuspended (const thread_descriptor_t *tdp) |
Creates a new thread into a static memory area. More... | |
thread_t * | chThdCreateI (const thread_descriptor_t *tdp) |
Creates a new thread into a static memory area. More... | |
thread_t * | chThdCreate (const thread_descriptor_t *tdp) |
Creates a new thread into a static memory area. More... | |
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. More... | |
thread_t * | chThdStart (thread_t *tp) |
Resumes a thread created with chThdCreateI() . More... | |
thread_t * | chThdAddRef (thread_t *tp) |
Adds a reference to a thread object. More... | |
void | chThdRelease (thread_t *tp) |
Releases a reference to a thread object. More... | |
void | chThdExit (msg_t msg) |
Terminates the current thread. More... | |
void | chThdExitS (msg_t msg) |
Terminates the current thread. More... | |
msg_t | chThdWait (thread_t *tp) |
Blocks the execution of the invoking thread until the specified thread terminates then the exit code is returned. More... | |
tprio_t | chThdSetPriority (tprio_t newprio) |
Changes the running thread priority level then reschedules if necessary. More... | |
void | chThdTerminate (thread_t *tp) |
Requests a thread termination. More... | |
void | chThdSleep (sysinterval_t time) |
Suspends the invoking thread for the specified time. More... | |
void | chThdSleepUntil (systime_t time) |
Suspends the invoking thread until the system time arrives to the specified value. More... | |
systime_t | chThdSleepUntilWindowed (systime_t prev, systime_t next) |
Suspends the invoking thread until the system time arrives to the specified value. More... | |
void | chThdYield (void) |
Yields the time slot. More... | |
msg_t | chThdSuspendS (thread_reference_t *trp) |
Sends the current thread sleeping and sets a reference variable. More... | |
msg_t | chThdSuspendTimeoutS (thread_reference_t *trp, sysinterval_t timeout) |
Sends the current thread sleeping and sets a reference variable. More... | |
void | chThdResumeI (thread_reference_t *trp, msg_t msg) |
Wakes up a thread waiting on a thread reference object. More... | |
void | chThdResumeS (thread_reference_t *trp, msg_t msg) |
Wakes up a thread waiting on a thread reference object. More... | |
void | chThdResume (thread_reference_t *trp, msg_t msg) |
Wakes up a thread waiting on a thread reference object. More... | |
msg_t | chThdEnqueueTimeoutS (threads_queue_t *tqp, sysinterval_t timeout) |
Enqueues the caller thread on a threads queue object. More... | |
void | chThdDequeueNextI (threads_queue_t *tqp, msg_t msg) |
Dequeues and wakes up one thread from the threads queue object, if any. More... | |
void | chThdDequeueAllI (threads_queue_t *tqp, msg_t msg) |
Dequeues and wakes up all threads from the threads queue object. More... | |
static thread_t * | chThdGetSelfX (void) |
Returns a pointer to the current thread_t . More... | |
static tprio_t | chThdGetPriorityX (void) |
Returns the current thread priority. More... | |
static systime_t | chThdGetTicksX (thread_t *tp) |
Returns the number of ticks consumed by the specified thread. More... | |
static stkalign_t * | chThdGetWorkingAreaX (thread_t *tp) |
Returns the working area base of the specified thread. More... | |
static bool | chThdTerminatedX (thread_t *tp) |
Verifies if the specified thread is in the CH_STATE_FINAL state. More... | |
static bool | chThdShouldTerminateX (void) |
Verifies if the current thread has a termination request pending. More... | |
static thread_t * | chThdStartI (thread_t *tp) |
Resumes a thread created with chThdCreateI() . More... | |
static void | chThdSleepS (sysinterval_t ticks) |
Suspends the invoking thread for the specified number of ticks. More... | |
static void | chThdQueueObjectInit (threads_queue_t *tqp) |
Initializes a threads queue object. More... | |
static bool | chThdQueueIsEmptyI (threads_queue_t *tqp) |
Evaluates to true if the specified queue is empty. More... | |
static void | chThdDoDequeueNextI (threads_queue_t *tqp, msg_t msg) |
Dequeues and wakes up one thread from the threads queue object. More... | |
#define __THREADS_QUEUE_DATA | ( | name | ) | {__CH_QUEUE_DATA(name)} |
Data part of a static threads queue object initializer.
This macro should be used when statically initializing a threads queue that is part of a bigger structure.
[in] | name | the name of the threads queue variable |
Definition at line 105 of file chthreads.h.
#define THREADS_QUEUE_DECL | ( | name | ) | threads_queue_t name = __THREADS_QUEUE_DATA(name) |
Static threads queue object initializer.
Statically initialized threads queues require no explicit initialization using queue_init()
.
[in] | name | the name of the threads queue variable |
Definition at line 114 of file chthreads.h.
#define THD_WORKING_AREA_SIZE | ( | n | ) | MEM_ALIGN_NEXT(sizeof(thread_t) + PORT_WA_SIZE(n), PORT_STACK_ALIGN) |
Calculates the total Working Area size.
[in] | n | the stack size to be assigned to the thread |
Definition at line 130 of file chthreads.h.
#define THD_WORKING_AREA | ( | s, | |
n | |||
) | PORT_WORKING_AREA(s, n) |
Static working area allocation.
This macro is used to allocate a static thread working area aligned as both position and size.
[in] | s | the name to be assigned to the stack array |
[in] | n | the stack size to be assigned to the thread |
Definition at line 143 of file chthreads.h.
#define THD_WORKING_AREA_BASE | ( | s | ) | ((stkalign_t *)(s)) |
Base of a working area casted to the correct type.
[in] | s | name of the working area |
Definition at line 150 of file chthreads.h.
#define THD_WORKING_AREA_END | ( | s | ) |
End of a working area casted to the correct type.
[in] | s | name of the working area |
Definition at line 157 of file chthreads.h.
#define THD_FUNCTION | ( | tname, | |
arg | |||
) | PORT_THD_FUNCTION(tname, arg) |
Thread declaration macro.
Definition at line 170 of file chthreads.h.
#define THD_DESCRIPTOR | ( | name, | |
wbase, | |||
wend, | |||
prio, | |||
funcp, | |||
arg | |||
) |
Thread descriptor initializer with no affinity.
[in] | name | thread name |
[in] | wbase | pointer to the working area base |
[in] | wend | pointer to the working area end |
[in] | prio | thread priority |
[in] | funcp | thread function pointer |
[in] | arg | thread argument |
Definition at line 188 of file chthreads.h.
#define THD_DESCRIPTOR_AFFINITY | ( | name, | |
wbase, | |||
wend, | |||
prio, | |||
funcp, | |||
arg, | |||
oip | |||
) |
Thread descriptor initializer with no affinity.
[in] | name | thread name |
[in] | wbase | pointer to the working area base |
[in] | wend | pointer to the working area end |
[in] | prio | thread priority |
[in] | funcp | thread function pointer |
[in] | arg | thread argument |
[in] | oip | instance affinity |
Definition at line 219 of file chthreads.h.
#define chThdSleepSeconds | ( | sec | ) | chThdSleep(TIME_S2I(sec)) |
Delays the invoking thread for the specified number of seconds.
[in] | sec | time in seconds, must be different from zero |
Definition at line 247 of file chthreads.h.
#define chThdSleepMilliseconds | ( | msec | ) | chThdSleep(TIME_MS2I(msec)) |
Delays the invoking thread for the specified number of milliseconds.
[in] | msec | time in milliseconds, must be different from zero |
Definition at line 263 of file chthreads.h.
#define chThdSleepMicroseconds | ( | usec | ) | chThdSleep(TIME_US2I(usec)) |
Delays the invoking thread for the specified number of microseconds.
[in] | usec | time in microseconds, must be different from zero |
Definition at line 279 of file chthreads.h.
typedef void(* tfunc_t) (void *p) |
Thread function.
Definition at line 52 of file chthreads.h.
thread_t * __thd_object_init | ( | os_instance_t * | oip, |
thread_t * | tp, | ||
const char * | name, | ||
tprio_t | prio | ||
) |
Initializes a thread structure.
[in] | oip | pointer to the OS instance |
[in] | tp | pointer to the thread |
[in] | name | thread name |
[in] | prio | the priority level for the new thread |
Definition at line 89 of file chthreads.c.
References CH_CFG_THREAD_INIT_HOOK, CH_CFG_TIME_QUANTUM, CH_FLAG_MODE_STATIC, ch_list_init(), ch_queue_init(), CH_STATE_WTSTART, chTMObjectInit(), ch_thread::epending, ch_thread::flags, ch_thread::hdr, ch_thread::msgqueue, ch_thread::mtxlist, ch_thread::name, ch_thread::owner, ch_thread::pqueue, ch_priority_queue::prio, ch_thread::realprio, ch_thread::refs, REG_INSERT, ch_thread::state, ch_thread::stats, ch_thread::ticks, ch_thread::time, and ch_thread::waiting.
Referenced by chInstanceObjectInit(), and chThdCreateStatic().
void __thd_memfill | ( | uint8_t * | startp, |
uint8_t * | endp, | ||
uint8_t | v | ||
) |
Memory fill utility.
[in] | startp | first address to fill |
[in] | endp | last address to fill +1 |
[in] | v | filler value |
Definition at line 141 of file chthreads.c.
Referenced by chThdCreate(), chThdCreateFromHeap(), chThdCreateFromMemoryPool(), chThdCreateStatic(), and chThdCreateSuspended().
thread_t * chThdCreateSuspendedI | ( | const thread_descriptor_t * | tdp | ) |
Creates a new thread into a static memory area.
The new thread is initialized but not inserted in the ready list, the initial state is CH_STATE_WTSTART
.
chThdRelease()
or chthdWait()
in order to release the reference. The thread persists in the registry until its reference counter reaches zero. chThdStart()
, chThdStartI()
or chSchWakeupS()
depending on the execution context. chThdExit()
or by simply returning from its main function. CH_DBG_FILL_THREADS
debug option because it would keep the kernel locked for too much time.[out] | tdp | pointer to the thread descriptor |
thread_t
structure allocated for the thread into the working space area.Definition at line 172 of file chthreads.c.
Referenced by chThdCreate(), chThdCreateFromHeap(), chThdCreateFromMemoryPool(), chThdCreateI(), and chThdCreateSuspended().
thread_t * chThdCreateSuspended | ( | const thread_descriptor_t * | tdp | ) |
Creates a new thread into a static memory area.
The new thread is initialized but not inserted in the ready list, the initial state is CH_STATE_WTSTART
.
chThdRelease()
or chthdWait()
in order to release the reference. The thread persists in the registry until its reference counter reaches zero. chThdStart()
, chThdStartI()
or chSchWakeupS()
depending on the execution context. chThdExit()
or by simply returning from its main function.[out] | tdp | pointer to the thread descriptor |
thread_t
structure allocated for the thread into the working space area.Definition at line 227 of file chthreads.c.
References __thd_memfill(), CH_DBG_STACK_FILL_VALUE, chDbgAssert, chRegFindThreadByWorkingArea(), chSysLock, chSysUnlock, chThdCreateSuspendedI(), thread_descriptor_t::wbase, and thread_descriptor_t::wend.
thread_t * chThdCreateI | ( | const thread_descriptor_t * | tdp | ) |
Creates a new thread into a static memory area.
The new thread is initialized and make ready to execute.
chThdRelease()
or chthdWait()
in order to release the reference. The thread persists in the registry until its reference counter reaches zero. chThdStart()
, chThdStartI()
or chSchWakeupS()
depending on the execution context. chThdExit()
or by simply returning from its main function. CH_DBG_FILL_THREADS
debug option because it would keep the kernel locked for too much time.[out] | tdp | pointer to the thread descriptor |
thread_t
structure allocated for the thread into the working space area.Definition at line 270 of file chthreads.c.
References chSchReadyI(), and chThdCreateSuspendedI().
thread_t * chThdCreate | ( | const thread_descriptor_t * | tdp | ) |
Creates a new thread into a static memory area.
The new thread is initialized and make ready to execute.
chThdRelease()
or chthdWait()
in order to release the reference. The thread persists in the registry until its reference counter reaches zero. chThdExit()
or by simply returning from its main function.[out] | tdp | pointer to the thread descriptor |
thread_t
structure allocated for the thread into the working space area.Definition at line 291 of file chthreads.c.
References __thd_memfill(), CH_DBG_STACK_FILL_VALUE, chDbgAssert, chRegFindThreadByWorkingArea(), chSchWakeupS(), chSysLock, chSysUnlock, chThdCreateSuspendedI(), MSG_OK, thread_descriptor_t::wbase, and thread_descriptor_t::wend.
Creates a new thread into a static memory area.
chThdRelease()
or chthdWait()
in order to release the reference. The thread persists in the registry until its reference counter reaches zero. chThdExit()
or by simply returning from its main function.[out] | wsp | pointer to a working area dedicated to the thread stack |
[in] | size | size of the working area |
[in] | prio | the priority level for the new thread |
[in] | pf | the thread function |
[in] | arg | an argument passed to the thread function. It can be NULL . |
thread_t
structure allocated for the thread into the working space area.Definition at line 334 of file chthreads.c.
References __thd_memfill(), __thd_object_init(), CH_DBG_STACK_FILL_VALUE, chDbgAssert, chDbgCheck, chRegFindThreadByWorkingArea(), chSchWakeupS(), chSysLock, chSysUnlock, currcore, HIGHPRIO, MEM_ALIGN_NEXT, MEM_IS_ALIGNED, MSG_OK, PORT_SETUP_CONTEXT, PORT_STACK_ALIGN, PORT_WORKING_AREA_ALIGN, THD_WORKING_AREA_SIZE, and ch_thread::wabase.
Resumes a thread created with chThdCreateI()
.
[in] | tp | pointer to the thread |
thread_t
structure allocated for the thread into the working space area.Definition at line 390 of file chthreads.c.
References CH_STATE_WTSTART, chDbgAssert, chSchWakeupS(), chSysLock, chSysUnlock, MSG_OK, and ch_thread::state.
Adds a reference to a thread object.
CH_CFG_USE_REGISTRY
must be enabled in order to use this function.[in] | tp | pointer to the thread |
Definition at line 412 of file chthreads.c.
References chDbgAssert, chSysLock, chSysUnlock, and ch_thread::refs.
void chThdRelease | ( | thread_t * | tp | ) |
Releases a reference to a thread object.
If the references counter reaches zero and the thread is in the CH_STATE_FINAL
state then the thread's memory is returned to the proper allocator and the thread is removed from the registry.
Threads whose counter reaches zero and are still active become "detached" and will be removed from registry on termination.
CH_CFG_USE_REGISTRY
must be enabled in order to use this function. [in] | tp | pointer to the thread |
Definition at line 438 of file chthreads.c.
References CH_FLAG_MODE_HEAP, CH_FLAG_MODE_MASK, CH_FLAG_MODE_MPOOL, CH_STATE_FINAL, chDbgAssert, chHeapFree(), chPoolFree(), chSysLock, chSysUnlock, chThdGetWorkingAreaX(), ch_thread::flags, ch_thread::mpool, ch_thread::refs, REG_REMOVE, and ch_thread::state.
Referenced by chRegNextThread(), and chThdWait().
void chThdExit | ( | msg_t | msg | ) |
Terminates the current thread.
The thread goes in the CH_STATE_FINAL
state holding the specified exit status code, other threads can retrieve the exit status code by invoking the function chThdWait()
.
[in] | msg | thread exit code |
Definition at line 488 of file chthreads.c.
References chSysLock, and chThdExitS().
void chThdExitS | ( | msg_t | msg | ) |
Terminates the current thread.
The thread goes in the CH_STATE_FINAL
state holding the specified exit status code, other threads can retrieve the exit status code by invoking the function chThdWait()
.
[in] | msg | thread exit code |
Definition at line 512 of file chthreads.c.
References CH_CFG_THREAD_EXIT_HOOK, CH_FLAG_MODE_MASK, CH_FLAG_MODE_STATIC, ch_list_notempty(), ch_list_unlink(), CH_STATE_FINAL, chDbgAssert, chSchGoSleepS(), chSchReadyI(), chThdGetSelfX, ch_thread::exitcode, ch_thread::flags, ch_thread::refs, REG_REMOVE, ch_thread::u, unlikely, and ch_thread::waiting.
Referenced by chThdExit().
Blocks the execution of the invoking thread until the specified thread terminates then the exit code is returned.
This function waits for the specified thread to terminate then decrements its reference counter, if the counter reaches zero then the thread working area is returned to the proper allocator and the thread is removed from registry.
CH_CFG_USE_WAITEXIT
must be enabled in order to use this function. chThdWait()
requires 2-4 (depending on the architecture) extra bytes in the thread_t
structure. CH_CFG_USE_DYNAMIC
is not specified this function just waits for the thread termination, no memory allocators are involved.[in] | tp | pointer to the thread |
Definition at line 569 of file chthreads.c.
References ch_list_link(), CH_STATE_FINAL, CH_STATE_WTEXIT, chDbgAssert, chDbgCheck, chSchGoSleepS(), chSysLock, chSysUnlock, chThdGetSelfX, chThdRelease(), ch_thread::exitcode, ch_thread::hdr, likely, ch_thread::list, ch_thread::refs, ch_thread::state, ch_thread::u, and ch_thread::waiting.
Changes the running thread priority level then reschedules if necessary.
[in] | newprio | the new priority level of the running thread |
Definition at line 609 of file chthreads.c.
References chDbgCheck, chSchRescheduleS(), chSysLock, chSysUnlock, chThdGetSelfX, ch_thread::hdr, HIGHPRIO, ch_thread::pqueue, ch_priority_queue::prio, and ch_thread::realprio.
void chThdTerminate | ( | thread_t * | tp | ) |
Requests a thread termination.
chThdShouldTerminate()
and terminate cleanly if it returns true
. [in] | tp | pointer to the thread |
Definition at line 645 of file chthreads.c.
References CH_FLAG_TERMINATE, chSysLock, chSysUnlock, and ch_thread::flags.
void chThdSleep | ( | sysinterval_t | time | ) |
Suspends the invoking thread for the specified time.
[in] | time | the delay in system ticks, the special values are handled as follow:
|
Definition at line 664 of file chthreads.c.
References chSysLock, chSysUnlock, and chThdSleepS.
void chThdSleepUntil | ( | systime_t | time | ) |
Suspends the invoking thread until the system time arrives to the specified value.
[in] | time | absolute system time |
Definition at line 684 of file chthreads.c.
References chSysLock, chSysUnlock, chThdSleepS, chTimeDiffX, chVTGetSystemTimeX, and likely.
Suspends the invoking thread until the system time arrives to the specified value.
prev
and next
else the call is assumed to have been called outside the allowed time interval, in this case no sleep is performed. [in] | prev | absolute system time of the previous deadline |
[in] | next | absolute system time of the next deadline |
next
parameterDefinition at line 709 of file chthreads.c.
References chSysLock, chSysUnlock, chThdSleepS, chTimeDiffX, chTimeIsInRangeX(), chVTGetSystemTimeX, and likely.
void chThdYield | ( | void | ) |
Yields the time slot.
Yields the CPU control to the next thread in the ready list with equal priority, if any.
Definition at line 729 of file chthreads.c.
References chSchDoYieldS(), chSysLock, and chSysUnlock.
msg_t chThdSuspendS | ( | thread_reference_t * | trp | ) |
Sends the current thread sleeping and sets a reference variable.
[in] | trp | a pointer to a thread reference object |
Definition at line 746 of file chthreads.c.
References CH_STATE_SUSPENDED, chDbgAssert, chSchGoSleepS(), chThdGetSelfX, ch_thread::u, and ch_thread::wttrp.
msg_t chThdSuspendTimeoutS | ( | thread_reference_t * | trp, |
sysinterval_t | timeout | ||
) |
Sends the current thread sleeping and sets a reference variable.
[in] | trp | a pointer to a thread reference object |
[in] | timeout | the timeout in system ticks, the special values are handled as follow:
|
MSG_TIMEOUT | if the operation timed out. |
Definition at line 777 of file chthreads.c.
References CH_STATE_SUSPENDED, chDbgAssert, chSchGoSleepTimeoutS(), chThdGetSelfX, MSG_TIMEOUT, TIME_IMMEDIATE, ch_thread::u, unlikely, and ch_thread::wttrp.
void chThdResumeI | ( | thread_reference_t * | trp, |
msg_t | msg | ||
) |
Wakes up a thread waiting on a thread reference object.
[in] | trp | a pointer to a thread reference object |
[in] | msg | the message code |
Definition at line 802 of file chthreads.c.
References CH_STATE_SUSPENDED, chDbgAssert, chSchReadyI(), ch_thread::rdymsg, ch_thread::state, and ch_thread::u.
void chThdResumeS | ( | thread_reference_t * | trp, |
msg_t | msg | ||
) |
Wakes up a thread waiting on a thread reference object.
[in] | trp | a pointer to a thread reference object |
[in] | msg | the message code |
Definition at line 825 of file chthreads.c.
References CH_STATE_SUSPENDED, chDbgAssert, chSchWakeupS(), and ch_thread::state.
Referenced by chThdResume().
void chThdResume | ( | thread_reference_t * | trp, |
msg_t | msg | ||
) |
Wakes up a thread waiting on a thread reference object.
[in] | trp | a pointer to a thread reference object |
[in] | msg | the message code |
Definition at line 847 of file chthreads.c.
References chSysLock, chSysUnlock, and chThdResumeS().
msg_t chThdEnqueueTimeoutS | ( | threads_queue_t * | tqp, |
sysinterval_t | timeout | ||
) |
Enqueues the caller thread on a threads queue object.
The caller thread is enqueued and put to sleep until it is dequeued or the specified timeouts expires.
[in] | tqp | pointer to the threads queue object |
[in] | timeout | the timeout in system ticks, the special values are handled as follow:
|
osalQueueWakeupOneI()
or osalQueueWakeupAllI()
functions. MSG_TIMEOUT | if the thread has not been dequeued within the specified timeout or if the function has been invoked with TIME_IMMEDIATE as timeout specification. |
Definition at line 877 of file chthreads.c.
References ch_queue_insert(), CH_STATE_QUEUED, chSchGoSleepTimeoutS(), chThdGetSelfX, MSG_TIMEOUT, TIME_IMMEDIATE, and unlikely.
void chThdDequeueNextI | ( | threads_queue_t * | tqp, |
msg_t | msg | ||
) |
Dequeues and wakes up one thread from the threads queue object, if any.
[in] | tqp | pointer to the threads queue object |
[in] | msg | the message code |
Definition at line 898 of file chthreads.c.
References ch_queue_notempty(), and chThdDoDequeueNextI().
void chThdDequeueAllI | ( | threads_queue_t * | tqp, |
msg_t | msg | ||
) |
Dequeues and wakes up all threads from the threads queue object.
[in] | tqp | pointer to the threads queue object |
[in] | msg | the message code |
Definition at line 913 of file chthreads.c.
References ch_queue_notempty(), and chThdDoDequeueNextI().
|
inlinestatic |
Returns a pointer to the current thread_t
.
Definition at line 341 of file chthreads.h.
References __sch_get_currthread.
Referenced by chThdGetPriorityX(), and chThdShouldTerminateX().
|
inlinestatic |
Returns the current thread priority.
Definition at line 354 of file chthreads.h.
References chThdGetSelfX(), ch_thread::hdr, ch_thread::pqueue, and ch_priority_queue::prio.
Returns the number of ticks consumed by the specified thread.
CH_DBG_THREADS_PROFILING
configuration option is enabled.[in] | tp | pointer to the thread |
Definition at line 370 of file chthreads.h.
References ch_thread::time.
|
inlinestatic |
Returns the working area base of the specified thread.
[in] | tp | pointer to the thread |
Definition at line 386 of file chthreads.h.
References ch_thread::wabase.
Referenced by chRegFindThreadByWorkingArea(), and chThdRelease().
|
inlinestatic |
Verifies if the specified thread is in the CH_STATE_FINAL
state.
[in] | tp | pointer to the thread |
true | thread terminated. |
false | thread not terminated. |
Definition at line 401 of file chthreads.h.
References CH_STATE_FINAL, and ch_thread::state.
|
inlinestatic |
Verifies if the current thread has a termination request pending.
true | termination request pending. |
false | termination request not pending. |
Definition at line 414 of file chthreads.h.
References CH_FLAG_TERMINATE, chThdGetSelfX(), and ch_thread::flags.
Resumes a thread created with chThdCreateI()
.
[in] | tp | pointer to the thread |
thread_t
structure allocated for the thread into the working space area.Definition at line 428 of file chthreads.h.
References CH_STATE_WTSTART, chDbgAssert, chSchReadyI(), and ch_thread::state.
|
inlinestatic |
Suspends the invoking thread for the specified number of ticks.
[in] | ticks | the delay in system ticks, the special values are handled as follow:
|
Definition at line 447 of file chthreads.h.
References CH_STATE_SLEEPING, chDbgCheck, chSchGoSleepTimeoutS(), and TIME_IMMEDIATE.
|
inlinestatic |
Initializes a threads queue object.
[out] | tqp | pointer to the threads queue object |
Definition at line 461 of file chthreads.h.
References ch_queue_init().
|
inlinestatic |
Evaluates to true
if the specified queue is empty.
[out] | tqp | pointer to the threads queue object |
false | if the queue is not empty. |
true | if the queue is empty. |
Definition at line 476 of file chthreads.h.
|
inlinestatic |
Dequeues and wakes up one thread from the threads queue object.
Dequeues one thread from the queue without checking if the queue is empty.
[in] | tqp | pointer to the threads queue object |
[in] | msg | the message code |
Definition at line 494 of file chthreads.h.
References ch_queue_fifo_remove(), ch_queue_notempty(), CH_STATE_QUEUED, chDbgAssert, chSchReadyI(), ch_thread::rdymsg, ch_thread::state, and ch_thread::u.