ChibiOS
21.6.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_HEADER(oip) (&ch_system.reglist.queue) |
Access to the registry list header. More... | |
#define | REG_REMOVE(tp) (void) ch_queue_dequeue(&(tp)->rqueue) |
Removes a thread from the registry list. More... | |
#define | REG_INSERT(oip, tp) ch_queue_insert(REG_HEADER(oip), &(tp)->rqueue) |
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 | __reg_object_init (registry_t *rp) |
Initializes a registry. 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_HEADER | ( | oip | ) | (&ch_system.reglist.queue) |
Access to the registry list header.
Definition at line 81 of file chregistry.h.
#define REG_REMOVE | ( | tp | ) | (void) ch_queue_dequeue(&(tp)->rqueue) |
Removes a thread from the registry list.
[in] | tp | thread to remove from the registry |
Definition at line 92 of file chregistry.h.
#define REG_INSERT | ( | oip, | |
tp | |||
) | ch_queue_insert(REG_HEADER(oip), &(tp)->rqueue) |
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 101 of file chregistry.h.
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 128 of file chregistry.c.
References __CH_OFFSETOF, chSysLock, chSysUnlock, currcore, ch_thread::refs, and REG_HEADER.
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 156 of file chregistry.c.
References __CH_OFFSETOF, chDbgAssert, chSysLock, chSysUnlock, chThdRelease(), currcore, ch_queue::next, ch_thread::refs, REG_HEADER, and ch_thread::rqueue.
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 199 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 226 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 255 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 134 of file chregistry.h.
References ch_queue_init(), and ch_registry::queue.
Referenced by chInstanceObjectInit().
|
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 148 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 168 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 188 of file chregistry.h.
References ch_thread::name.