|
ChibiOS/RT
2.5.1 |
|
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_USE_REGISTRY option must be enabled in chconf.h. Data Structures | |
| struct | chdebug_t |
| ChibiOS/RT memory signature record. More... | |
Functions | |
| Thread * | chRegFirstThread (void) |
| Returns the first thread in the system. | |
| Thread * | chRegNextThread (Thread *tp) |
| Returns the thread next to the specified one. | |
Macro Functions | |
| #define | chRegSetThreadName(p) (currp->p_name = (p)) |
| Sets the current thread name. | |
| #define | chRegGetThreadName(tp) ((tp)->p_name) |
| Returns the name of the specified thread. | |
Defines | |
| #define | REG_REMOVE(tp) |
| Removes a thread from the registry list. | |
| #define | REG_INSERT(tp) |
| Adds a thread to the registry list. | |
| Thread * 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 110 of file chregistry.c.
References chSysLock, chSysUnlock, Thread::p_refs, ReadyList::r_newer, and rlist.
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 133 of file chregistry.c.
References chDbgAssert, chSysLock, chSysUnlock, chThdRelease(), Thread::p_newer, Thread::p_refs, and rlist.

| #define chRegSetThreadName | ( | p | ) | (currp->p_name = (p)) |
Sets the current thread name.
CH_USE_REGISTRY is enabled else no action is performed.| [in] | p | thread name as a zero terminated string |
Definition at line 73 of file chregistry.h.
Referenced by _idle_thread(), and chSysInit().
| #define chRegGetThreadName | ( | tp | ) | ((tp)->p_name) |
Returns the name of the specified thread.
CH_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 85 of file chregistry.h.
| #define REG_REMOVE | ( | tp | ) |
{ \
(tp)->p_older->p_newer = (tp)->p_newer; \
(tp)->p_newer->p_older = (tp)->p_older; \
}
Removes a thread from the registry list.
| [in] | tp | thread to remove from the registry |
Definition at line 99 of file chregistry.h.
Referenced by chThdExitS(), and chThdRelease().
| #define REG_INSERT | ( | tp | ) |
{ \
(tp)->p_newer = (Thread *)&rlist; \
(tp)->p_older = rlist.r_older; \
(tp)->p_older->p_newer = rlist.r_older = (tp); \
}
Adds a thread to the registry list.
| [in] | tp | thread to add to the registry |
Definition at line 110 of file chregistry.h.
Referenced by _thread_init().