ChibiOS/RT Architecture - Reference Manual - Guides |
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, as 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.
In order to use the threads registry the CH_USE_REGISTRY
option must be enabled in chconf.h
.
Defines | |
#define | REG_REMOVE(tp) |
Removes a thread from the registry list. | |
#define | REG_INSERT(tp) |
Adds a thread to the registry list. | |
Functions | |
Thread * | chRegFirstThread (void) |
Returns the first thread in the system. | |
Thread * | chRegNextThread (Thread *tp) |
Returns the thread next to the specified one. |
#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 46 of file chregistry.h.
Referenced by chThdExit().
#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 57 of file chregistry.h.
Referenced by init_thread().
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.
NULL
because there is always at least one thread in the system.Definition at line 70 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 91 of file chregistry.c.
References chDbgAssert, chSysLock, chSysUnlock, chThdRelease(), Thread::p_newer, Thread::p_refs, and rlist.