µ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-lists.h
Go to the documentation of this file.
1/*
2 * This file is part of the µOS++ project (https://micro-os-plus.github.io/).
3 * Copyright (c) 2016-2025 Liviu Ionescu. All rights reserved.
4 *
5 * Permission to use, copy, modify, and/or distribute this software
6 * for any purpose is hereby granted, under the terms of the MIT license.
7 *
8 * If a copy of the license was not distributed with this file, it can
9 * be obtained from https://opensource.org/licenses/mit.
10 */
11
12#ifndef CMSIS_PLUS_RTOS_INTERNAL_OS_LISTS_H_
13#define CMSIS_PLUS_RTOS_INTERNAL_OS_LISTS_H_
14
15// ----------------------------------------------------------------------------
16
17#ifdef __cplusplus
18
19// ----------------------------------------------------------------------------
20
22
23#include <cstdint>
24#include <cstddef>
25#include <cassert>
26#include <iterator>
27
28// ----------------------------------------------------------------------------
29
30#pragma GCC diagnostic push
31#if defined(__clang__)
32#pragma clang diagnostic ignored "-Wc++98-compat"
33#pragma clang diagnostic ignored "-Wdocumentation-unknown-command"
34#endif
35
36// ----------------------------------------------------------------------------
37
38namespace os
39{
40 namespace rtos
41 {
42 class thread;
43
44 namespace internal
45 {
46 // ======================================================================
47
48#pragma GCC diagnostic push
49#if defined(__clang__)
50#pragma clang diagnostic ignored "-Wpadded"
51#elif defined(__GNUC__)
52#pragma GCC diagnostic ignored "-Wpadded"
53#endif
54
59 {
60 public:
71
79 operator= (const waiting_thread_node&)
80 = delete;
82 operator= (waiting_thread_node&&)
83 = delete;
84
93
98 public:
108
112 };
113
114#pragma GCC diagnostic pop
115
116 // ======================================================================
117
118#pragma GCC diagnostic push
119#if defined(__clang__)
120#pragma clang diagnostic ignored "-Wpadded"
121#elif defined(__GNUC__)
122#pragma GCC diagnostic ignored "-Wpadded"
123#endif
124
129 {
130 public:
141
146 timestamp_node (const timestamp_node&) = delete;
147 timestamp_node (timestamp_node&&) = delete;
149 operator= (const timestamp_node&)
150 = delete;
152 operator= (timestamp_node&&)
153 = delete;
154
162 virtual ~timestamp_node ();
163
168 public:
181 virtual void
182 action (void)
183 = 0;
184
189 public:
199
203 };
204
205#pragma GCC diagnostic pop
206
207 // ======================================================================
208
209#pragma GCC diagnostic push
210#if defined(__clang__)
211#pragma clang diagnostic ignored "-Wpadded"
212#elif defined(__GNUC__)
213#pragma GCC diagnostic ignored "-Wpadded"
214#endif
215
220 {
221 public:
233
241 operator= (const timeout_thread_node&)
242 = delete;
244 operator= (timeout_thread_node&&)
245 = delete;
246
254 virtual ~timeout_thread_node () override;
255
260 public:
273 virtual void
274 action (void) override;
275
280 public:
290
294 };
295
296#pragma GCC diagnostic pop
297
298 // ======================================================================
299
300#pragma GCC diagnostic push
301#if defined(__clang__)
302#pragma clang diagnostic ignored "-Wpadded"
303#elif defined(__GNUC__)
304#pragma GCC diagnostic ignored "-Wpadded"
305#endif
306
311 {
312 public:
324
328 timer_node (const timer_node&) = delete;
329 timer_node (timer_node&&) = delete;
331 operator= (const timer_node&)
332 = delete;
334 operator= (timer_node&&)
335 = delete;
343 virtual ~timer_node () override;
344
349 public:
362 virtual void
363 action (void) override;
364
369 public:
379
383 };
384
385#pragma GCC diagnostic pop
386
387 // ======================================================================
388
393 {
394 public:
404
412 operator= (const thread_children_list&)
413 = delete;
415 operator= (thread_children_list&&)
416 = delete;
417
426
431 public:
443 void
444 link (thread& thread);
445
446 // TODO add iterator begin(), end()
447
451 };
452
453 // ======================================================================
454
459 {
460 public:
470
475 ready_threads_list (const ready_threads_list&) = delete;
478 operator= (const ready_threads_list&)
479 = delete;
481 operator= (ready_threads_list&&)
482 = delete;
483
492
497 public:
509 void
511
518 volatile waiting_thread_node*
519 head (void) const;
520
527 thread*
528 unlink_head (void);
529
530 // TODO add iterator begin(), end()
531
535 };
536
537 // ======================================================================
538
543 {
544 public:
556
570
578 operator= (const waiting_threads_list&)
579 = delete;
581 operator= (waiting_threads_list&&)
582 = delete;
583
592
597 public:
609 void
611
618 volatile waiting_thread_node*
619 head (void) const;
620
628 bool
629 resume_one (void);
630
638 void
639 resume_all (void);
640
646 begin () const;
647
653 end () const;
654
658 };
659
660 // ======================================================================
661
666 {
667 public:
677
685 operator= (const clock_timestamps_list&)
686 = delete;
688 operator= (clock_timestamps_list&&)
689 = delete;
690
699
704 public:
716 void
717 link (timestamp_node& node);
718
725 volatile timestamp_node*
726 head (void) const;
727
734 void
736
740 };
741
742 // ======================================================================
743
748 {
749 public:
759
767 operator= (const terminated_threads_list&)
768 = delete;
770 operator= (terminated_threads_list&&)
771 = delete;
772
781
786 public:
798 void
800
807 volatile waiting_thread_node*
808 head (void) const;
809
810 // TODO add iterator begin(), end()
811
815 };
816
817 } /* namespace internal */
818
819 // ------------------------------------------------------------------------
820 namespace scheduler
821 {
822
827 void
828 internal_link_node (internal::waiting_threads_list& list,
830
831 void
832 internal_unlink_node (internal::waiting_thread_node& node);
833
834 void
835 internal_link_node (internal::waiting_threads_list& list,
838 internal::timeout_thread_node& timeout_node);
839
840 void
841 internal_unlink_node (internal::waiting_thread_node& node,
842 internal::timeout_thread_node& timeout_node);
843
848 } // namespace scheduler
849
850 // ------------------------------------------------------------------------
851
852 } /* namespace rtos */
853} /* namespace os */
854
855// ----------------------------------------------------------------------------
856
857namespace os
858{
859 namespace rtos
860 {
861 namespace internal
862 {
863
864 // ======================================================================
865
867 : thread_ (&th)
868 {
869 }
870
872 {
873 }
874
875 // ======================================================================
876
882 {
883 }
884
886 {
887 }
888
889 // ======================================================================
890
896 {
897 }
898
900 {
901 }
902
903 inline volatile waiting_thread_node*
905 {
906 return static_cast<volatile waiting_thread_node*> (
907 static_double_list::head ());
908 }
909
910 // ======================================================================
911
917 {
918 }
919
921 {
922 }
923
924 inline volatile waiting_thread_node*
926 {
927 return static_cast<volatile waiting_thread_node*> (
928 double_list::head ());
929 }
930
931#pragma GCC diagnostic push
932#if defined(__clang__)
933#elif defined(__GNUC__)
934#pragma GCC diagnostic ignored "-Waggregate-return"
935#endif
938 {
939 return iterator{
941 head_.next ())
942 };
943 }
944
947 {
948 return iterator{
951 };
952 }
953#pragma GCC diagnostic pop
954
955 // ======================================================================
956
958 {
959 }
960
962 {
963 }
964
965 inline volatile timestamp_node*
967 {
968 return static_cast<volatile timestamp_node*> (double_list::head ());
969 }
970
971 // ======================================================================
972
978 {
979 }
980
982 {
983 }
984
985 inline volatile waiting_thread_node*
987 {
988 return static_cast<volatile waiting_thread_node*> (
989 static_double_list::head ());
990 }
991
992 // ----------------------------------------------------------------------
993 } /* namespace internal */
994 } /* namespace rtos */
995} /* namespace os */
996
997#pragma GCC diagnostic pop
998
999// ----------------------------------------------------------------------------
1000
1001#endif /* __cplusplus */
1002
1003// ----------------------------------------------------------------------------
1004
1005#endif /* CMSIS_PLUS_RTOS_INTERNAL_OS_LISTS_H_ */
Ordered list of time stamp nodes.
Definition os-lists.h:666
void check_timestamp(port::clock::timestamp_t now)
Check list time stamps.
Definition os-lists.cpp:490
volatile timestamp_node * head(void) const
Get list head.
Definition os-lists.h:966
void link(timestamp_node &node)
Add a new thread node to the list.
Definition os-lists.cpp:413
clock_timestamps_list()
Construct a list of clock time stamps.
Definition os-lists.h:957
~clock_timestamps_list()
Destruct the list.
Definition os-lists.h:961
Priority ordered list of threads waiting too run.
Definition os-lists.h:459
ready_threads_list()
Construct a list of waiting threads.
Definition os-lists.h:895
~ready_threads_list()
Destruct the list.
Definition os-lists.h:899
thread * unlink_head(void)
Remove the top node from the list.
Definition os-lists.cpp:126
volatile waiting_thread_node * head(void) const
Get list head.
Definition os-lists.h:904
void link(waiting_thread_node &node)
Add a new thread node to the list.
Definition os-lists.cpp:47
terminated_threads_list()
Construct a list of waiting threads.
Definition os-lists.h:977
volatile waiting_thread_node * head(void) const
Get list head.
Definition os-lists.h:986
void link(waiting_thread_node &node)
Add a new thread node to the list.
Definition os-lists.cpp:535
List of children threads.
Definition os-lists.h:393
~thread_children_list()
Destruct the list.
Definition os-lists.h:885
thread_children_list()
Construct a list of waiting threads.
Definition os-lists.h:881
void link(thread &thread)
Add a new thread node to the list.
Definition os-lists.cpp:37
Double linked list node, with time stamp and thread.
Definition os-lists.h:220
rtos::thread & thread
Reference to thread who initiated the timeout.
Definition os-lists.h:289
virtual ~timeout_thread_node() override
Destruct the node.
Definition os-lists.cpp:337
virtual void action(void) override
Action to perform when the time stamp is reached.
Definition os-lists.cpp:346
Double linked list node, with time stamp and timer.
Definition os-lists.h:311
timer & tmr
Reference to waiting timer.
Definition os-lists.h:378
virtual void action(void) override
Action to perform when the time stamp is reached.
Definition os-lists.cpp:383
virtual ~timer_node() override
Destruct the node.
Definition os-lists.cpp:371
Double linked list node, with time stamp.
Definition os-lists.h:129
virtual void action(void)=0
Action to perform when the time stamp is reached.
port::clock::timestamp_t timestamp
Time stamp when the next action will be performed.
Definition os-lists.h:198
virtual ~timestamp_node()
Destruct the node.
Definition os-lists.cpp:318
Double linked list node, with thread reference.
Definition os-lists.h:59
rtos::thread * thread_
Pointer to waiting thread.
Definition os-lists.h:107
~waiting_thread_node()
Destruct the node.
Definition os-lists.h:871
waiting_thread_node(thread &th)
Construct a node with references to the thread.
Definition os-lists.h:866
Priority ordered list of threads.
Definition os-lists.h:543
void link(waiting_thread_node &node)
Add a new thread node to the list.
Definition os-lists.cpp:194
bool resume_one(void)
Wake-up one thread (the oldest with the highest priority)
Definition os-lists.cpp:266
iterator end() const
Iterator begin.
Definition os-lists.h:946
waiting_threads_list()
Construct a list of waiting threads.
Definition os-lists.h:916
volatile waiting_thread_node * head(void) const
Get list head.
Definition os-lists.h:925
void resume_all(void)
Wake-up all threads in the list.
Definition os-lists.cpp:303
iterator begin() const
Iterator begin.
Definition os-lists.h:937
~waiting_threads_list()
Destruct the list.
Definition os-lists.h:920
POSIX compliant thread, using the default RTOS allocator.
Definition os-thread.h:251
User single-shot or periodic timer.
Definition os-timer.h:56
Template for a double linked list iterator.
Definition lists.h:209
N * iterator_pointer
Type of reference to the iterator internal pointer.
Definition lists.h:234
Circular double linked list of nodes.
Definition lists.h:488
Statically allocated circular double linked list of nodes.
Definition lists.h:342
static_double_list_links head_
A list node used to point to head and tail.
Definition lists.h:473
Standard thread.
uint64_t timestamp_t
Type of variables holding time stamps.
Definition os-decls.h:821
System namespace.