|
ChibiOS 21.11.4
|
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.
Data Structures | |
| struct | chdebug_t |
| ChibiOS/RT memory signature record. More... | |
Macros | |
| #define | REG_HEADER(oip) |
| Access to the registry list header. | |
| #define | REG_REMOVE(tp) |
| Removes a thread from the registry list. | |
| #define | REG_INSERT(oip, tp) |
| Adds a thread to the registry list. | |
Functions | |
| thread_t * | chRegFirstThread (void) |
| Returns the first thread in the system. | |
| thread_t * | chRegNextThread (thread_t *tp) |
| Returns the thread next to the specified one. | |
| thread_t * | chRegFindThreadByName (const char *name) |
| Retrieves a thread pointer by name. | |
| thread_t * | chRegFindThreadByPointer (thread_t *tp) |
| Confirms that a pointer is a valid thread pointer. | |
| thread_t * | chRegFindThreadByWorkingArea (stkalign_t *wa) |
| Confirms that a working area is being used by some active thread. | |
| static void | __reg_object_init (registry_t *rp) |
| Initializes a registry. | |
| static void | chRegSetThreadName (const char *name) |
| Sets the current thread name. | |
| static const char * | chRegGetThreadNameX (thread_t *tp) |
| Returns the name of the specified thread. | |
| static void | chRegSetThreadNameX (thread_t *tp, const char *name) |
| Changes the name of the specified thread. | |
Variables | |
| ROMCONST chdebug_t | ch_debug |
| ROMCONST chdebug_t | ch_debug |
| #define REG_HEADER | ( | oip | ) |
Access to the registry list header.
Definition at line 98 of file chregistry.h.
Referenced by chRegFirstThread(), chRegNextThread(), and chSysIntegrityCheckI().
| #define REG_REMOVE | ( | tp | ) |
Removes a thread from the registry list.
| [in] | tp | thread to remove from the registry |
Definition at line 109 of file chregistry.h.
Referenced by chThdExitS(), and chThdRelease().
| #define REG_INSERT | ( | oip, | |
| tp ) |
Adds a thread to the registry list.
| [in] | oip | pointer to the OS instance |
| [in] | tp | thread to add to the registry |
Definition at line 118 of file chregistry.h.
Referenced by __thd_object_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 159 of file chregistry.c.
References __CH_OFFSETOF, chSysLock, chSysUnlock, currcore, ch_thread::refs, REG_HEADER, and threadref.
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 187 of file chregistry.c.
References __CH_OFFSETOF, chDbgAssert, chSysLock, chSysUnlock, chThdRelease(), currcore, ch_queue::next, ch_thread::refs, REG_HEADER, ch_thread::rqueue, and threadref.
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 230 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 257 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 286 of file chregistry.c.
References chRegFirstThread(), chRegNextThread(), and chThdGetWorkingAreaX().
Referenced by chThdCreate(), chThdCreateStatic(), and chThdCreateSuspended().

|
inlinestatic |
Initializes a registry.
| [out] | rp | pointer to a registry_t structure |
Definition at line 151 of file chregistry.h.
References ch_queue_init(), and ch_registry::queue.
Referenced by chInstanceObjectInit(), and chSysInit().

|
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 165 of file chregistry.h.
References __sch_get_currthread.
|
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 185 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 205 of file chregistry.h.
References ch_thread::name.
Definition at line 77 of file chregistry.c.
Referenced by chInstanceObjectInit().
Definition at line 77 of file chregistry.c.
Referenced by chInstanceObjectInit().