µ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.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 /*
29  * The initial µOS++ RTOS API was inspired by CMSIS RTOS API v1.x,
30  * Copyright (c) 2013 ARM LIMITED.
31  */
32 
66 /*
67  * TODO:
68  * - make Thread virtual, to allow create_hook/delete_hook functionality
69  * - make most classes virtual, to allow post_hook functionality
70  * - event timestamps: add derived classes that capture the event timestamp
71  * - add object type in base class
72  * - add Wait_list in base class
73  *
74  * Notes:
75  * - the try_wait(), try_flags_wait() names are probably not very inspired,
76  * but at least they are consistent in POSIX.
77  */
78 
79 #ifndef CMSIS_PLUS_RTOS_OS_H_
80 #define CMSIS_PLUS_RTOS_OS_H_
81 
82 // ----------------------------------------------------------------------------
83 
84 #if defined(__cplusplus)
85 
87 
89 
90 // Includes a reference to critical sections.
92 
102 
104 
105 // More or less at the end, when all other definitions are available.
107 #include <cmsis-plus/rtos/port/os-inlines.h>
108 
109 namespace os
110 {
111  namespace rtos
112  {
113  namespace scheduler
114  {
122  extern thread::threads_list top_threads_list_;
123 
133  thread::threads_list&
134  children_threads (thread* th);
135 
136  } /* namespace scheduler */
137 
138  // ------------------------------------------------------------------------
139 
140  namespace interrupts
141  {
142 #if defined(OS_HAS_INTERRUPTS_STACK) || defined(__DOXYGEN__)
143 
151  class thread::stack*
152  stack (void);
153 
154 #else
155 #endif /* defined(OS_HAS_INTERRUPTS_STACK) */
156 
157  ;
158  // Avoid formatter bug.
159  } /* namespace interrupts */
160 
161  // ------------------------------------------------------------------------
171  template<typename T, typename ... Args>
172  inline typename std::enable_if<!std::is_array<T>::value,
173  std::shared_ptr<T> >::type
174  make_shared (Args&&... args)
175  {
176  // -Wno-psabi to disble the ABI warning.
177  typedef typename std::remove_const<T>::type T_nc;
178  return std::allocate_shared<T> (memory::allocator<T_nc> (),
179  std::forward<Args>(args)...);
180  }
181 
182  } /* namespace rtos */
183 } /* namespace os */
184 
185 #endif /* __cplusplus */
186 
187 // ----------------------------------------------------------------------------
188 
189 #endif /* CMSIS_PLUS_RTOS_OS_H_ */
class thread::stack * stack(void)
Get the interrupts stack.
Definition: os-core.cpp:562
System namespace.
Standard thread.
std::enable_if<!std::is_array< T >::value, std::shared_ptr< T > >::type make_shared(Args &&... args)
Create an object that is owned by a shared_ptr and is allocated using the RTOS system allocator...
Definition: os.h:174
class thread::stack & stack(void)
Get the thread context stack.
Definition: os-thread.h:2396
thread::threads_list & children_threads(thread *th)
Get the children threads.
Definition: os-core.cpp:260
Standard allocator based on the RTOS system default memory manager.
Definition: os-decls.h:82