Priority ordered list of threads. More...
#include <os-lists.h>
Inheritance diagram for os::rtos::internal::waiting_threads_list: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. | |
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 542 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_> |
Definition at line 553 of file os-lists.h.
|
inline |
|
inline |
Definition at line 920 of file os-lists.h.
|
inline |
Definition at line 937 of file os-lists.h.
References os::utils::static_double_list::head_, and os::utils::static_double_list_links::next().
|
inherited |
Initialise the mandatory node with links to itself.
Definition at line 108 of file lists.cpp.
References os::utils::static_double_list::head_, os::utils::static_double_list_links::next(), and os::utils::static_double_list_links::prev().
Referenced by os::utils::double_list::double_list(), os::rtos::internal::ready_threads_list::link(), and os::rtos::internal::terminated_threads_list::link().
|
inlineinherited |
| true | The list has no nodes. |
| false | The list has at least one node. |
Definition at line 1001 of file lists.h.
References os::utils::static_double_list::head_, and os::utils::static_double_list_links::next().
Referenced by os::utils::double_list::~double_list(), os::rtos::internal::clock_timestamps_list::check_timestamp(), os::rtos::internal::clock_timestamps_list::link(), os::rtos::internal::ready_threads_list::link(), link(), resume_one(), and os::rtos::internal::ready_threads_list::unlink_head().
|
inline |
Definition at line 946 of file os-lists.h.
References os::utils::static_double_list::head_.
|
inline |
Definition at line 925 of file os-lists.h.
Referenced by link(), and resume_one().
|
protectedinherited |
| node | Reference to node to insert. |
| after | Reference to existing node. |
Definition at line 121 of file lists.cpp.
References os::utils::static_double_list_links::next(), os::utils::static_double_list_links::prev(), and os::trace::printf().
Referenced by os::rtos::internal::thread_children_list::link(), os::rtos::internal::clock_timestamps_list::link(), os::rtos::internal::ready_threads_list::link(), link(), and os::rtos::internal::terminated_threads_list::link().
| void os::rtos::internal::waiting_threads_list::link | ( | waiting_thread_node & | node | ) |
| [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 194 of file os-lists.cpp.
References os::utils::static_double_list::empty(), head(), os::utils::static_double_list::head_, os::utils::static_double_list::insert_after(), os::utils::static_double_list_links::prev(), os::trace::printf(), os::rtos::thread::priority(), os::utils::static_double_list::tail(), and os::rtos::internal::waiting_thread_node::thread_.
| void os::rtos::internal::waiting_threads_list::resume_all | ( | void | ) |
Definition at line 303 of file os-lists.cpp.
References resume_one().
| bool os::rtos::internal::waiting_threads_list::resume_one | ( | void | ) |
| 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 266 of file os-lists.cpp.
References os::rtos::thread::state::destroyed, os::utils::static_double_list::empty(), head(), os::trace::printf(), os::rtos::thread::resume(), os::rtos::thread::state(), os::rtos::internal::waiting_thread_node::thread_, and unlink().
Referenced by resume_all().
|
inlineinherited |
Definition at line 1014 of file lists.h.
References os::utils::static_double_list::head_, and os::utils::static_double_list_links::prev().
Referenced by os::rtos::internal::thread_children_list::link(), os::rtos::internal::clock_timestamps_list::link(), os::rtos::internal::ready_threads_list::link(), link(), and os::rtos::internal::terminated_threads_list::link().
|
inlineinherited |
| true | The list was not initialised. |
| false | The list was initialised. |
Definition at line 994 of file lists.h.
References os::utils::static_double_list::head_, and os::utils::static_double_list_links::prev().
|
protectedinherited |
To simplify processing, the list always has a node.
Definition at line 473 of file lists.h.
Referenced by begin(), os::rtos::internal::clock_timestamps_list::check_timestamp(), os::utils::static_double_list::clear(), os::utils::static_double_list::empty(), end(), os::utils::static_double_list::head(), os::rtos::internal::clock_timestamps_list::link(), os::rtos::internal::ready_threads_list::link(), link(), os::rtos::internal::terminated_threads_list::link(), os::utils::static_double_list::tail(), and os::utils::static_double_list::uninitialized().