ChibiOS/RT Logo ChibiOS/RT

Architecture - Reference Manual - Guides

Defines | Functions

Registry
[Kernel]

Collaboration diagram for Registry:


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, 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

ThreadchRegFirstThread (void)
 Returns the first thread in the system.
ThreadchRegNextThread (Thread *tp)
 Returns the thread next to the specified one.

Define Documentation

#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] tp thread to remove from the registry

Definition at line 46 of file chregistry.h.

Referenced by chThdExit().

#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] tp thread to add to the registry

Definition at line 57 of file chregistry.h.

Referenced by init_thread().


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.

Note:
A reference is added to the returned thread in order to make sure it status is not lost.
This function cannot return NULL because there is always at least one thread in the system.
Returns:
A reference to the first thread.

Definition at line 70 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] tp pointer to the thread
Returns:
A reference to the next thread.
Return values:
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.

Here is the call graph for this function:


Generated on Sun Oct 24 2010 09:40:46 for ChibiOS/RT by doxygen 1.7.1