ChibiOS/RT  6.0.3
ch_thread Struct Reference

Structure representing a thread. More...

#include <chschd.h>

Collaboration diagram for ch_thread:
Collaboration graph

Data Fields

threads_queue_t queue
 Threads queue header. More...
 
tprio_t prio
 Thread priority. More...
 
struct port_context ctx
 Processor context. More...
 
thread_tnewer
 Newer registry element. More...
 
thread_tolder
 Older registry element. More...
 
const char * name
 Thread name or NULL. More...
 
stkalign_t * wabase
 Working area base address. More...
 
tstate_t state
 Current thread state. More...
 
tmode_t flags
 Various thread flags. More...
 
trefs_t refs
 References to this thread. More...
 
tslices_t ticks
 Number of ticks remaining to this thread. More...
 
volatile systime_t time
 Thread consumed time in ticks. More...
 
union {
   msg_t   rdymsg
 Thread wakeup code. More...
 
   msg_t   exitcode
 Thread exit code. More...
 
   void *   wtobjp
 Pointer to a generic "wait" object. More...
 
   thread_reference_t *   wttrp
 Pointer to a generic thread reference object. More...
 
   msg_t   sentmsg
 Thread sent message. More...
 
   struct ch_semaphore *   wtsemp
 Pointer to a generic semaphore object. More...
 
   struct ch_mutex *   wtmtxp
 Pointer to a generic mutex object. More...
 
