ChibiOS/RT
2.5.1
Internals
Collaboration diagram for Internals:

Detailed Description

All the functions present in this module, while public, are not OS APIs and should not be directly used in the user applications code.

Data Structures

struct  ThreadsQueue
 Generic threads bidirectional linked list header and element. More...
struct  ThreadsList
 Generic threads single link list, it works like a stack. More...

Functions

void prio_insert (Thread *tp, ThreadsQueue *tqp)
 Inserts a thread into a priority ordered queue.
void queue_insert (Thread *tp, ThreadsQueue *tqp)
 Inserts a Thread into a queue.
Threadfifo_remove (ThreadsQueue *tqp)
 Removes the first-out Thread from a queue and returns it.
Threadlifo_remove (ThreadsQueue *tqp)
 Removes the last-out Thread from a queue and returns it.
Threaddequeue (Thread *tp)
 Removes a Thread from a queue and returns it.
void list_insert (Thread *tp, ThreadsList *tlp)
 Pushes a Thread on top of a stack list.
Threadlist_remove (ThreadsList *tlp)
 Pops a Thread from the top of a stack list and returns it.

Defines

#define queue_init(tqp)   ((tqp)->p_next = (tqp)->p_prev = (Thread *)(tqp));
 Threads queue initialization.
#define list_init(tlp)   ((tlp)->p_next = (Thread *)(tlp))
 Threads list initialization.
#define isempty(p)   ((p)->p_next == (Thread *)(p))
 Evaluates to TRUE if the specified threads queue or list is empty.
#define notempty(p)   ((p)->p_next != (Thread *)(p))
 Evaluates to TRUE if the specified threads queue or list is not empty.
#define _THREADSQUEUE_DATA(name)   {(Thread *)&name, (Thread *)&name}
 Data part of a static threads queue initializer.
#define THREADSQUEUE_DECL(name)   ThreadsQueue name = _THREADSQUEUE_DATA(name)
 Static threads queue initializer.

Function Documentation

void prio_insert ( Thread tp,
ThreadsQueue tqp 
)

Inserts a thread into a priority ordered queue.

Note:
The insertion is done by scanning the list from the highest priority toward the lowest.
Parameters:
[in]tpthe pointer to the thread to be inserted in the list
[in]tqpthe pointer to the threads list header
Function Class:
Not an API, this function is for internal use only.

Definition at line 44 of file chlists.c.

References Thread::p_next, Thread::p_prev, and Thread::p_prio.

Referenced by chCondWaitS(), chCondWaitTimeoutS(), and chMtxLockS().

void queue_insert ( Thread tp,
ThreadsQueue tqp 
)

Inserts a Thread into a queue.

Parameters:
[in]tpthe pointer to the thread to be inserted in the list
[in]tqpthe pointer to the threads list header
Function Class:
Not an API, this function is for internal use only.

Definition at line 67 of file chlists.c.

References Thread::p_next, ThreadsQueue::p_prev, and Thread::p_prev.

Thread * fifo_remove ( ThreadsQueue tqp)

Removes the first-out Thread from a queue and returns it.

Note:
If the queue is priority ordered then this function returns the thread with the highest priority.
Parameters:
[in]tqpthe pointer to the threads list header
Returns:
The removed thread pointer.
Function Class:
Not an API, this function is for internal use only.

Definition at line 84 of file chlists.c.

References Thread::p_next, and ThreadsQueue::p_next.

Referenced by chCondBroadcastI(), chCondSignal(), chCondSignalI(), chIQPutI(), chIQResetI(), chMsgWait(), chMtxUnlock(), chMtxUnlockAll(), chMtxUnlockS(), chOQGetI(), chOQResetI(), chSchDoRescheduleAhead(), chSchDoRescheduleBehind(), chSchGoSleepS(), chSemAddCounterI(), chSemSignal(), chSemSignalI(), and chSemSignalWait().

Thread * lifo_remove ( ThreadsQueue tqp)

