ChibiOS/RT
5.1.0
|
Threads Registry related APIs and services.
The Threads Registry is a double linked list that holds all the active threads in the system.
Operations defined for the registry:
The registry is meant to be mainly a debug feature, for example, using the registry a debugger can enumerate the active threads in any given moment or the shell can print the active threads and their state.
Another possible use is for centralized threads memory management, terminating threads can pulse an event source and an event handler can perform a scansion of the registry in order to recover the memory.
CH_CFG_USE_REGISTRY
option must be enabled in chconf.h
. Macros | |
#define | REG_REMOVE(tp) |
Removes a thread from the registry list. More... | |
#define | REG_INSERT(tp) |
Adds a thread to the registry list. More... | |
Data Structures | |
struct | chdebug_t |
ChibiOS/RT memory signature record. More... | |
Functions | |
thread_t * | chRegFirstThread (void) |
Returns the first thread in the system. More... | |
thread_t * | chRegNextThread (thread_t *tp) |
Returns the thread next to the specified one. More... | |
thread_t * | chRegFindThreadByName (const char *name) |
Retrieves a thread pointer by name. More... | |
thread_t * | chRegFindThreadByPointer (thread_t *tp) |
Confirms that a pointer is a valid thread pointer. More... | |
thread_t * | chRegFindThreadByWorkingArea (stkalign_t *wa) |
Confirms that a working area is being used by some active thread. More... | |
static void | chRegSetThreadName (const char *name) |
Sets the current thread name. More... | |
static const char * | chRegGetThreadNameX (thread_t *tp) |
Returns the name of the specified thread. More... | |
static void | chRegSetThreadNameX (thread_t *tp, const char *name) |
Changes the name of the specified thread. More... | |
#define REG_REMOVE | ( | tp | ) |
Removes a thread from the registry list.
[in] | tp | thread to remove from the registry |
Definition at line 83 of file chregistry.h.
Referenced by chThdExitS(), and chThdRelease().
#define REG_INSERT | ( | tp | ) |
Adds a thread to the registry list.
[in] | tp | thread to add to the registry |
Definition at line 94 of file chregistry.h.
Referenced by _thread_init().
thread_t * chRegFirstThread | ( | void | ) |
Returns the first thread in the system.
Returns the most ancient thread in the system, usually this is the main thread unless it terminated. A reference is added to the returned thread in order to make sure its status is not lost.
NULL
because there is always at least one thread in the system.Definition at line 134 of file chregistry.c.
References ch, chSysLock(), chSysUnlock(), ch_thread::refs, and ch_system::rlist.
Referenced by chRegFindThreadByName(), chRegFindThreadByPointer(), and chRegFindThreadByWorkingArea().
Returns the thread next to the specified one.
The reference counter of the specified thread is decremented and the reference counter of the returned thread is incremented.
[in] | tp | pointer to the thread |
NULL | if there is no next thread. |
Definition at line 158 of file chregistry.c.
References ch, chDbgAssert, chSysLock(), chSysUnlock(), chThdRelease(), ch_thread::newer, ch_thread::refs, and ch_system::rlist.
Referenced by chRegFindThreadByName(), chRegFindThreadByPointer(), and chRegFindThreadByWorkingArea().
thread_t * chRegFindThreadByName | ( | const char * | name | ) |
Retrieves a thread pointer by name.
[in] | name | the thread name |
NULL | if a matching thread has not been found. |
Definition at line 194 of file chregistry.c.
References chRegFirstThread(), chRegGetThreadNameX(), and chRegNextThread().
Confirms that a pointer is a valid thread pointer.
[in] | tp | pointer to the thread |
NULL | if a matching thread has not been found. |
Definition at line 221 of file chregistry.c.
References chRegFirstThread(), and chRegNextThread().
thread_t * chRegFindThreadByWorkingArea | ( | stkalign_t * | wa | ) |
Confirms that a working area is being used by some active thread.
[in] | wa | pointer to a static working area |
NULL | if a matching thread has not been found. |
Definition at line 250 of file chregistry.c.
References chRegFirstThread(), chRegNextThread(), and chThdGetWorkingAreaX().
Referenced by chThdCreate(), chThdCreateStatic(), and chThdCreateSuspended().
|
inlinestatic |
Sets the current thread name.
CH_CFG_USE_REGISTRY
is enabled else no action is performed.[in] | name | thread name as a zero terminated string |
Definition at line 133 of file chregistry.h.
References ch, and ch_system::rlist.
|
inlinestatic |
Returns the name of the specified thread.
CH_CFG_USE_REGISTRY
is enabled else NULL
is returned.[in] | tp | pointer to the thread |
NULL | if the thread name has not been set. |
Definition at line 153 of file chregistry.h.
References ch_thread::name.
Referenced by chRegFindThreadByName().
|
inlinestatic |
Changes the name of the specified thread.
CH_CFG_USE_REGISTRY
is enabled else no action is performed.[in] | tp | pointer to the thread |
[in] | name | thread name as a zero terminated string |
Definition at line 173 of file chregistry.h.
References ch_thread::name.