ChibiOS/RT  6.1.4
ch_thread Struct Reference

Structure representing a thread. More...

#include <chschd.h>

Collaboration diagram for ch_thread:
Collaboration graph

Data Fields

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...
 
ch_list_t waiting
 Termination waiting list. More...
 
ch_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...
 
ch_list_t list
 Threads lists element.
More...
 
ch_queue_t queue
 Threads queues element.
More...
 
ch_priority_queue_t pqueue
 Threads ordered queues element.
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 134 of file chschd.h.

Field Documentation

◆ list

ch_list_t ch_thread::list

Threads lists element.

Definition at line 136 of file chschd.h.

◆ queue

ch_queue_t ch_thread::queue

Threads queues element.

Definition at line 137 of file chschd.h.

Referenced by chCondWaitS(), and chMtxLockS().

◆ pqueue

◆ ctx

struct port_context ch_thread::ctx

Processor context.

Definition at line 141 of file chschd.h.

◆ newer

thread_t* ch_thread::newer

Newer registry element.

Definition at line 143 of file chschd.h.

Referenced by chRegNextThread().

◆ older

thread_t* ch_thread::older

Older registry element.

Definition at line 144 of file chschd.h.

◆ name

const char* ch_thread::name

Thread name or NULL.

Definition at line 151 of file chschd.h.

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

◆ wabase

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 160 of file chschd.h.

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

◆ state

◆ flags

tmode_t ch_thread::flags

◆ refs

trefs_t ch_thread::refs

References to this thread.

Definition at line 174 of file chschd.h.

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

◆ ticks

tslices_t ch_thread::ticks

Number of ticks remaining to this thread.

Definition at line 180 of file chschd.h.

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

◆ time

volatile systime_t ch_thread::time

Thread consumed time in ticks.

Note
This field can overflow.

Definition at line 187 of file chschd.h.

Referenced by _thread_init(), and chThdGetTicksX().

◆ rdymsg

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 201 of file chschd.h.

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

◆ exitcode

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 208 of file chschd.h.

Referenced by chThdExitS(), and chThdWait().

◆ wtobjp

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 215 of file chschd.h.

Referenced by chCondWaitS().

◆ wttrp

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 222 of file chschd.h.

Referenced by chThdSuspendS(), and chThdSuspendTimeoutS().

◆ sentmsg

msg_t ch_thread::sentmsg

Thread sent message.

Definition at line 227 of file chschd.h.

Referenced by chMsgGet(), and chMsgSend().

◆ wtsemp

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 236 of file chschd.h.

◆ wtmtxp

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 245 of file chschd.h.

Referenced by chMtxLockS().

◆ ewmask

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 253 of file chschd.h.

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

◆ u

◆ waiting

ch_list_t ch_thread::waiting

Termination waiting list.

Definition at line 260 of file chschd.h.

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

◆ msgqueue

ch_queue_t ch_thread::msgqueue

Messages queue.

Definition at line 266 of file chschd.h.

Referenced by _thread_init(), and chMsgIsPendingI().

◆ epending

eventmask_t ch_thread::epending

◆ mtxlist

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 279 of file chschd.h.

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

◆ realprio

tprio_t ch_thread::realprio

Thread's own, non-inherited, priority.

Definition at line 283 of file chschd.h.

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

◆ mpool

void* ch_thread::mpool

Memory Pool where the thread workspace is returned.

Definition at line 290 of file chschd.h.

Referenced by chThdCreateFromMemoryPool(), and chThdRelease().

◆ stats

time_measurement_t ch_thread::stats

Thread statistics.

Definition at line 296 of file chschd.h.

Referenced by _stats_ctxswc(), and _thread_init().