ChibiOS/RT
2.5.1
Registry
Collaboration diagram for Registry:

Detailed Description

Threads Registry related APIs and services.

Operation mode

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.

Precondition:
In order to use the threads registry the CH_USE_REGISTRY option must be enabled in chconf.h.

Data Structures

struct  chdebug_t
 ChibiOS/RT memory signature record. More...

Functions

ThreadchRegFirstThread (void)
 Returns the first thread in the system.
ThreadchRegNextThread (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.

Function Documentation

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.

Note:
This function cannot return NULL because there is always at least one thread in the system.
Returns:
A reference to the most ancient thread.
Function Class:
Normal API, this function can be invoked by regular system threads but not from within a lock zone.

Definition at line 110 of file chregistry.c.

References chSysLock, chSysUnlock, Thread::p_refs, ReadyList::r_newer, and rlist.

Thread * chRegNextThread ( Thread tp)

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.

Parameters:
[in]tppointer to the thread
Returns:
A reference to the next thread.
Return values:
NULLif there is no next thread.
Function Class:
Normal API, this function can be invoked by regular system threads but not from within a lock zone.

Definition at line 133 of file chregistry.c.

References chDbgAssert, chSysLock, chSysUnlock, chThdRelease(), Thread::p_newer, Thread::p_refs, and rlist.

Here is the call graph for this function:


Define Documentation

#define chRegSetThreadName (   p)    (currp->p_name = (p))

Sets the current thread name.

Precondition:
This function only stores the pointer to the name if the option CH_USE_REGISTRY is enabled else no action is performed.
Parameters:
[in]pthread name as a zero terminated string
Function Class:
Normal API, this function can be invoked by regular system threads but not from within a lock zone.

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.

Precondition:
This function only returns the pointer to the name if the option CH_USE_REGISTRY is enabled else NULL is returned.
Parameters:
[in]tppointer to the thread
Returns:
Thread name as a zero terminated string.
Return values:
NULLif the thread name has not been set.

Definition at line 85 of file chregistry.h.

#define REG_REMOVE (   tp)
Value:
{                                                    \
  (tp)->p_older->p_newer = (tp)->p_newer;                                   \
  (tp)->p_newer->p_older = (tp)->p_older;                                   \
}

Removes a thread from the registry list.

Note:
This macro is not meant for use in application code.
Parameters:
[in]tpthread to remove from the registry

Definition at line 99 of file chregistry.h.

Referenced by chThdExitS(), and chThdRelease().

#define REG_INSERT (   tp)
Value:
{                                                    \
  (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.

Note:
This macro is not meant for use in application code.
Parameters:
[in]tpthread to add to the registry

Definition at line 110 of file chregistry.h.

Referenced by _thread_init().