µ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 Liviu Ionescu.
5 *
6 * Permission is hereby granted, free of charge, to any person
7 * obtaining a copy of this software and associated documentation
8 * files (the "Software"), to deal in the Software without
9 * restriction, including without limitation the rights to use,
10 * copy, modify, merge, publish, distribute, sublicense, and/or
11 * sell copies of the Software, and to permit persons to whom
12 * the Software is furnished to do so, subject to the following
13 * conditions:
14 *
15 * The above copyright notice and this permission notice shall be
16 * included in all copies or substantial portions of the Software.
17 *
18 * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
19 * EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES
20 * OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
21 * NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT
22 * HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY,
23 * WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING
24 * FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR
25 * OTHER DEALINGS IN THE SOFTWARE.
26 */
27
28#ifndef CMSIS_PLUS_RTOS_INTERNAL_OS_LISTS_H_
29#define CMSIS_PLUS_RTOS_INTERNAL_OS_LISTS_H_
30
31// ----------------------------------------------------------------------------
32
33#ifdef __cplusplus
34
35// ----------------------------------------------------------------------------
36
38
39#include <cstdint>
40#include <cstddef>
41#include <cassert>
42#include <iterator>
43
44// ----------------------------------------------------------------------------
45
46#pragma GCC diagnostic push
47
48#if defined(__clang__)
49#pragma clang diagnostic ignored "-Wc++98-compat"
50#pragma clang diagnostic ignored "-Wdocumentation-unknown-command"
51#endif
52
53// ----------------------------------------------------------------------------
54
55namespace os
56{
57 namespace rtos
58 {
59 class thread;
60
61 namespace internal
62 {
63 // ======================================================================
64
65#pragma GCC diagnostic push
66#pragma GCC diagnostic ignored "-Wpadded"
67
72 {
73 public:
74
85
93 operator= (const waiting_thread_node&) = delete;
95 operator= (waiting_thread_node&&) = delete;
96
105
110 public:
111
121
125 };
126
127#pragma GCC diagnostic pop
128
129 // ======================================================================
130
131#pragma GCC diagnostic push
132#pragma GCC diagnostic ignored "-Wpadded"
133
138 {
139 public:
140
151
156 timestamp_node (const timestamp_node&) = delete;
157 timestamp_node (timestamp_node&&) = delete;
159 operator= (const timestamp_node&) = delete;
161 operator= (timestamp_node&&) = delete;
162
170 virtual
172
177 public:
178
191 virtual void
192 action (void) = 0;
193
198 public:
199
209
214 };
215
216#pragma GCC diagnostic pop
217
218 // ======================================================================
219
220#pragma GCC diagnostic push
221#pragma GCC diagnostic ignored "-Wpadded"
222
227 {
228 public:
229
241
249 operator= (const timeout_thread_node&) = delete;
251 operator= (timeout_thread_node&&) = delete;
252
260 virtual
261 ~timeout_thread_node () override;
262
267 public:
268
281 virtual void
282 action (void) override;
283
288 public:
289
299
303 };
304
305#pragma GCC diagnostic pop
306
307 // ======================================================================
308
309#pragma GCC diagnostic push
310#pragma GCC diagnostic ignored "-Wpadded"
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
879 inline
881 {
882 ;
883 }
884
885 // ======================================================================
886
891 inline
893 {
894 ;
895 }
896
897 inline
899 {
900 ;
901 }
902
903 // ======================================================================
904
909 inline
911 {
912 ;
913 }
914
915 inline
917 {
918 ;
919 }
920
921 inline volatile waiting_thread_node*
923 {
924 return static_cast<volatile waiting_thread_node*> (static_double_list::head ());
925 }
926
927 // ======================================================================
928
933 inline
935 {
936 ;
937 }
938
939 inline
941 {
942 ;
943 }
944
945 inline volatile waiting_thread_node*
947 {
948 return static_cast<volatile waiting_thread_node*> (double_list::head ());
949 }
950
953 {
954 return iterator
955 {
957 }
958
961 {
962 return iterator
963 {
965 }
966
967 // ======================================================================
968
969 inline
971 {
972 ;
973 }
974
975 inline
977 {
978 ;
979 }
980
981 inline volatile timestamp_node*
983 {
984 return static_cast<volatile timestamp_node*> (double_list::head ());
985 }
986
987 // ======================================================================
988
993 inline
995 {
996 ;
997 }
998
999 inline
1001 {
1002 ;
1003 }
1004
1005 inline volatile waiting_thread_node*
1007 {
1008 return static_cast<volatile waiting_thread_node*> (static_double_list::head ());
1009 }
1010
1011 // ------------------------------------------------------------------------
1012 } /* namespace internal */
1013 } /* namespace rtos */
1014} /* namespace os */
1015
1016#pragma GCC diagnostic pop
1017
1018// ----------------------------------------------------------------------------
1019
1020#endif /* __cplusplus */
1021
1022// ----------------------------------------------------------------------------
1023
1024#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:455
volatile timestamp_node * head(void) const
Get list head.
Definition os-lists.h:982
void link(timestamp_node &node)
Add a new thread node to the list.
Definition os-lists.cpp:392
clock_timestamps_list()
Construct a list of clock time stamps.
Definition os-lists.h:970
~clock_timestamps_list()
Destruct the list.
Definition os-lists.h:976
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:910
~ready_threads_list()
Destruct the list.
Definition os-lists.h:916
thread * unlink_head(void)
Remove the top node from the list.
Definition os-lists.cpp:123
volatile waiting_thread_node * head(void) const
Get list head.
Definition os-lists.h:922
void link(waiting_thread_node &node)
Add a new thread node to the list.
Definition os-lists.cpp:59
terminated_threads_list()
Construct a list of waiting threads.
Definition os-lists.h:994
volatile waiting_thread_node * head(void) const
Get list head.
Definition os-lists.h:1006
void link(waiting_thread_node &node)
Add a new thread node to the list.
Definition os-lists.cpp:494
List of children threads.
Definition os-lists.h:400
~thread_children_list()
Destruct the list.
Definition os-lists.h:898
thread_children_list()
Construct a list of waiting threads.
Definition os-lists.h:892
void link(thread &thread)
Add a new thread node to the list.
Definition os-lists.cpp:49
Double linked list node, with time stamp and thread.
Definition os-lists.h:227
rtos::thread & thread
Reference to thread who initiated the timeout.
Definition os-lists.h:298
virtual ~timeout_thread_node() override
Destruct the node.
Definition os-lists.cpp:320
virtual void action(void) override
Action to perform when the time stamp is reached.
Definition os-lists.cpp:329
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:367
virtual ~timer_node() override
Destruct the node.
Definition os-lists.cpp:355
Double linked list node, with time stamp.
Definition os-lists.h:138
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:208
virtual ~timestamp_node()
Destruct the node.
Definition os-lists.cpp:300
Double linked list node, with thread reference.
Definition os-lists.h:72
rtos::thread * thread_
Pointer to waiting thread.
Definition os-lists.h:120
~waiting_thread_node()
Destruct the node.
Definition os-lists.h:880
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:190
bool resume_one(void)
Wake-up one thread (the oldest with the highest priority)
Definition os-lists.cpp:247
iterator end() const
Iterator begin.
Definition os-lists.h:960
waiting_threads_list()
Construct a list of waiting threads.
Definition os-lists.h:934
volatile waiting_thread_node * head(void) const
Get list head.
Definition os-lists.h:946
void resume_all(void)
Wake-up all threads in the list.
Definition os-lists.cpp:284
iterator begin() const
Iterator begin.
Definition os-lists.h:952
~waiting_threads_list()
Destruct the list.
Definition os-lists.h:940
POSIX compliant thread, using the default RTOS allocator.
Definition os-thread.h:247
User single-shot or periodic timer.
Definition os-timer.h:65
Template for a double linked list iterator.
Definition lists.h:227
N * iterator_pointer
Type of reference to the iterator internal pointer.
Definition lists.h:253
Circular double linked list of nodes.
Definition lists.h:513
Statically allocated circular double linked list of nodes.
Definition lists.h:366
static_double_list_links head_
A list node used to point to head and tail.
Definition lists.h:498
Standard thread.
uint64_t timestamp_t
Type of variables holding time stamps.
Definition os-decls.h:846
System namespace.