Priority ordered list of threads. More...
#include <os-lists.h>
Public Types | |
Types and constants | |
using | iterator = utils::double_list_iterator< thread, waiting_thread_node, &waiting_thread_node::thread_ > |
Iterator over the list threads. | |
Public Member Functions | |
Constructors & Destructor | |
waiting_threads_list () | |
Construct a list of waiting threads. | |
~waiting_threads_list () | |
Destruct the list. | |
Public Member Functions | |
void | link (waiting_thread_node &node) |
Add a new thread node to the list. | |
volatile waiting_thread_node * | head (void) const |
Get list head. | |
bool | resume_one (void) |
Wake-up one thread (the oldest with the highest priority) | |
void | resume_all (void) |
Wake-up all threads in the list. | |
iterator | begin () const |
Iterator begin. | |
iterator | end () const |
Iterator begin. | |
Public Member Functions | |
bool | uninitialized (void) const |
Check if the list is uninitialised. | |
void | clear (void) |
Clear the list. | |
bool | empty (void) const |
Check if the list is empty. | |
volatile static_double_list_links * | tail (void) const |
Get the list tail. | |
Protected Member Functions | |
Private Member Functions | |
void | insert_after (static_double_list_links &node, static_double_list_links *after) |
Insert a new node after existing node. | |
Protected Attributes | |
Private Member Variables | |
static_double_list_links | head_ |
A list node used to point to head and tail. | |
Priority ordered list of threads.
There are at least two strategies:
The first strategy requires a partial list traverse with each insert, to find the place to insert the node, but makes retrieving the top priority node trivial, by a single access to the list head.
The second strategy might minimise the overall processing time, but always requires a full list traversal to determine the top priority node.
On the other hand, typical waiting lists contain only one element, and in this case there is no distinction. Mutex objects occasionally might have two entries (and rarely more). Condition variables might also have several waiting threads, the number is usually small. In these cases, the distinction between the two strategies is also minimal.
In the rare cases when the waiting list is large, the first strategy favours top node retrieval, possibly improving the response time, and is thus preferred.
Definition at line 549 of file os-lists.h.
using os::rtos::internal::waiting_threads_list::iterator = utils::double_list_iterator<thread, waiting_thread_node, &waiting_thread_node::thread_> |
Iterator over the list threads.
Definition at line 561 of file os-lists.h.
|
inline |
Construct a list of waiting threads.
The initial list status is empty.
Definition at line 928 of file os-lists.h.
|
inline |
Destruct the list.
Definition at line 933 of file os-lists.h.
|
inline |
Iterator begin.
Definition at line 949 of file os-lists.h.
|
inherited |
|
inlineinherited |
|
inline |
Iterator begin.
Definition at line 957 of file os-lists.h.
|
inline |
Get list head.
Definition at line 938 of file os-lists.h.
|
protectedinherited |
void os::rtos::internal::waiting_threads_list::link | ( | waiting_thread_node & | node | ) |
Add a new thread node to the list.
[in] | node | Reference to a list node. |
Based on priority, the node is inserted
To satisfy the circular double linked list requirements, an empty list still contains the head node with references to itself.
Definition at line 193 of file os-lists.cpp.
void os::rtos::internal::waiting_threads_list::resume_all | ( | void | ) |
Wake-up all threads in the list.
Definition at line 301 of file os-lists.cpp.
bool os::rtos::internal::waiting_threads_list::resume_one | ( | void | ) |
Wake-up one thread (the oldest with the highest priority)
true | The list may have further entries. |
false | The list is empty. |
Atomically get the top thread from the list, remove the node and wake-up the thread.
Definition at line 264 of file os-lists.cpp.
|
inlineinherited |
|
inlineinherited |
|
protectedinherited |