ChibiOS/RT  6.1.4
Lists and Queues
Collaboration diagram for Lists and Queues:

Detailed Description

Macros

#define _CH_QUEUE_DATA(name)   {(ch_queue_t *)&name, (ch_queue_t *)&name}
 Data part of a static queue object initializer. More...
 
#define CH_QUEUE_DECL(name)   ch_queue_t name = _CH_QUEUE_DATA(name)
 Static queue object initializer. More...
 

Typedefs

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

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

Functions

static void ch_list_init (ch_list_t *lp)
 List initialization. More...
 
static bool ch_list_isempty (ch_list_t *lp)
 Evaluates to true if the specified list is empty. More...
 
static bool ch_list_notempty (ch_list_t *lp)
 Evaluates to true if the specified list is not empty. More...
 
static void ch_list_push (ch_list_t *p, ch_list_t *lp)
 Pushes an element on top of a stack list. More...
 
static ch_list_tch_list_pop (ch_list_t *lp)
 Pops an element from the top of a stack list and returns it. More...
 
static void ch_queue_init (ch_queue_t *qp)
 Queue initialization. More...
 
static bool ch_queue_isempty (const ch_queue_t *qp)
 Evaluates to true if the specified queue is empty. More...
 
static bool ch_queue_notempty (const ch_queue_t *qp)
 Evaluates to true if the specified queue is not empty. More...
 
static void ch_queue_insert (ch_queue_t *p, ch_queue_t *qp)
 Inserts an element into a queue. More...
 
static ch_queue_tch_queue_fifo_remove (ch_queue_t *qp)
 Removes the first-out element from a queue and returns it. More...
 
static ch_queue_tch_queue_lifo_remove (ch_queue_t *qp)
 Removes the last-out element from a queue and returns it. More...
 
static ch_queue_tch_queue_dequeue (ch_queue_t *p)
 Removes an element from a queue and returns it. More...
 
static void ch_pqueue_init (ch_priority_queue_t *pqp)
 Priority queue initialization. More...
 
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. More...
 
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. More...
 
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. More...
 

Macro Definition Documentation

◆ _CH_QUEUE_DATA

#define _CH_QUEUE_DATA (   name)    {(ch_queue_t *)&name, (ch_queue_t *)&name}

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 102 of file chlists.h.

◆ CH_QUEUE_DECL

#define CH_QUEUE_DECL (   name)    ch_queue_t name = _CH_QUEUE_DATA(name)

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 111 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.

Function Documentation

◆ ch_list_init()

static 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 138 of file chlists.h.

References ch_list::next.

Referenced by _thread_init().

◆ ch_list_isempty()

static 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 151 of file chlists.h.

References ch_list::next.

◆ ch_list_notempty()

static 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 164 of file chlists.h.

References ch_list::next.

Referenced by chThdExitS().

◆ ch_list_push()

static void ch_list_push ( ch_list_t p,
ch_list_t lp 
)
inlinestatic

Pushes an element on top of a stack list.

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

Definition at line 177 of file chlists.h.

References ch_list::next.

Referenced by chThdWait().

◆ ch_list_pop()

static ch_list_t* ch_list_pop ( 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 192 of file chlists.h.

References ch_list::next.

Referenced by chThdExitS().

◆ ch_queue_init()

static 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 207 of file chlists.h.

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

Referenced by _thread_init(), chCondObjectInit(), chMtxObjectInit(), chSemObjectInit(), and chThdQueueObjectInit().

◆ ch_queue_isempty()

static 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 221 of file chlists.h.

References ch_queue::next.

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

◆ ch_queue_notempty()

static 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 234 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()

static void ch_queue_insert ( ch_queue_t p,
ch_queue_t qp 
)
inlinestatic

Inserts an element into a queue.

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

Definition at line 247 of file chlists.h.

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

Referenced by chThdEnqueueTimeoutS().

◆ ch_queue_fifo_remove()

static 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 265 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()

static 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 284 of file chlists.h.

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

Referenced by chSemResetWithMessageI().

◆ ch_queue_dequeue()

static 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 303 of file chlists.h.

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

Referenced by chMtxLockS().

◆ ch_pqueue_init()

static 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 321 of file chlists.h.

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

Referenced by _scheduler_init().

◆ ch_pqueue_remove_highest()

static 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 337 of file chlists.h.

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

Referenced by chSchDoReschedule(), chSchDoRescheduleAhead(), chSchDoRescheduleBehind(), and chSchGoSleepS().

◆ ch_pqueue_insert_behind()

static 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 358 of file chlists.h.

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

Referenced by chSchReadyI().

◆ ch_pqueue_insert_ahead()

static 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 387 of file chlists.h.

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

Referenced by chSchReadyAheadI().