Removes the last-out Thread from a queue and returns it.

Note:
If the queue is priority ordered then this function returns the thread with the lowest priority.
Parameters:
[in]tqpthe pointer to the threads list header
Returns:
The removed thread pointer.
Function Class:
Not an API, this function is for internal use only.

Definition at line 101 of file chlists.c.

References Thread::p_prev, and ThreadsQueue::p_prev.

Referenced by chSemResetI().

Thread * dequeue ( Thread tp)

Removes a Thread from a queue and returns it.

The thread is removed from the queue regardless of its relative position and regardless the used insertion method.

Parameters:
[in]tpthe pointer to the thread to be removed from the queue
Returns:
The removed thread pointer.
Function Class:
Not an API, this function is for internal use only.

Definition at line 118 of file chlists.c.

References Thread::p_next, and Thread::p_prev.

Referenced by chMtxLockS().

void list_insert ( Thread tp,
ThreadsList tlp 
)

Pushes a Thread on top of a stack list.

Parameters:
[in]tpthe pointer to the thread to be inserted in the list
[in]tlpthe pointer to the threads list header
Function Class:
Not an API, this function is for internal use only.

Definition at line 133 of file chlists.c.

References ThreadsList::p_next, and Thread::p_next.

Referenced by chThdWait().

Thread * list_remove ( ThreadsList tlp)

Pops a Thread from the top of a stack list and returns it.

Precondition:
The list must be non-empty before calling this function.
Parameters:
[in]tlpthe pointer to the threads list header
Returns:
The removed thread pointer.
Function Class:
Not an API, this function is for internal use only.

Definition at line 148 of file chlists.c.

References Thread::p_next, and ThreadsList::p_next.

Referenced by chThdExitS().


Define Documentation

#define queue_init (   tqp)    ((tqp)->p_next = (tqp)->p_prev = (Thread *)(tqp));

Threads queue initialization.

Function Class:
Not an API, this function is for internal use only.

Definition at line 42 of file chlists.h.

Referenced by _scheduler_init(), _thread_init(), chCondInit(), chIQInit(), chMtxInit(), chOQInit(), and chSemInit().

#define list_init (   tlp)    ((tlp)->p_next = (Thread *)(tlp))

Threads list initialization.

Function Class:
Not an API, this function is for internal use only.

Definition at line 49 of file chlists.h.

Referenced by _thread_init().

#define isempty (   p)    ((p)->p_next == (Thread *)(p))

Evaluates to TRUE if the specified threads queue or list is empty.

Function Class:
Not an API, this function is for internal use only.

Definition at line 57 of file chlists.h.

Referenced by chSemAddCounterI(), chSemResetI(), chSemSignal(), chSemSignalI(), chSemSignalWait(), chSemWaitS(), and chSemWaitTimeoutS().

#define notempty (   p)    ((p)->p_next != (Thread *)(p))

Evaluates to TRUE if the specified threads queue or list is not empty.

Function Class:
Not an API, this function is for internal use only.

Definition at line 65 of file chlists.h.

Referenced by chCondSignal(), chCondSignalI(), chIQPutI(), chIQResetI(), chOQGetI(), chOQResetI(), chSemAddCounterI(), chSemResetI(), chSemSignal(), chSemSignalI(), chSemSignalWait(), chSemWaitS(), chSemWaitTimeoutS(), and chThdExitS().

#define _THREADSQUEUE_DATA (   name)    {(Thread *)&name, (Thread *)&name}

Data part of a static threads queue initializer.

This macro should be used when statically initializing a threads queue that is part of a bigger structure.

Parameters:
[in]namethe name of the threads queue variable

Definition at line 74 of file chlists.h.

#define THREADSQUEUE_DECL (   name)    ThreadsQueue name = _THREADSQUEUE_DATA(name)

Static threads queue initializer.

Statically initialized threads queues require no explicit initialization using queue_init().

Parameters:
[in]namethe name of the threads queue variable

Definition at line 83 of file chlists.h.