µ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++ distribution.
3 * (https://github.com/micro-os-plus)
4 * Copyright (c) 2016-2023 Liviu Ionescu. All rights reserved.
5 *
6 * Permission to use, copy, modify, and/or distribute this software
7 * for any purpose is hereby granted, under the terms of the MIT license.
8 *
9 * If a copy of the license was not distributed with this file, it can
10 * be obtained from https://opensource.org/licenses/mit/.
11 */
12
13#ifndef CMSIS_PLUS_RTOS_INTERNAL_OS_LISTS_H_
14#define CMSIS_PLUS_RTOS_INTERNAL_OS_LISTS_H_
15
16// ----------------------------------------------------------------------------
17
18#ifdef __cplusplus
19
20// ----------------------------------------------------------------------------
21
23
24#include <cstdint>
25#include <cstddef>
26#include <cassert>
27#include <iterator>
28
29// ----------------------------------------------------------------------------
30
31#pragma GCC diagnostic push
32#if defined(__clang__)
33#pragma clang diagnostic ignored "-Wc++98-compat"
34#pragma clang diagnostic ignored "-Wdocumentation-unknown-command"
35#endif
36
37// ----------------------------------------------------------------------------
38
39namespace os
40{
41 namespace rtos
42 {
43 class thread;
44
45 namespace internal
46 {
47 // ======================================================================
48
49#pragma GCC diagnostic push
50#if defined(__clang__)
51#pragma clang diagnostic ignored "-Wpadded"
52#elif defined(__GNUC__)
53#pragma GCC diagnostic ignored "-Wpadded"
54#endif
55
60 {
61 public:
62
73
81 operator= (const waiting_thread_node&) = delete;
83 operator= (waiting_thread_node&&) = delete;
84
93
98 public:
99
109
113 };
114
115#pragma GCC diagnostic pop
116
117 // ======================================================================
118
119#pragma GCC diagnostic push
120#if defined(__clang__)
121#pragma clang diagnostic ignored "-Wpadded"
122#elif defined(__GNUC__)
123#pragma GCC diagnostic ignored "-Wpadded"
124#endif
125
130 {
131 public:
132
143
148 timestamp_node (const timestamp_node&) = delete;
149 timestamp_node (timestamp_node&&) = delete;
151 operator= (const timestamp_node&) = delete;
153 operator= (timestamp_node&&) = delete;
154
162 virtual
164
169 public:
170
183 virtual void
184 action (void) = 0;
185
190 public:
191
201
206 };
207
208#pragma GCC diagnostic pop
209
210 // ======================================================================
211
212#pragma GCC diagnostic push
213#if defined(__clang__)
214#pragma clang diagnostic ignored "-Wpadded"
215#elif defined(__GNUC__)
216#pragma GCC diagnostic ignored "-Wpadded"
217#endif
218
223 {
224 public:
225
237
245 operator= (const timeout_thread_node&) = delete;
247 operator= (timeout_thread_node&&) = delete;
248
256 virtual
257 ~timeout_thread_node () override;
258
263 public:
264
277 virtual void
278 action (void) override;
279
284 public:
285
295
299 };
300
301#pragma GCC diagnostic pop
302
303 // ======================================================================
304
305#pragma GCC diagnostic push
306#if defined(__clang__)
307#pragma clang diagnostic ignored "-Wpadded"
308#elif defined(__GNUC__)
309#pragma GCC diagnostic ignored "-Wpadded"
310#endif
311
316 {
317 public:
318
330
334 timer_node (const timer_node&) = delete;
335 timer_node (timer_node&&) = delete;
337 operator= (const timer_node&) = delete;
339 operator= (timer_node&&) = delete;
347 virtual
348 ~timer_node () override;
349
354 public:
355
368 virtual void
369 action (void) override;
370
375 public:
376
386
390 };
391
392#pragma GCC diagnostic pop
393
394 // ======================================================================
395
400 {
401 public:
402
412
420 operator= (const thread_children_list&) = delete;
422 operator= (thread_children_list&&) = delete;
423
432
437 public:
438
450 void
451 link (thread& thread);
452
453 // TODO add iterator begin(), end()
454
458 };
459
460 // ======================================================================
461
466 {
467 public:
468
478
483 ready_threads_list (const ready_threads_list&) = delete;
486 operator= (const ready_threads_list&) = delete;
488 operator= (ready_threads_list&&) = delete;
489
498
503 public:
504
516 void
518
525 volatile waiting_thread_node*
526 head (void) const;
527
534 thread*
535 unlink_head (void);
536
537 // TODO add iterator begin(), end()
538
542 };
543
544 // ======================================================================
545
550 {
551 public:
552
562
576
584 operator= (const waiting_threads_list&) = delete;
586 operator= (waiting_threads_list&&) = delete;
587
596
601 public:
602
614 void
616
623 volatile waiting_thread_node*
624 head (void) const;
625
633 bool
634 resume_one (void);
635
643 void
644 resume_all (void);
645
651 begin () const;
652
658 end () const;
659
663 };
664
665 // ======================================================================
666
671 {
672 public:
673
683
691 operator= (const clock_timestamps_list&) = delete;
693 operator= (clock_timestamps_list&&) = delete;
694
703
708 public:
709
721 void
722 link (timestamp_node& node);
723
730 volatile timestamp_node*
731 head (void) const;
732
739 void
741
745 };
746
747 // ======================================================================
748
753 {
754 public:
755
765
773 operator= (const terminated_threads_list&) = delete;
775 operator= (terminated_threads_list&&) = delete;
776
785
790 public:
791
803 void
805
812 volatile waiting_thread_node*
813 head (void) const;
814
815 // TODO add iterator begin(), end()
816
821 };
822
823 } /* namespace internal */
824
825 // ------------------------------------------------------------------------
826 namespace scheduler
827 {
828
833 void
834 internal_link_node (internal::waiting_threads_list& list,
836
837 void
838 internal_unlink_node (internal::waiting_thread_node& node);
839
840 void
841 internal_link_node (internal::waiting_threads_list& list,
844 internal::timeout_thread_node& timeout_node);
845
846 void
847 internal_unlink_node (internal::waiting_thread_node& node,
848 internal::timeout_thread_node& timeout_node);
849
854 } /* namespace this_thread */
855
856 // --------------------------------------------------------------------------
857
858 } /* namespace rtos */
859} /* namespace os */
860
861// ----------------------------------------------------------------------------
862
863namespace os
864{
865 namespace rtos
866 {
867 namespace internal
868 {
869
870 // ======================================================================
871
872 inline
874 thread_ (&th)
875 {
876 }
877
878 inline
880 {
881 }
882
883 // ======================================================================
884
889 inline
891 {
892 }
893
894 inline
896 {
897 }
898
899 // ======================================================================
900
905 inline
907 {
908 }
909
910 inline
912 {
913 }
914
915 inline volatile waiting_thread_node*
917 {
918 return static_cast<volatile waiting_thread_node*> (static_double_list::head ());
919 }
920
921 // ======================================================================
922
927 inline
929 {
930 }
931
932 inline
934 {
935 }
936
937 inline volatile waiting_thread_node*
939 {
940 return static_cast<volatile waiting_thread_node*> (double_list::head ());
941 }
942
943#pragma GCC diagnostic push
944#if defined(__clang__)
945#elif defined(__GNUC__)
946#pragma GCC diagnostic ignored "-Waggregate-return"
947#endif
950 {
951 return iterator
952 {
954 }
955
958 {
959 return iterator
960 {
962 }
963#pragma GCC diagnostic pop
964
965 // ======================================================================
966
967 inline
969 {
970 }
971
972 inline
974 {
975 }
976
977 inline volatile timestamp_node*
979 {
980 return static_cast<volatile timestamp_node*> (double_list::head ());
981 }
982
983 // ======================================================================
984
989 inline
991 {
992 }
993
994 inline
996 {
997 }
998
999 inline volatile waiting_thread_node*
1001 {
1002 return static_cast<volatile waiting_thread_node*> (static_double_list::head ());
1003 }
1004
1005 // ------------------------------------------------------------------------
1006 } /* namespace internal */
1007 } /* namespace rtos */
1008} /* namespace os */
1009
1010#pragma GCC diagnostic pop
1011
1012// ----------------------------------------------------------------------------
1013
1014#endif /* __cplusplus */
1015
1016// ----------------------------------------------------------------------------
1017
1018#endif /* CMSIS_PLUS_RTOS_INTERNAL_OS_LISTS_H_ */
Ordered list of time stamp nodes.
Definition os-lists.h:671
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:978
void link(timestamp_node &node)
Add a new thread node to the list.
Definition os-lists.cpp:414
clock_timestamps_list()
Construct a list of clock time stamps.
Definition os-lists.h:968
~clock_timestamps_list()
Destruct the list.
Definition os-lists.h:973
Priority ordered list of threads waiting too run.
Definition os-lists.h:466
ready_threads_list()
Construct a list of waiting threads.
Definition os-lists.h:906
~ready_threads_list()
Destruct the list.
Definition os-lists.h:911
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:916
void link(waiting_thread_node &node)
Add a new thread node to the list.
Definition os-lists.cpp:48
terminated_threads_list()
Construct a list of waiting threads.
Definition os-lists.h:990
volatile waiting_thread_node * head(void) const
Get list head.
Definition os-lists.h:1000
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:400
~thread_children_list()
Destruct the list.
Definition os-lists.h:895
thread_children_list()
Construct a list of waiting threads.
Definition os-lists.h:890
void link(thread &thread)
Add a new thread node to the list.
Definition os-lists.cpp:38
Double linked list node, with time stamp and thread.
Definition os-lists.h:223
rtos::thread & thread
Reference to thread who initiated the timeout.
Definition os-lists.h:294
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:316
timer & tmr
Reference to waiting timer.
Definition os-lists.h:385
virtual void action(void) override
Action to perform when the time stamp is reached.
Definition os-lists.cpp:384
virtual ~timer_node() override
Destruct the node.
Definition os-lists.cpp:372
Double linked list node, with time stamp.
Definition os-lists.h:130
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:200
virtual ~timestamp_node()
Destruct the node.
Definition os-lists.cpp:317
Double linked list node, with thread reference.
Definition os-lists.h:60
rtos::thread * thread_
Pointer to waiting thread.
Definition os-lists.h:108
~waiting_thread_node()
Destruct the node.
Definition os-lists.h:879
waiting_thread_node(thread &th)
Construct a node with references to the thread.
Definition os-lists.h:873
Priority ordered list of threads.
Definition os-lists.h:550
void link(waiting_thread_node &node)
Add a new thread node to the list.
Definition os-lists.cpp:193
bool resume_one(void)
Wake-up one thread (the oldest with the highest priority)
Definition os-lists.cpp:264
iterator end() const
Iterator begin.
Definition os-lists.h:957
waiting_threads_list()
Construct a list of waiting threads.
Definition os-lists.h:928
volatile waiting_thread_node * head(void) const
Get list head.
Definition os-lists.h:938
void resume_all(void)
Wake-up all threads in the list.
Definition os-lists.cpp:301
iterator begin() const
Iterator begin.
Definition os-lists.h:949
~waiting_threads_list()
Destruct the list.
Definition os-lists.h:933
POSIX compliant thread, using the default RTOS allocator.
Definition os-thread.h:250
User single-shot or periodic timer.
Definition os-timer.h:57
Template for a double linked list iterator.
Definition lists.h:211
N * iterator_pointer
Type of reference to the iterator internal pointer.
Definition lists.h:237
Circular double linked list of nodes.
Definition lists.h:497
Statically allocated circular double linked list of nodes.
Definition lists.h:350
static_double_list_links head_
A list node used to point to head and tail.
Definition lists.h:482
Standard thread.
uint64_t timestamp_t
Type of variables holding time stamps.
Definition os-decls.h:828
System namespace.