ChibiOS 21.11.4
Lists and Queues

Detailed Description

Collaboration diagram for Lists and Queues:

Data Structures

struct  ch_list
 Structure representing a generic single link list header and element. More...
struct  ch_queue
 Structure representing a generic bidirectional linked list header and element. More...
struct  ch_priority_queue
 Structure representing a generic priority-ordered bidirectional linked list header and element. More...
struct  ch_delta_list
 Delta list element and header structure. More...

Macros

#define __CH_QUEUE_DATA(name)
 Data part of a static queue object initializer.
#define CH_QUEUE_DECL(name)
 Static queue object initializer.

Typedefs

typedef struct ch_list ch_list_t
 Type of a generic single link list header and element.
typedef struct ch_queue ch_queue_t
 Type of a generic bidirectional linked list header and element.
typedef struct ch_priority_queue ch_priority_queue_t
 Type of a generic priority-ordered bidirectional linked list header and element.
typedef struct ch_delta_list ch_delta_list_t
 Type of a generic bidirectional linked delta list header and element.

Functions

static void ch_list_init (ch_list_t *lp)
 List initialization.
static bool ch_list_isempty (ch_list_t *lp)
 Evaluates to true if the specified list is empty.
static bool ch_list_notempty (ch_list_t *lp)
 Evaluates to true if the specified list is not empty.
static void ch_list_link (ch_list_t *lp, ch_list_t *p)
 Pushes an element on top of a stack list.
static ch_list_tch_list_unlink (ch_list_t *lp)
 Pops an element from the top of a stack list and returns it.
static void ch_queue_init (ch_queue_t *qp)
 Queue initialization.
static bool ch_queue_isempty (const ch_queue_t *qp)
 Evaluates to true if the specified queue is empty.
static bool ch_queue_notempty (const ch_queue_t *qp)
 Evaluates to true if the specified queue is not empty.
static void ch_queue_insert (ch_queue_t *qp, ch_queue_t *p)
 Inserts an element into a queue.
static ch_queue_tch_queue_fifo_remove (ch_queue_t *qp)
 Removes the first-out element from a queue and returns it.
static ch_queue_tch_queue_lifo_remove (ch_queue_t *qp)
 Removes the last-out element from a queue and returns it.
static ch_queue_tch_queue_dequeue (ch_queue_t *p)
 Removes an element from a queue and returns it.
static void ch_pqueue_init (ch_priority_queue_t *pqp)
 Priority queue initialization.
static ch_priority_queue_tch_pqueue_remove_highest (ch_priority_queue_t *pqp)
 Removes the highest priority element from a priority queue and returns it.
static ch_priority_queue_tch_pqueue_insert_behind (ch_priority_queue_t *pqp, ch_priority_queue_t *p)
 Inserts an element in the priority queue placing it behind its peers.
static ch_priority_queue_tch_pqueue_insert_ahead (ch_priority_queue_t *pqp, ch_priority_queue_t *p)
 Inserts an element in the priority queue placing it ahead of its peers.
static void ch_dlist_init (ch_delta_list_t *dlhp)
 Delta list initialization.
static bool ch_dlist_isempty (ch_delta_list_t *dlhp)
 Evaluates to true if the specified delta list is empty.
static bool ch_dlist_notempty (ch_delta_list_t *dlhp)
 Evaluates to true if the specified queue is not empty.
static bool ch_dlist_islast (ch_delta_list_t *dlhp, ch_delta_list_t *dlp)
 Last element in the delta list check.
static bool ch_dlist_isfirst (ch_delta_list_t *dlhp, ch_delta_list_t *dlp)
 Fist element in the delta list check.
static void ch_dlist_insert_after (ch_delta_list_t *dlhp, ch_delta_list_t *dlp, sysinterval_t delta)
 Inserts an element after another header element.
static void ch_dlist_insert_before (ch_delta_list_t *dlhp, ch_delta_list_t *dlp, sysinterval_t delta)
 Inserts an element before another header element.
static void ch_dlist_insert (ch_delta_list_t *dlhp, ch_delta_list_t *dlep, sysinterval_t delta)
 Inserts an element in a delta list.
static ch_delta_list_tch_dlist_remove_first (ch_delta_list_t *dlhp)
 Dequeues an element from the delta list.
static ch_delta_list_tch_dlist_dequeue (ch_delta_list_t *dlp)
 Dequeues an element from the delta list.

Macro Definition Documentation

◆ __CH_QUEUE_DATA

#define __CH_QUEUE_DATA ( name)
Value:
{(ch_queue_t *)&name, (ch_queue_t *)&name}
struct ch_queue ch_queue_t
Type of a generic bidirectional linked list header and element.
Definition chlists.h:63

Data part of a static queue object initializer.

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

Parameters
[in]namethe name of the queue variable

Definition at line 117 of file chlists.h.

◆ CH_QUEUE_DECL

#define CH_QUEUE_DECL ( name)
Value:
#define __CH_QUEUE_DATA(name)
Data part of a static queue object initializer.
Definition chlists.h:117

Static queue object initializer.

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

Parameters
[in]namethe name of the queue variable

Definition at line 126 of file chlists.h.

Typedef Documentation

◆ ch_list_t

typedef struct ch_list ch_list_t

Type of a generic single link list header and element.

Definition at line 50 of file chlists.h.

◆ ch_queue_t

typedef struct ch_queue ch_queue_t

Type of a generic bidirectional linked list header and element.

Definition at line 63 of file chlists.h.

◆ ch_priority_queue_t

Type of a generic priority-ordered bidirectional linked list header and element.

Definition at line 78 of file chlists.h.

◆ ch_delta_list_t

Type of a generic bidirectional linked delta list header and element.

Definition at line 95 of file chlists.h.

Function Documentation

◆ ch_list_init()

void ch_list_init ( ch_list_t * lp)
inlinestatic

List initialization.

Parameters
[out]lppointer to the list header
Function Class:
Not an API, this function is for internal use only.

Definition at line 153 of file chlists.h.

References ch_list::next.

Referenced by __thd_object_init().

◆ ch_list_isempty()

bool ch_list_isempty ( ch_list_t * lp)
inlinestatic

Evaluates to true if the specified list is empty.

Parameters
[in]lppointer to the list header
Returns
The status of the list.
Function Class:
Not an API, this function is for internal use only.

Definition at line 166 of file chlists.h.

References ch_list::next.

◆ ch_list_notempty()

bool ch_list_notempty ( ch_list_t * lp)
inlinestatic

Evaluates to true if the specified list is not empty.

Parameters
[in]lppointer to the list header
Returns
The status of the list.
Function Class:
Not an API, this function is for internal use only.

Definition at line 179 of file chlists.h.

References ch_list::next.

Referenced by chThdExitS().

◆ ch_list_link()

void ch_list_link ( ch_list_t * lp,
ch_list_t * p )
inlinestatic

Pushes an element on top of a stack list.

Parameters
[in]lpthe pointer to the list header
[in]pthe pointer to the element to be inserted in the list
Function Class:
Not an API, this function is for internal use only.

Definition at line 192 of file chlists.h.

References ch_list::next.

Referenced by chThdWait().

◆ ch_list_unlink()

ch_list_t * ch_list_unlink ( ch_list_t * lp)
inlinestatic

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

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

Definition at line 207 of file chlists.h.

References ch_list::next.

Referenced by chThdExitS().

◆ ch_queue_init()

void ch_queue_init ( ch_queue_t * qp)
inlinestatic

Queue initialization.

Parameters
[out]qppointer to the queue header
Function Class:
Not an API, this function is for internal use only.

Definition at line 222 of file chlists.h.

References ch_queue::next, and ch_queue::prev.

Referenced by __reg_object_init(), __thd_object_init(), chCondObjectInit(), chMtxObjectInit(), chSemObjectInit(), and chThdQueueObjectInit().

◆ ch_queue_isempty()

bool ch_queue_isempty ( const ch_queue_t * qp)
inlinestatic

Evaluates to true if the specified queue is empty.

Parameters
[in]qppointer to the queue header
Returns
The status of the queue.
Function Class:
Not an API, this function is for internal use only.

Definition at line 236 of file chlists.h.

References ch_queue::next.

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

◆ ch_queue_notempty()

bool ch_queue_notempty ( const ch_queue_t * qp)
inlinestatic

Evaluates to true if the specified queue is not empty.

Parameters
[in]qppointer to the queue header
Returns
The status of the queue.
Function Class:
Not an API, this function is for internal use only.

Definition at line 249 of file chlists.h.

References ch_queue::next.

Referenced by chCondBroadcastI(), chCondSignal(), chCondSignalI(), chMtxQueueNotEmptyS(), chSemAddCounterI(), chSemResetWithMessageI(), chSemSignal(), chSemSignalI(), chSemSignalWait(), chSemWaitS(), chSemWaitTimeoutS(), chThdDequeueAllI(), chThdDequeueNextI(), and chThdDoDequeueNextI().

◆ ch_queue_insert()

void ch_queue_insert ( ch_queue_t * qp,
ch_queue_t * p )
inlinestatic

Inserts an element into a queue.

Parameters
[in]qpthe pointer to the queue header
[in]pthe pointer to the element to be inserted in the queue
Function Class:
Not an API, this function is for internal use only.

Definition at line 262 of file chlists.h.

References ch_queue::next, and ch_queue::prev.

Referenced by chThdEnqueueTimeoutS().

◆ ch_queue_fifo_remove()

ch_queue_t * ch_queue_fifo_remove ( ch_queue_t * qp)
inlinestatic

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

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

Definition at line 280 of file chlists.h.

References ch_queue::next, and ch_queue::prev.

Referenced by chCondBroadcastI(), chCondSignal(), chCondSignalI(), chMsgPollS(), chMsgWaitS(), chMsgWaitTimeoutS(), chMtxUnlock(), chMtxUnlockAllS(), chMtxUnlockS(), chSemAddCounterI(), chSemSignal(), chSemSignalI(), chSemSignalWait(), and chThdDoDequeueNextI().

◆ ch_queue_lifo_remove()

ch_queue_t * ch_queue_lifo_remove ( ch_queue_t * qp)
inlinestatic

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

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

Definition at line 299 of file chlists.h.

References ch_queue::next, and ch_queue::prev.

Referenced by chSemResetWithMessageI().

◆ ch_queue_dequeue()

ch_queue_t * ch_queue_dequeue ( ch_queue_t * p)
inlinestatic

Removes an element from a queue and returns it.

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

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

Definition at line 318 of file chlists.h.

References ch_queue::next, and ch_queue::prev.

Referenced by __sch_wakeup(), and chMtxLockS().

◆ ch_pqueue_init()

void ch_pqueue_init ( ch_priority_queue_t * pqp)
inlinestatic

Priority queue initialization.

Note
The queue header priority is initialized to zero, all other elements in the queue are assumed to have priority greater than zero.
Parameters
[out]pqppointer to the priority queue header
Function Class:
Not an API, this function is for internal use only.

Definition at line 336 of file chlists.h.

References ch_priority_queue::next, ch_priority_queue::prev, and ch_priority_queue::prio.

Referenced by chInstanceObjectInit().

◆ ch_pqueue_remove_highest()

ch_priority_queue_t * ch_pqueue_remove_highest ( ch_priority_queue_t * pqp)
inlinestatic

Removes the highest priority element from a priority queue and returns it.

Parameters
[in]pqpthe pointer to the priority queue list header
Returns
The removed element pointer.
Function Class:
Not an API, this function is for internal use only.

Definition at line 352 of file chlists.h.

References ch_priority_queue::next, and ch_priority_queue::prev.

Referenced by __sch_reschedule_ahead(), __sch_reschedule_behind(), chSchDoPreemption(), chSchGoSleepS(), and chSchSelectFirst().

◆ ch_pqueue_insert_behind()

ch_priority_queue_t * ch_pqueue_insert_behind ( ch_priority_queue_t * pqp,
ch_priority_queue_t * p )
inlinestatic

Inserts an element in the priority queue placing it behind its peers.

The element is positioned behind all elements with higher or equal priority.

Parameters
[in]pqpthe pointer to the priority queue list header
[in]pthe pointer to the element to be inserted in the queue
Returns
The inserted element pointer.
Function Class:
Not an API, this function is for internal use only.

Definition at line 373 of file chlists.h.

References ch_priority_queue::next, ch_priority_queue::prev, ch_priority_queue::prio, and unlikely.

Referenced by __sch_ready_behind().

◆ ch_pqueue_insert_ahead()

ch_priority_queue_t * ch_pqueue_insert_ahead ( ch_priority_queue_t * pqp,
ch_priority_queue_t * p )
inlinestatic

Inserts an element in the priority queue placing it ahead of its peers.

The element is positioned ahead of all elements with higher or equal priority.

Parameters
[in]pqpthe pointer to the priority queue list header
[in]pthe pointer to the element to be inserted in the queue
Returns
The inserted element pointer.
Function Class:
Not an API, this function is for internal use only.

Definition at line 402 of file chlists.h.

References ch_priority_queue::next, ch_priority_queue::prev, ch_priority_queue::prio, and unlikely.

Referenced by __sch_ready_ahead().

◆ ch_dlist_init()

void ch_dlist_init ( ch_delta_list_t * dlhp)
inlinestatic

Delta list initialization.

Parameters
[out]dlhppointer to the delta list header
Function Class:
Not an API, this function is for internal use only.

Definition at line 426 of file chlists.h.

References ch_delta_list::delta, ch_delta_list::next, and ch_delta_list::prev.

