µOS++ IIIe Reference  v6.3.15
“Perfekt ist nicht gut genug”
The third edition of µOS++, a POSIX inspired open source system, written in C++.
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 #include <cmsis-plus/utils/lists.h>
36 
37 #include <cstdint>
38 #include <cstddef>
39 #include <cassert>
40 #include <iterator>
41 
42 namespace os
43 {
44  namespace rtos
45  {
46  class thread;
47 
48  namespace internal
49  {
50  // ======================================================================
51 
52 #pragma GCC diagnostic push
53 #pragma GCC diagnostic ignored "-Wpadded"
54 
59  {
60  public:
61 
72 
77  waiting_thread_node (const waiting_thread_node&) = delete;
80  operator= (const waiting_thread_node&) = delete;
82  operator= (waiting_thread_node&&) = delete;
83 
92 
97  public:
98 
108 
112  };
113 
114 #pragma GCC diagnostic pop
115 
116  // ======================================================================
117 
118 #pragma GCC diagnostic push
119 #pragma GCC diagnostic ignored "-Wpadded"
120 
125  {
126  public:
127 
138 
143  timestamp_node (const timestamp_node&) = delete;
144  timestamp_node (timestamp_node&&) = delete;
146  operator= (const timestamp_node&) = delete;
148  operator= (timestamp_node&&) = delete;
149 
157  virtual
158  ~timestamp_node ();
159 
164  public:
165 
178  virtual void
179  action (void) = 0;
180 
185  public:
186 
196 
201  };
202 
203 #pragma GCC diagnostic pop
204 
205  // ======================================================================
206 
207 #pragma GCC diagnostic push
208 #pragma GCC diagnostic ignored "-Wpadded"
209 
214  {
215  public:
216 
228 
233  timeout_thread_node (const timeout_thread_node&) = delete;
236  operator= (const timeout_thread_node&) = delete;
238  operator= (timeout_thread_node&&) = delete;
239 
247  virtual
248  ~timeout_thread_node () override;
249 
254  public:
255 
268  virtual void
269  action (void) override;
270 
275  public:
276 
286 
290  };
291 
292 #pragma GCC diagnostic pop
293 
294  // ======================================================================
295 
296 #pragma GCC diagnostic push
297 #pragma GCC diagnostic ignored "-Wpadded"
298 
302  class timer_node : public timestamp_node
303  {
304  public:
305 
317 
321  timer_node (const timer_node&) = delete;
322  timer_node (timer_node&&) = delete;
323  timer_node&
324  operator= (const timer_node&) = delete;
325  timer_node&
326  operator= (timer_node&&) = delete;
334  virtual
335  ~timer_node () override;
336 
341  public:
342 
355  virtual void
356  action (void) override;
357 
362  public:
363 
373 
377  };
378 
379 #pragma GCC diagnostic pop
380 
381  // ======================================================================
382 
387  {
388  public:
389 
399 
404  thread_children_list (const thread_children_list&) = delete;
407  operator= (const thread_children_list&) = delete;
409  operator= (thread_children_list&&) = delete;
410 
419 
424  public:
425 
437  void
438  link (thread& thread);
439 
440  // TODO add iterator begin(), end()
441 
445  };
446 
447  // ======================================================================
448 
453  {
454  public:
455 
465 
470  ready_threads_list (const ready_threads_list&) = delete;
473  operator= (const ready_threads_list&) = delete;
475  operator= (ready_threads_list&&) = delete;
476 
484  ~ready_threads_list ();
485 
490  public:
491 
503  void
504  link (waiting_thread_node& node);
505 
512  volatile waiting_thread_node*
513  head (void) const;
514 
521  thread*
522  unlink_head (void);
523 
524  // TODO add iterator begin(), end()
525 
529  };
530 
531  // ======================================================================
532 
537  {
538  public:
539 
549 
563 
568  waiting_threads_list (const waiting_threads_list&) = delete;
571  operator= (const waiting_threads_list&) = delete;
573  operator= (waiting_threads_list&&) = delete;
574 
583 
588  public:
589 
601  void
602  link (waiting_thread_node& node);
603 
610  volatile waiting_thread_node*
611  head (void) const;
612 
620  bool
621  resume_one (void);
622 
630  void
631  resume_all (void);
632 
637  iterator
638  begin () const;
639 
644  iterator
645  end () const;
646 
650  };
651 
652  // ======================================================================
653 
658  {
659  public:
660 
670 
678  operator= (const clock_timestamps_list&) = delete;
680  operator= (clock_timestamps_list&&) = delete;
681 
690 
695  public:
696 
708  void
709  link (timestamp_node& node);
710 
717  volatile timestamp_node*
718  head (void) const;
719 
726  void
727  check_timestamp (port::clock::timestamp_t now);
728 
732  };
733 
734  // ======================================================================
735 
740  {
741  public:
742 
752 
760  operator= (const terminated_threads_list&) = delete;
762  operator= (terminated_threads_list&&) = delete;
763 
772 
777  public:
778 
790  void
791  link (waiting_thread_node& node);
792 
799  volatile waiting_thread_node*
800  head (void) const;
801 
802  // TODO add iterator begin(), end()
803 
808  };
809 
810  }
811  ;
812  /* namespace internal */
813 
814  // ------------------------------------------------------------------------
815  namespace scheduler
816  {
821  void
822  internal_link_node (internal::waiting_threads_list& list,
824 
825  void
826  internal_unlink_node (internal::waiting_thread_node& node);
827 
828  void
829  internal_link_node (internal::waiting_threads_list& list,
831  internal::clock_timestamps_list& timeout_list,
832  internal::timeout_thread_node& timeout_node);
833 
834  void
835  internal_unlink_node (internal::waiting_thread_node& node,
836  internal::timeout_thread_node& timeout_node);
837 
842  } /* namespace this_thread */
843 
844  // --------------------------------------------------------------------------
845 
846  } /* namespace rtos */
847 } /* namespace os */
848 
849 // ----------------------------------------------------------------------------
850 
851 namespace os
852 {
853  namespace rtos
854  {
855  namespace internal
856  {
857 
858  // ======================================================================
859 
860  inline
862  thread_ (&th)
863  {
864  ;
865  }
866 
867  inline
869  {
870  ;
871  }
872 
873  // ======================================================================
874 
879  inline
881  {
882  ;
883  }
884 
885  inline
887  {
888  ;
889  }
890 
891  // ======================================================================
892 
897  inline
899  {
900  ;
901  }
902 
903  inline
905  {
906  ;
907  }
908 
909  inline volatile waiting_thread_node*
911  {
912  return static_cast<volatile waiting_thread_node*> (static_double_list::head ());
913  }
914 
915  // ======================================================================
916 
921  inline
923  {
924  ;
925  }
926 
927  inline
929  {
930  ;
931  }
932 
933  inline volatile waiting_thread_node*
935  {
936  return static_cast<volatile waiting_thread_node*> (double_list::head ());
937  }
938 
941  {
942  return iterator
943  {
944  static_cast<waiting_threads_list::iterator::iterator_pointer> (head_.next ()) };
945  }
946 
949  {
950  return iterator
951  {
953  }
954 
955  // ======================================================================
956 
957  inline
959  {
960  ;
961  }
962 
963  inline
965  {
966  ;
967  }
968 
969  inline volatile timestamp_node*
971  {
972  return static_cast<volatile timestamp_node*> (double_list::head ());
973  }
974 
975  // ======================================================================
976 
981  inline
983  {
984  ;
985  }
986 
987  inline
989  {
990  ;
991  }
992 
993  inline volatile waiting_thread_node*
995  {
996  return static_cast<volatile waiting_thread_node*> (static_double_list::head ());
997  }
998 
999  // ------------------------------------------------------------------------
1000  } /* namespace internal */
1001  } /* namespace rtos */
1002 } /* namespace os */
1003 
1004 // ----------------------------------------------------------------------------
1005 
1006 #endif /* __cplusplus */
1007 
1008 #endif /* CMSIS_PLUS_RTOS_INTERNAL_OS_LISTS_H_ */
port::clock::timestamp_t timestamp
Time stamp when the next action will be performed.
Definition: os-lists.h:195
clock_timestamps_list()
Construct a list of clock time stamps.
Definition: os-lists.h:958
uint64_t timestamp_t
Type of variables holding time stamps.
Definition: os-decls.h:834
volatile timestamp_node * head(void) const
Get list head.
Definition: os-lists.h:970
~ready_threads_list()
Destruct the list.
Definition: os-lists.h:904
rtos::thread & thread
Reference to thread who initiated the timeout.
Definition: os-lists.h:285
Priority ordered list of threads.
Definition: os-lists.h:536
volatile waiting_thread_node * head(void) const
Get list head.
Definition: os-lists.h:934
Double linked list node, with thread reference.
Definition: os-lists.h:58
terminated_threads_list()
Construct a list of waiting threads.
Definition: os-lists.h:982
waiting_thread_node(thread &th)
Construct a node with references to the thread.
Definition: os-lists.h:861
~terminated_threads_list()
Destruct the list.
Definition: os-lists.h:988
volatile waiting_thread_node * head(void) const
Get list head.
Definition: os-lists.h:910
System namespace.
Double linked list node, with time stamp and thread.
Definition: os-lists.h:213
User single-shot or periodic timer.
Definition: os-timer.h:53
rtos::thread * thread_
Pointer to waiting thread.
Definition: os-lists.h:107
~waiting_threads_list()
Destruct the list.
Definition: os-lists.h:928
~clock_timestamps_list()
Destruct the list.
Definition: os-lists.h:964
Standard thread.
Double linked list node, with time stamp and timer.
Definition: os-lists.h:302
Priority ordered list of threads waiting too run.
Definition: os-lists.h:452
Statically allocated circular double linked list of nodes.
Definition: lists.h:353
POSIX compliant thread, using the default RTOS allocator.
Definition: os-thread.h:230
~waiting_thread_node()
Destruct the node.
Definition: os-lists.h:868
waiting_threads_list()
Construct a list of waiting threads.
Definition: os-lists.h:922
int link(const char *existing, const char *_new)
ready_threads_list()
Construct a list of waiting threads.
Definition: os-lists.h:898
Template for a double linked list iterator.
Definition: lists.h:214
volatile waiting_thread_node * head(void) const
Get list head.
Definition: os-lists.h:994
Unordered list of threads.
Definition: os-lists.h:739
iterator begin() const
Iterator begin.
Definition: os-lists.h:940
N * iterator_pointer
Type of reference to the iterator internal pointer.
Definition: lists.h:241
Circular double linked list of nodes.
Definition: lists.h:500
Ordered list of time stamp nodes.
Definition: os-lists.h:657
timer & tmr
Reference to waiting timer.
Definition: os-lists.h:372
~thread_children_list()
Destruct the list.
Definition: os-lists.h:886
thread_children_list()
Construct a list of waiting threads.
Definition: os-lists.h:880
List of children threads.
Definition: os-lists.h:386
Double linked list node, with time stamp.
Definition: os-lists.h:124
iterator end() const
Iterator begin.
Definition: os-lists.h:948