   eventmask_t   ewmask
 Enabled events mask. More...
 
u
 State-specific fields. More...
 
threads_list_t waiting
 Termination waiting list. More...
 
threads_queue_t msgqueue
 Messages queue. More...
 
eventmask_t epending
 Pending events mask. More...
 
struct ch_mutexmtxlist
 List of the mutexes owned by this thread. More...
 
tprio_t realprio
 Thread's own, non-inherited, priority. More...
 
void * mpool
 Memory Pool where the thread workspace is returned. More...
 
time_measurement_t stats
 Thread statistics. More...
 

Detailed Description

Structure representing a thread.

Note
Not all the listed fields are always needed, by switching off some not needed ChibiOS/RT subsystems it is possible to save RAM space by shrinking this structure.

Definition at line 153 of file chschd.h.

Field Documentation

struct port_context ch_thread::ctx

Processor context.

Definition at line 156 of file chschd.h.

thread_t* ch_thread::newer

Newer registry element.

Definition at line 158 of file chschd.h.

Referenced by chRegNextThread(), and chSysIntegrityCheckI().

thread_t* ch_thread::older

Older registry element.

Definition at line 159 of file chschd.h.

Referenced by chSysIntegrityCheckI().

const char* ch_thread::name

Thread name or NULL.

Definition at line 166 of file chschd.h.

Referenced by _thread_init(), chRegGetThreadNameX(), and chRegSetThreadNameX().

stkalign_t* ch_thread::wabase

Working area base address.

Note
This pointer is used for stack overflow checks and for dynamic threading.

Definition at line 175 of file chschd.h.

Referenced by chThdCreateStatic(), chThdCreateSuspendedI(), and chThdGetWorkingAreaX().

tmode_t ch_thread::flags
trefs_t ch_thread::refs

References to this thread.

Definition at line 189 of file chschd.h.

Referenced by _thread_init(), chRegFirstThread(), chRegNextThread(), chThdAddRef(), chThdExitS(), chThdRelease(), and chThdWait().

tslices_t ch_thread::ticks

Number of ticks remaining to this thread.

Definition at line 195 of file chschd.h.

Referenced by _thread_init(), chSchDoReschedule(), chSchDoRescheduleBehind(), and chSchGoSleepS().

volatile systime_t ch_thread::time

Thread consumed time in ticks.

Note
This field can overflow.

Definition at line 202 of file chschd.h.

Referenced by _thread_init(), and chThdGetTicksX().

msg_t ch_thread::rdymsg

Thread wakeup code.

Note
This field contains the low level message sent to the thread by the waking thread or interrupt handler. The value is valid after exiting the chSchWakeupS() function.

Definition at line 216 of file chschd.h.

Referenced by chCondBroadcastI(), chCondSignalI(), chCondWaitS(), chEvtSignalI(), chMsgSend(), chSchGoSleepS(), chSchWakeupS(), chSemAddCounterI(), chSemResetI(), chSemSignalI(), chSemSignalWait(), chThdDoDequeueNextI(), chThdResumeI(), and chThdSuspendS().

msg_t ch_thread::exitcode

Thread exit code.

Note
The thread termination code is stored in this field in order to be retrieved by the thread performing a chThdWait() on this thread.

Definition at line 223 of file chschd.h.

Referenced by chThdExitS(), and chThdWait().

void* ch_thread::wtobjp

Pointer to a generic "wait" object.

Note
This field is used to get a generic pointer to a synchronization object and is valid when the thread is in one of the wait states.

Definition at line 230 of file chschd.h.

Referenced by _trace_switch(), and chCondWaitS().

thread_reference_t* ch_thread::wttrp

Pointer to a generic thread reference object.

Note
This field is used to get a pointer to a synchronization object and is valid when the thread is in CH_STATE_SUSPENDED state.

Definition at line 237 of file chschd.h.

Referenced by chSchGoSleepS(), chThdSuspendS(), and chThdSuspendTimeoutS().

msg_t ch_thread::sentmsg

Thread sent message.

Definition at line 242 of file chschd.h.

Referenced by chMsgGet(), and chMsgSend().

struct ch_semaphore* ch_thread::wtsemp

Pointer to a generic semaphore object.

Note
This field is used to get a pointer to a synchronization object and is valid when the thread is in CH_STATE_WTSEM state.

Definition at line 251 of file chschd.h.

Referenced by chSchGoSleepS(), and chSemSignalWait().

struct ch_mutex* ch_thread::wtmtxp

Pointer to a generic mutex object.

Note
This field is used to get a pointer to a synchronization object and is valid when the thread is in CH_STATE_WTMTX state.

Definition at line 260 of file chschd.h.

Referenced by chMtxLockS().

eventmask_t ch_thread::ewmask

Enabled events mask.

Note
This field is only valid while the thread is in the CH_STATE_WTOREVT or CH_STATE_WTANDEVT states.

Definition at line 268 of file chschd.h.

Referenced by chEvtSignalI(), chEvtWaitAll(), chEvtWaitAllTimeout(), chEvtWaitAny(), chEvtWaitAnyTimeout(), chEvtWaitOne(), and chEvtWaitOneTimeout().

threads_list_t ch_thread::waiting

Termination waiting list.

Definition at line 275 of file chschd.h.

Referenced by _thread_init(), chThdExitS(), and chThdWait().

threads_queue_t ch_thread::msgqueue

Messages queue.

Definition at line 281 of file chschd.h.

Referenced by _thread_init(), chMsgIsPendingI(), and chMsgSend().

eventmask_t ch_thread::epending
struct ch_mutex* ch_thread::mtxlist

List of the mutexes owned by this thread.

Note
The list is terminated by a NULL in this field.

Definition at line 294 of file chschd.h.

Referenced by _thread_init(), chMtxGetNextMutexX(), chMtxLockS(), chMtxUnlock(), chMtxUnlockAll(), chMtxUnlockAllS(), and chMtxUnlockS().

tprio_t ch_thread::realprio

Thread's own, non-inherited, priority.

Definition at line 298 of file chschd.h.

Referenced by _thread_init(), chMtxUnlock(), chMtxUnlockAll(), chMtxUnlockAllS(), and chMtxUnlockS().

void* ch_thread::mpool

Memory Pool where the thread workspace is returned.

Definition at line 305 of file chschd.h.

Referenced by chThdCreateFromMemoryPool(), and chThdRelease().

time_measurement_t ch_thread::stats

Thread statistics.

Definition at line 311 of file chschd.h.

Referenced by _stats_ctxswc(), and _thread_init().