Referenced by __vt_object_init().

◆ ch_dlist_isempty()

bool ch_dlist_isempty ( ch_delta_list_t * dlhp)
inlinestatic

Evaluates to true if the specified delta list is empty.

Parameters
[in]dlhppointer to the delta list header
Returns
The status of the delta list.
Function Class:
Not an API, this function is for internal use only.

Definition at line 441 of file chlists.h.

References ch_delta_list::next.

Referenced by chVTDoResetI(), chVTDoTickI(), and vt_enqueue().

◆ ch_dlist_notempty()

bool ch_dlist_notempty ( ch_delta_list_t * dlhp)
inlinestatic

Evaluates to true if the specified queue is not empty.

Parameters
[in]dlhppointer to the delta list header
Returns
The status of the delta list.
Function Class:
Not an API, this function is for internal use only.

Definition at line 454 of file chlists.h.

References ch_delta_list::next.

Referenced by chVTDoTickI().

◆ ch_dlist_islast()

bool ch_dlist_islast ( ch_delta_list_t * dlhp,
ch_delta_list_t * dlp )
inlinestatic

Last element in the delta list check.

Parameters
[in]dlhppointer to the delta list header
[in]dlppointer to the delta list element
Function Class:
Not an API, this function is for internal use only.

Definition at line 467 of file chlists.h.

References ch_delta_list::next.

◆ ch_dlist_isfirst()

bool ch_dlist_isfirst ( ch_delta_list_t * dlhp,
ch_delta_list_t * dlp )
inlinestatic

Fist element in the delta list check.

Parameters
[in]dlhppointer to the delta list header
[in]dlppointer to the delta list element
Function Class:
Not an API, this function is for internal use only.

Definition at line 481 of file chlists.h.

References ch_delta_list::next.

Referenced by chVTDoResetI().

◆ ch_dlist_insert_after()

void ch_dlist_insert_after ( ch_delta_list_t * dlhp,
ch_delta_list_t * dlp,
sysinterval_t delta )
inlinestatic

Inserts an element after another header element.

Parameters
[in]dlhppointer to the delta list header element
[in]dlpelement to be inserted after the header element
[in]deltadelta of the element to be inserted
Function Class:
Not an API, this function is for internal use only.

Definition at line 496 of file chlists.h.

References ch_delta_list::delta, ch_delta_list::next, and ch_delta_list::prev.

Referenced by vt_insert_first().

◆ ch_dlist_insert_before()

void ch_dlist_insert_before ( ch_delta_list_t * dlhp,
ch_delta_list_t * dlp,
sysinterval_t delta )
inlinestatic

Inserts an element before another header element.

Parameters
[in]dlhppointer to the delta list header element
[in]dlpelement to be inserted before the header element
[in]deltadelta of the element to be inserted
Function Class:
Not an API, this function is for internal use only.

Definition at line 516 of file chlists.h.

References ch_delta_list::delta, ch_delta_list::next, and ch_delta_list::prev.

Referenced by ch_dlist_insert().

◆ ch_dlist_insert()

void ch_dlist_insert ( ch_delta_list_t * dlhp,
ch_delta_list_t * dlep,
sysinterval_t delta )
inlinestatic

Inserts an element in a delta list.

Parameters
[in]dlhppointer to the delta list header element
[in]dlepelement to be inserted before the header element
[in]deltadelta of the element to be inserted
Function Class:
Not an API, this function is for internal use only.

Definition at line 536 of file chlists.h.

References ch_dlist_insert_before(), chDbgAssert, ch_delta_list::delta, likely, and ch_delta_list::next.

Referenced by chVTDoTickI(), and vt_enqueue().

Here is the call graph for this function:

◆ ch_dlist_remove_first()

ch_delta_list_t * ch_dlist_remove_first ( ch_delta_list_t * dlhp)
inlinestatic

Dequeues an element from the delta list.

Parameters
[in]dlhppointer to the delta list header
Function Class:
Not an API, this function is for internal use only.

Definition at line 571 of file chlists.h.

References ch_delta_list::next, and ch_delta_list::prev.

Referenced by chVTDoResetI().

◆ ch_dlist_dequeue()

ch_delta_list_t * ch_dlist_dequeue ( ch_delta_list_t * dlp)
inlinestatic

Dequeues an element from the delta list.

Parameters
[in]dlppointer to the delta list element
Function Class:
Not an API, this function is for internal use only.

Definition at line 587 of file chlists.h.

References ch_delta_list::next, and ch_delta_list::prev.

Referenced by chVTDoResetI(), and chVTDoTickI().