µOS++ IIIe Reference 7.0.0
The third edition of µOS++, a POSIX inspired open source framework, written in C++
Loading...
Searching...
No Matches
os::rtos::internal::waiting_threads_list Class Reference

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

Detailed Description

Priority ordered list of threads.

There are at least two strategies:

  • keep the list ordered by priorities and have the top node easily accessible the head
  • preserve the insertion order and perform a full list traversal to determine the top node.

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.

Member Typedef Documentation

◆ iterator

Constructor & Destructor Documentation

◆ waiting_threads_list()

os::rtos::internal::waiting_threads_list::waiting_threads_list ( )
inline

Construct a list of waiting threads.

The initial list status is empty.

Definition at line 928 of file os-lists.h.

◆ ~waiting_threads_list()

os::rtos::internal::waiting_threads_list::~waiting_threads_list ( )
inline

Destruct the list.

Definition at line 933 of file os-lists.h.

Member Function Documentation

◆ begin()

waiting_threads_list::iterator os::rtos::internal::waiting_threads_list::begin ( ) const
inline

Iterator begin.

Returns
An iterator positioned at the first element.

Definition at line 949 of file os-lists.h.

◆ clear()

void os::utils::static_double_list::clear ( void  )
inherited

Clear the list.

Parameters
None.
Returns
Nothing.

Initialise the mandatory node with links to itself.

Definition at line 105 of file lists.cpp.

◆ empty()

bool os::utils::static_double_list::empty ( void  ) const
inlineinherited

Check if the list is empty.

Parameters
None.
Return values
trueThe list has no nodes.
falseThe list has at least one node.

Definition at line 1028 of file lists.h.

◆ end()

waiting_threads_list::iterator os::rtos::internal::waiting_threads_list::end ( ) const
inline

Iterator begin.

Returns
An iterator positioned after the last element.

Definition at line 957 of file os-lists.h.

◆ head()

volatile waiting_thread_node * os::rtos::internal::waiting_threads_list::head ( void  ) const
inline

Get list head.

Parameters
None.
Returns
Casted pointer to head node.

Definition at line 938 of file os-lists.h.

◆ insert_after()

void os::utils::static_double_list::insert_after ( static_double_list_links node,
static_double_list_links after 
)
protectedinherited

Insert a new node after existing node.

Parameters
nodeReference to node to insert.
afterReference to existing node.
Returns
Nothing.

Definition at line 118 of file lists.cpp.

◆ link()

void os::rtos::internal::waiting_threads_list::link ( waiting_thread_node node)

Add a new thread node to the list.

Parameters
[in]nodeReference to a list node.
Returns
Nothing.

Based on priority, the node is inserted

  • at the end of the list,
  • at the beginning of the list,
  • in the middle of the list, which requires a partial list traversal (done from the end).

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.

◆ resume_all()

void os::rtos::internal::waiting_threads_list::resume_all ( void  )

Wake-up all threads in the list.

Parameters
None.
Returns
Nothing.

Definition at line 301 of file os-lists.cpp.

◆ resume_one()

bool os::rtos::internal::waiting_threads_list::resume_one ( void  )

Wake-up one thread (the oldest with the highest priority)

Parameters
None.
Return values
trueThe list may have further entries.
falseThe 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.

◆ tail()

volatile static_double_list_links * os::utils::static_double_list::tail ( void  ) const
inlineinherited

Get the list tail.

Parameters
None.
Returns
Pointer to tail node.

Definition at line 1041 of file lists.h.

◆ uninitialized()

bool os::utils::static_double_list::uninitialized ( void  ) const
inlineinherited

Check if the list is uninitialised.

Parameters
None.
Return values
trueThe list was not initialised.
falseThe list was initialised.

Definition at line 1021 of file lists.h.

Member Data Documentation

◆ head_

static_double_list_links os::utils::static_double_list::head_
protectedinherited

A list node used to point to head and tail.

To simplify processing, the list always has a node.

Definition at line 482 of file lists.h.


The documentation for this class was generated from the following files: