17#if defined(OS_USE_OS_APP_CONFIG_H)
18#include <cmsis-plus/os-app-config.h>
27#pragma clang diagnostic ignored "-Wc++98-compat"
28#elif defined(__GNUC__)
29#pragma GCC diagnostic ignored "-Wuseless-cast"
42 "adjust size of os_result_t");
44 "adjust align of os_result_t");
47 "adjust size of os_flags_mode_t");
49 "adjust align of os_flags_mode_t");
52 "adjust size of os_flags_mask_t");
54 "adjust align of os_flags_mask_t");
57 "adjust size of os_sched_state_t");
59 "adjust align of os_sched_state_t");
62 "adjust size of os_irq_state_t");
64 "adjust align of os_irq_state_t");
67 "adjust size of os_port_clock_timestamp_t");
69 "adjust align of os_port_clock_timestamp_t");
72 "adjust size of os_port_clock_duration_t");
74 "adjust align of os_port_clock_duration_t");
77 "adjust size of os_port_clock_offset_t");
79 "adjust align of os_port_clock_offset_t");
83 "adjust size of os_statistics_counter_t");
86 "adjust align of os_statistics_counter_t");
90 "adjust size of os_statistics_duration_t");
93 "adjust align of os_statistics_duration_t");
96 "adjust size of os_thread_func_args_t");
99 "adjust align of os_thread_func_args_t");
102 "adjust size of os_thread_func_t");
104 "adjust align of os_thread_func_t");
107 "adjust size of os_thread_state_t");
109 "adjust align of os_thread_state_t");
112 "adjust size of os_thread_prio_t");
114 "adjust align of os_thread_prio_t");
117 "adjust size of os_timer_func_args_t");
119 "adjust align of os_timer_func_args_t");
122 "adjust size of os_timer_func_t");
124 "adjust align of os_timer_func_t");
127 "adjust size of os_timer_type_t");
129 "adjust align of os_timer_type_t");
132 "adjust size of os_timer_state_t");
134 "adjust align of os_timer_state_t");
137 "adjust size of os_mutex_count_t");
139 "adjust align of os_mutex_count_t");
142 "adjust size of os_mutex_type_t");
144 "adjust align of os_mutex_type_t");
147 "adjust size of os_mutex_protocol_t");
149 "adjust align of os_mutex_protocol_t");
152 "adjust size of os_mutex_robustness_t");
155 "adjust align of os_mutex_robustness_t");
158 "adjust size of os_semaphore_count_t");
160 "adjust align of os_semaphore_count_t");
163 "adjust size of os_mempool_size_t");
165 "adjust align of os_mempool_size_t");
168 "adjust size of os_mqueue_size_t");
170 "adjust align of os_mqueue_size_t");
174 "adjust size of os_mqueue_msg_size_t");
177 "adjust align of os_mqueue_msg_size_t");
180 "adjust size of os_mqueue_index_t");
182 "adjust align of os_mqueue_index_t");
185 "adjust size of os_mqueue_prio_t");
188 "adjust align of os_mqueue_prio_t");
194#pragma GCC diagnostic push
195#if defined(__clang__)
196#pragma clang diagnostic ignored "-Wanon-enum-enum-conversion"
198#pragma GCC diagnostic ignored "-Wenum-compare"
199#pragma GCC diagnostic ignored "-Wsign-compare"
203 "adjust os_thread_priority_idle");
205 "adjust os_thread_priority_low");
208 "adjust os_thread_priority_below_normal");
210 "adjust os_thread_priority_normal");
213 "adjust os_thread_priority_above_normal");
215 "adjust os_thread_priority_high");
217 "adjust os_thread_priority_realtime");
219 "adjust os_thread_priority_error");
222 "adjust os_flags_mode_all");
224 "adjust os_flags_mode_any");
226 "adjust os_flags_mode_clear");
229 "adjust os_thread_state_undefined");
231 "adjust os_thread_state_initializing");
233 "adjust os_thread_state_ready");
235 "adjust os_thread_state_running");
237 "adjust os_thread_state_suspended");
239 "adjust os_thread_state_terminated");
241 "adjust os_thread_state_destroyed");
245 "adjust os_timer_periodic");
248 "adjust os_mutex_protocol_none");
250 "adjust os_mutex_protocol_inherit");
252 "adjust os_mutex_protocol_protect");
255 "adjust os_mutex_robustness_stalled");
257 "adjust os_mutex_robustness_robust");
260 "adjust os_mutex_type_normal");
262 "adjust os_mutex_type_errorcheck");
264 "adjust os_mutex_type_recursive");
266 "adjust os_mutex_type_default");
268#pragma GCC diagnostic pop
275#pragma GCC diagnostic push
276#if defined(__clang__)
277#pragma clang diagnostic ignored "-Winvalid-offsetof"
278#elif defined(__GNUC__)
279#pragma GCC diagnostic ignored "-Winvalid-offsetof"
283 "adjust os_clock_t size");
286 "adjust os_thread_t size");
288 "adjust os_thread_attr_t size");
291 "adjust os_thread_attr_t members");
294 "adjust os_thread_attr_t members");
297 "adjust os_thread_attr_t members");
300 "adjust os_thread_attr_t members");
303 "adjust size of os_timer_t");
305 "adjust size of os_timer_attr_t");
308 "adjust os_timer_attr_t members");
311 "adjust size of os_mutex_t");
313 "adjust size of os_mutex_attr_t");
316 "adjust os_mutex_attr_t members");
319 "adjust os_mutex_attr_t members");
322 "adjust os_mutex_attr_t members");
325 "adjust os_mutex_attr_t members");
328 "adjust os_mutex_attr_t members");
331 "adjust size of os_condvar_t");
334 "adjust size of os_condvar_attr_t");
337 "adjust size of os_semaphore_t");
340 "adjust size of os_semaphore_attr_t");
343 "adjust os_semaphore_attr_t members");
346 "adjust os_semaphore_attr_t members");
349 "adjust size of os_mempool_t");
352 "adjust size of os_mempool_attr_t");
355 "adjust os_mempool_attr_t members");
358 "adjust os_mempool_attr_t members");
361 "adjust size of os_mqueue_t");
364 "adjust size of os_mqueue_attr_t");
367 "adjust os_mqueue_attr_t members");
370 "adjust os_mqueue_attr_t members");
373 "adjust size of os_evflags_t");
376 "adjust size of os_evflags_attr_t");
379 "adjust size of os_thread_stack_t");
382 "adjust size of os_thread_context_t");
384#if defined(OS_INCLUDE_RTOS_STATISTICS_THREAD_CONTEXT_SWITCHES) \
385 || defined(OS_INCLUDE_RTOS_STATISTICS_THREAD_CPU_CYCLES)
388 "adjust size of os_thread_statistics_t");
393 "adjust size of os_internal_clock_timer_node_t");
395#pragma GCC diagnostic pop
397#pragma GCC diagnostic push
398#if defined(__clang__)
399#pragma clang diagnostic ignored "-Wold-style-cast"
400#elif defined(__GNUC__)
401#pragma GCC diagnostic ignored "-Wold-style-cast"
514#if defined(OS_INCLUDE_RTOS_STATISTICS_THREAD_CONTEXT_SWITCHES)
531#if defined(OS_INCLUDE_RTOS_STATISTICS_THREAD_CPU_CYCLES)
614#if defined(OS_HAS_INTERRUPTS_STACK) || defined(__DOXYGEN__)
654 return this_thread::suspend ();
666 this_thread::exit (exit_ptr);
679 return (
os_result_t)this_thread::flags_wait (mask, oflags, mode);
692 return (
os_result_t)this_thread::flags_try_wait (mask, oflags, mode);
706 return (
os_result_t)this_thread::flags_timed_wait (mask, timeout, oflags,
719 return (
os_result_t)this_thread::flags_clear (mask, oflags);
745 assert (attr !=
nullptr);
762 assert (
thread !=
nullptr);
783 assert (
thread !=
nullptr);
829 assert (
thread !=
nullptr);
842 assert (
thread !=
nullptr);
856 assert (
thread !=
nullptr);
869 assert (
thread !=
nullptr);
883 assert (
thread !=
nullptr);
897 assert (
thread !=
nullptr);
910 assert (
thread !=
nullptr);
924 assert (
thread !=
nullptr);
938 assert (
thread !=
nullptr);
940 .flags_raise (mask, oflags);
952 assert (
thread !=
nullptr);
957#if defined(OS_INCLUDE_RTOS_CUSTOM_THREAD_USER_STORAGE) || defined(__DOXYGEN__)
969os_thread_user_storage_t*
972 assert (
thread !=
nullptr);
987 assert (
thread !=
nullptr);
1051 assert (stack !=
nullptr);
1064 assert (stack !=
nullptr);
1077 assert (stack !=
nullptr);
1090 assert (stack !=
nullptr);
1103 assert (stack !=
nullptr);
1105 .check_bottom_magic ();
1117 assert (stack !=
nullptr);
1119 .check_top_magic ();
1124#if defined(OS_INCLUDE_RTOS_STATISTICS_THREAD_CONTEXT_SWITCHES)
1135 assert (
thread !=
nullptr);
1139 .context_switches ());
1144#if defined(OS_INCLUDE_RTOS_STATISTICS_THREAD_CPU_CYCLES)
1155 assert (
thread !=
nullptr);
1157 (
reinterpret_cast<rtos::thread&
> (*thread)).statistics ().cpu_cycles ());
1175#pragma GCC diagnostic push
1176#if defined(__clang__)
1177#elif defined(__GNUC__)
1178#pragma GCC diagnostic ignored "-Waggregate-return"
1183 .get_iterator_pointer ());
1184#pragma GCC diagnostic pop
1201#pragma GCC diagnostic push
1202#if defined(__clang__)
1203#elif defined(__GNUC__)
1204#pragma GCC diagnostic ignored "-Waggregate-return"
1209 .get_iterator_pointer ());
1210#pragma GCC diagnostic pop
1224 thread::threads_list::iterator it{
1240 thread::threads_list::iterator it{
1245 return reinterpret_cast<os_iterator_t> (it.get_iterator_pointer ());
1259 assert (
clock !=
nullptr);
1272 assert (
clock !=
nullptr);
1286 assert (
clock !=
nullptr);
1300 assert (
clock !=
nullptr);
1302 .sleep_for (duration);
1314 assert (
clock !=
nullptr);
1316 .sleep_until (timestamp);
1328 assert (
clock !=
nullptr);
1330 .wait_for (timeout);
1342 assert (
clock !=
nullptr);
1359 assert (
clock !=
nullptr);
1360 assert (
clock !=
nullptr);
1462 assert (attr !=
nullptr);
1475 assert (attr !=
nullptr);
1504 assert (
timer !=
nullptr);
1505 if (attr ==
nullptr)
1525 assert (
timer !=
nullptr);
1546 if (attr ==
nullptr)
1571 assert (
timer !=
nullptr);
1584 assert (
timer !=
nullptr);
1597 assert (
timer !=
nullptr);
1610 assert (
timer !=
nullptr);
1625 assert (attr !=
nullptr);
1638 assert (attr !=
nullptr);
1666 assert (
mutex !=
nullptr);
1667 if (attr ==
nullptr)
1686 assert (
mutex !=
nullptr);
1687 if (attr ==
nullptr)
1706 assert (
mutex !=
nullptr);
1726 if (attr ==
nullptr)
1750 if (attr ==
nullptr)
1775 assert (
mutex !=
nullptr);
1788 assert (
mutex !=
nullptr);
1801 assert (
mutex !=
nullptr);
1814 assert (
mutex !=
nullptr);
1827 assert (
mutex !=
nullptr);
1829 .timed_lock (timeout);
1841 assert (
mutex !=
nullptr);
1854 assert (
mutex !=
nullptr);
1870 assert (
mutex !=
nullptr);
1872 .prio_ceiling (prio_ceiling, old_prio_ceiling);
1884 assert (
mutex !=
nullptr);
1897 assert (
mutex !=
nullptr);
1910 assert (
mutex !=
nullptr);
1923 assert (
mutex !=
nullptr);
1936 assert (
mutex !=
nullptr);
1949 assert (
mutex !=
nullptr);
1964 assert (attr !=
nullptr);
1980 assert (condvar !=
nullptr);
1981 if (attr ==
nullptr)
2000 assert (condvar !=
nullptr);
2020 if (attr ==
nullptr)
2044 assert (condvar !=
nullptr);
2057 assert (condvar !=
nullptr);
2070 assert (condvar !=
nullptr);
2084 assert (condvar !=
nullptr);
2098 assert (condvar !=
nullptr);
2113 assert (condvar !=
nullptr);
2129 assert (attr !=
nullptr);
2143 assert (attr !=
nullptr);
2158 assert (attr !=
nullptr);
2187 if (attr ==
nullptr)
2259 if (attr ==
nullptr)
2398 .timed_wait (timeout);
2471 assert (attr !=
nullptr);
2487 assert (mempool !=
nullptr);
2488 if (attr ==
nullptr)
2492 new (mempool)
memory_pool (name, blocks, block_size_bytes,
2507 assert (mempool !=
nullptr);
2528 if (attr ==
nullptr)
2552 assert (mempool !=
nullptr);
2565 assert (mempool !=
nullptr);
2566 return (
reinterpret_cast<memory_pool&
> (*mempool)).name ();
2578 assert (mempool !=
nullptr);
2579 return (
reinterpret_cast<memory_pool&
> (*mempool)).alloc ();
2591 assert (mempool !=
nullptr);
2592 return (
reinterpret_cast<memory_pool&
> (*mempool)).try_alloc ();
2604 assert (mempool !=
nullptr);
2605 return (
reinterpret_cast<memory_pool&
> (*mempool)).timed_alloc (timeout);
2617 assert (mempool !=
nullptr);
2630 assert (mempool !=
nullptr);
2631 return (
reinterpret_cast<memory_pool&
> (*mempool)).capacity ();
2643 assert (mempool !=
nullptr);
2644 return (
reinterpret_cast<memory_pool&
> (*mempool)).count ();
2656 assert (mempool !=
nullptr);
2657 return (
reinterpret_cast<memory_pool&
> (*mempool)).block_size ();
2669 assert (mempool !=
nullptr);
2670 return (
reinterpret_cast<memory_pool&
> (*mempool)).empty ();
2682 assert (mempool !=
nullptr);
2683 return (
reinterpret_cast<memory_pool&
> (*mempool)).full ();
2695 assert (mempool !=
nullptr);
2708 assert (mempool !=
nullptr);
2709 return (
void*)(
reinterpret_cast<memory_pool&
> (*mempool)).pool ();
2723 assert (attr !=
nullptr);
2739 assert (mqueue !=
nullptr);
2740 if (attr ==
nullptr)
2759 assert (mqueue !=
nullptr);
2780 if (attr ==
nullptr)
2804 assert (mqueue !=
nullptr);
2817 assert (mqueue !=
nullptr);
2818 return (
reinterpret_cast<message_queue&
> (*mqueue)).name ();
2831 assert (mqueue !=
nullptr);
2833 .
send (msg, nbytes, mprio);
2846 assert (mqueue !=
nullptr);
2848 .try_send (msg, nbytes, mprio);
2861 assert (mqueue !=
nullptr);
2863 .timed_send (msg, nbytes, timeout, mprio);
2876 assert (mqueue !=
nullptr);
2878 .receive (msg, nbytes, mprio);
2891 assert (mqueue !=
nullptr);
2893 .try_receive (msg, nbytes, mprio);
2906 assert (mqueue !=
nullptr);
2908 .timed_receive (msg, nbytes, timeout, mprio);
2920 assert (mqueue !=
nullptr);
2921 return (
reinterpret_cast<message_queue&
> (*mqueue)).length ();
2933 assert (mqueue !=
nullptr);
2934 return (
reinterpret_cast<message_queue&
> (*mqueue)).capacity ();
2946 assert (mqueue !=
nullptr);
2947 return (
reinterpret_cast<message_queue&
> (*mqueue)).msg_size ();
2959 assert (mqueue !=
nullptr);
2960 return (
reinterpret_cast<message_queue&
> (*mqueue)).empty ();
2972 assert (mqueue !=
nullptr);
2973 return (
reinterpret_cast<message_queue&
> (*mqueue)).full ();
2985 assert (mqueue !=
nullptr);
3000 assert (attr !=
nullptr);
3016 assert (evflags !=
nullptr);
3017 if (attr ==
nullptr)
3035 assert (evflags !=
nullptr);
3055 if (attr ==
nullptr)
3079 assert (evflags !=
nullptr);
3092 assert (evflags !=
nullptr);
3093 return (
reinterpret_cast<event_flags&
> (*evflags)).name ();
3106 assert (evflags !=
nullptr);
3108 .
wait (mask, oflags, mode);
3121 assert (evflags !=
nullptr);
3123 .try_wait (mask, oflags, mode);
3137 assert (evflags !=
nullptr);
3139 .timed_wait (mask, timeout, oflags, mode);
3152 assert (evflags !=
nullptr);
3154 .
raise (mask, oflags);
3167 assert (evflags !=
nullptr);
3169 .clear (mask, oflags);
3182 assert (evflags !=
nullptr);
3196 assert (evflags !=
nullptr);
3197 return (
reinterpret_cast<event_flags&
> (*evflags)).waiting ();
3225 assert (memory !=
nullptr);
3226#pragma GCC diagnostic push
3227#pragma GCC diagnostic ignored "-Wcast-align"
3229 .allocate (bytes, alignment);
3230#pragma GCC diagnostic pop
3244 assert (memory !=
nullptr);
3245#pragma GCC diagnostic push
3246#pragma GCC diagnostic ignored "-Wcast-align"
3248 .deallocate (addr, bytes, alignment);
3249#pragma GCC diagnostic pop
3262 assert (memory !=
nullptr);
3263#pragma GCC diagnostic push
3264#pragma GCC diagnostic ignored "-Wcast-align"
3266#pragma GCC diagnostic pop
3279 assert (memory !=
nullptr);
3280#pragma GCC diagnostic push
3281#pragma GCC diagnostic ignored "-Wcast-align"
3284#pragma GCC diagnostic pop
3297 assert (memory !=
nullptr);
3298#pragma GCC diagnostic push
3299#pragma GCC diagnostic ignored "-Wcast-align"
3302#pragma GCC diagnostic pop
3315 assert (memory !=
nullptr);
3316#pragma GCC diagnostic push
3317#pragma GCC diagnostic ignored "-Wcast-align"
3319 .allocated_bytes ();
3320#pragma GCC diagnostic pop
3333 assert (memory !=
nullptr);
3334#pragma GCC diagnostic push
3335#pragma GCC diagnostic ignored "-Wcast-align"
3338#pragma GCC diagnostic pop
3351 assert (memory !=
nullptr);
3352#pragma GCC diagnostic push
3353#pragma GCC diagnostic ignored "-Wcast-align"
3355 .allocated_chunks ();
3356#pragma GCC diagnostic pop
3369 assert (memory !=
nullptr);
3370#pragma GCC diagnostic push
3371#pragma GCC diagnostic ignored "-Wcast-align"
3374#pragma GCC diagnostic pop
3451#if (defined(osFeature_SysTick) && (osFeature_SysTick != 0))
3470 return static_cast<uint32_t
> (
hrclock.
now ());
3500 if (thread_def ==
nullptr)
3516 for (uint32_t i = 0; i < thread_def->
instances; ++i)
3518#pragma GCC diagnostic push
3519#if defined(__clang__)
3520#pragma clang diagnostic ignored "-Wunsafe-buffer-usage"
3529 = &thread_def->
stack[(i)
3531 + sizeof (uint64_t) - 1)
3532 /
sizeof (uint64_t))];
3534#pragma GCC diagnostic push
3535#if defined(__clang__)
3536#pragma clang diagnostic ignored "-Wcast-function-type"
3537#elif defined(__GNUC__)
3538#pragma GCC diagnostic ignored "-Wcast-function-type"
3544#pragma GCC diagnostic pop
3549#pragma GCC diagnostic pop
3568 return reinterpret_cast<osThreadId> (&this_thread::thread ());
3590 if (thread_id ==
nullptr)
3596 = (
reinterpret_cast<rtos::thread&
> (*thread_id)).state ();
3602 if ((
reinterpret_cast<thread*
> (thread_id)) == &this_thread::thread ())
3604 this_thread::exit ();
3652 if (thread_id ==
nullptr)
3658 = (
reinterpret_cast<rtos::thread&
> (*thread_id)).state ();
3672 = ((
reinterpret_cast<rtos::thread&
> (*thread_id)).priority (prio));
3681 else if (res == EINVAL)
3706 if (thread_id ==
nullptr)
3713 = (
reinterpret_cast<rtos::thread&
> (*thread_id)).priority ();
3744 if (res == ETIMEDOUT)
3754#if (defined(osFeature_Wait) && (osFeature_Wait != 0))
3756#pragma GCC diagnostic push
3757#if defined(__clang__)
3758#elif defined(__GNUC__)
3759#pragma GCC diagnostic ignored "-Waggregate-return"
3780osWait (uint32_t millisec)
3794 if (res == ETIMEDOUT)
3806#pragma GCC diagnostic pop
3829 if (timer_def ==
nullptr)
3837#pragma GCC diagnostic push
3838#if defined(__clang__)
3839#pragma clang diagnostic ignored "-Wcast-function-type-strict"
3841 new ((
void*)timer_def->
data)
3844#pragma GCC diagnostic pop
3863 if (timer_id ==
nullptr)
3893 if (timer_id ==
nullptr)
3903 else if (res == EAGAIN)
3927 if (timer_id ==
nullptr)
3948 if (thread_id ==
nullptr)
3950 return (int32_t)0x80000000;
3953 if (signals == (int32_t)0x80000000)
3955 return (int32_t)0x80000000;
3960 return (int32_t)osig;
3972 if (thread_id ==
nullptr)
3974 return (int32_t)0x80000000;
3979 return (int32_t)0x80000000;
3984#if defined(OS_INCLUDE_RTOS_THREAD_PUBLIC_FLAGS_CLEAR)
3987 assert (((
thread*)(thread_id)) == &this_thread::thread ());
3991 return (int32_t)sig;
3994#pragma GCC diagnostic push
3995#if defined(__clang__)
3996#elif defined(__GNUC__)
3997#pragma GCC diagnostic ignored "-Waggregate-return"
4033 if ((uint32_t)signals & 0x80000000)
4045 else if (millisec == 0)
4052 res = this_thread::flags_timed_wait (
4062 else if (res == EWOULDBLOCK)
4064 event.status =
osOK;
4066 else if (res == ETIMEDOUT)
4070 else if (res == EPERM)
4074 else if (res == EINVAL)
4086#pragma GCC diagnostic pop
4106 if (mutex_def ==
nullptr)
4146 if (mutex_id ==
nullptr)
4154 ret = (
reinterpret_cast<rtos::mutex&
> (*mutex_id)).lock ();
4157 else if (millisec == 0)
4159 ret = (
reinterpret_cast<rtos::mutex&
> (*mutex_id)).try_lock ();
4163 ret = (
reinterpret_cast<rtos::mutex&
> (*mutex_id))
4174 else if (ret == EWOULDBLOCK)
4180 else if (ret == ENOTRECOVERABLE)
4186 else if (ret == ETIMEDOUT)
4216 if (mutex_id ==
nullptr)
4222 res = (
reinterpret_cast<rtos::mutex&
> (*mutex_id)).unlock ();
4228 else if ((res == EPERM) || (res == ENOTRECOVERABLE))
4255 if (mutex_id ==
nullptr)
4268#if (defined(osFeature_Semaphore) && (osFeature_Semaphore != 0))
4287 if (semaphore_def ==
nullptr)
4336 if (semaphore_id ==
nullptr)
4346 else if (millisec == 0)
4348 res = (
reinterpret_cast<rtos::semaphore&
> (*semaphore_id)).try_wait ();
4349 if (res == EWOULDBLOCK)
4359 if (res == ETIMEDOUT)
4367 int count = (int32_t)(
reinterpret_cast<rtos::semaphore&
> (*semaphore_id))
4387 if (semaphore_id ==
nullptr)
4392 if ((
reinterpret_cast<rtos::semaphore&
> (*semaphore_id)).initial_value ()
4404 else if (res == EAGAIN)
4431 if (semaphore_id ==
nullptr)
4445#if (defined(osFeature_Pool) && (osFeature_Pool != 0))
4461 if (pool_def ==
nullptr)
4470 new ((
void*)pool_def->
data)
4472 (std::size_t)pool_def->
item_sz, attr);
4486 if (pool_id ==
nullptr)
4491 return (
reinterpret_cast<memory_pool&
> (*pool_id)).try_alloc ();
4503 if (pool_id ==
nullptr)
4509 ret = (
reinterpret_cast<memory_pool&
> (*pool_id)).try_alloc ();
4513 (
reinterpret_cast<memory_pool&
> (*pool_id)).block_size ());
4528 if (pool_id ==
nullptr)
4533 if (block ==
nullptr)
4545 else if (res == EINVAL)
4560#if (defined(osFeature_MessageQ) && (osFeature_MessageQ != 0))
4570 osThreadId thread_id __attribute__ ((unused)))
4577 if (queue_def ==
nullptr)
4586 new ((
void*)queue_def->
data)
4588 (std::size_t)queue_def->
item_sz, attr);
4612#pragma GCC diagnostic push
4613#if defined(__clang__)
4614#pragma clang diagnostic ignored "-Wint-to-pointer-cast"
4617 if (queue_id ==
nullptr)
4630 .
send ((
const char*)&info,
sizeof (uint32_t), 0);
4633 else if (millisec == 0)
4636 .try_send ((
const char*)&info,
sizeof (uint32_t), 0);
4647 (
const char*)&info,
sizeof (uint32_t),
4658 else if (res == EWOULDBLOCK)
4663 else if (res == ETIMEDOUT)
4668 else if (res == EINVAL || res == EMSGSIZE)
4678#pragma GCC diagnostic pop
4681#pragma GCC diagnostic push
4682#if defined(__clang__)
4683#elif defined(__GNUC__)
4684#pragma GCC diagnostic ignored "-Waggregate-return"
4711 if (queue_id ==
nullptr)
4725 .receive ((
char*)&
event.value.v,
sizeof (uint32_t),
nullptr);
4728 else if (millisec == 0)
4731 .try_receive ((
char*)&
event.value.v,
sizeof (uint32_t),
4745 (
char*)&
event.value.v,
sizeof (uint32_t),
4757 else if (res == ETIMEDOUT)
4762 else if (res == EINVAL || res == EMSGSIZE)
4767 else if (res == EWOULDBLOCK)
4770 event.status =
osOK;
4780#pragma GCC diagnostic pop
4787#if (defined(osFeature_MailQ) && (osFeature_MailQ != 0))
4797 osThreadId thread_id __attribute__ ((unused)))
4804 if (mail_def ==
nullptr)
4852 if (mail_id ==
nullptr)
4857 void* ret =
nullptr;
4859#pragma GCC diagnostic push
4860#if defined(__clang__)
4861#elif defined(__GNUC__)
4862#pragma GCC diagnostic ignored "-Wstrict-aliasing"
4872 else if (millisec == 0)
4886#pragma GCC diagnostic pop
4919#pragma GCC diagnostic push
4920#if defined(__clang__)
4921#elif defined(__GNUC__)
4922#pragma GCC diagnostic ignored "-Wstrict-aliasing"
4926#pragma GCC diagnostic pop
4941 if (mail_id ==
nullptr)
4945 if (mail ==
nullptr)
4952#pragma GCC diagnostic push
4953#if defined(__clang__)
4954#pragma clang diagnostic ignored "-Wunsafe-buffer-usage"
4956 if (((
char*)mail < (
char*)(pool->
pool ()))
4957 || (((
char*)mail) >= ((
char*)(pool->
pool ())
4962#pragma GCC diagnostic pop
4965#pragma GCC diagnostic push
4966#if defined(__clang__)
4967#elif defined(__GNUC__)
4968#pragma GCC diagnostic ignored "-Wstrict-aliasing"
4971 .try_send ((
const char*)&mail,
sizeof (
void*), 0);
4972#pragma GCC diagnostic pop
4983#pragma GCC diagnostic push
4984#if defined(__clang__)
4985#elif defined(__GNUC__)
4986#pragma GCC diagnostic ignored "-Waggregate-return"
4988#pragma GCC diagnostic ignored "-Wstrict-aliasing"
5014 if (mail_id ==
nullptr)
5028 .receive ((
char*)&
event.value.p,
sizeof (
void*),
nullptr);
5031 else if (millisec == 0)
5034 .try_receive ((
char*)&
event.value.p,
sizeof (
void*),
nullptr);
5046 (
char*)&
event.value.p,
sizeof (
void*),
5057 else if (res == EWOULDBLOCK)
5060 event.status =
osOK;
5062 else if (res == EINVAL || res == EMSGSIZE)
5067 else if (res == ETIMEDOUT)
5080#pragma GCC diagnostic pop
5091 if (mail_id ==
nullptr)
5095 if (mail ==
nullptr)
5107#pragma GCC diagnostic pop
virtual timestamp_t now(void) override
Tell the current time.
static constexpr clock::duration_t ticks_cast(Rep_T microsec)
Convert microseconds to ticks.
result_t wait_for(duration_t timeout)
Timed wait for an event.
virtual result_t sleep_until(timestamp_t timestamp)
Sleep until an absolute timestamp.
virtual timestamp_t now(void)
Tell the current time, possibly adjusted for epoch.
result_t sleep_for(duration_t duration)
Sleep for a relative duration.
Condition variable attributes.
POSIX compliant condition variable.
Synchronised event flags.
Double linked list node, with time stamp and timer.
static void exit(state_t state)
Exit the interrupts critical section.
static state_t enter(void)
Enter an interrupts critical section.
static state_t enter(void)
Enter interrupts uncritical section.
static void exit(state_t state)
Exit interrupts uncritical section.
Memory resource manager (abstract class).
void * mp_pool_address
Address of the user defined storage for the memory pool.
std::size_t mp_pool_size_bytes
Size of the user defined storage for the memory pool.
Synchronised memory pool, using the default RTOS allocator.
std::size_t block_size(void) const
Get block size.
std::size_t capacity(void) const
Get memory pool capacity.
void * pool(void)
Get the pool storage address.
Message queue attributes.
void * mq_queue_address
Address of the user defined storage for the message queue.
std::size_t mq_queue_size_bytes
Size of the user defined storage for the message queue.
POSIX compliant message queue, using the default RTOS allocator.
Recursive mutex attributes.
type_t mx_type
Attribute with the mutex type.
protocol_t mx_protocol
Attribute with the mutex protocol.
POSIX compliant recursive mutex.
Binary semaphore attributes.
Counting semaphore attributes.
count_t sm_max_value
Semaphore max count value.
count_t sm_initial_value
Semaphore initial count value.
POSIX compliant binary semaphore.
POSIX compliant counting semaphore.
POSIX compliant semaphore.
std::size_t th_stack_size_bytes
Size of the user defined storage for the thread stack, in bytes.
priority_t th_priority
Thread initial priority.
void * th_stack_address
Address of the user defined storage for the thread stack.
static std::size_t default_size(void)
Get the default stack size.
static std::size_t min_size(void)
Get the min stack size.
POSIX compliant thread, using the default RTOS allocator.
result_t kill(void)
Force thread termination.
uint8_t state_t
Type of variables holding thread states.
result_t join(void **exit_ptr=nullptr)
Wait for thread termination.
void *(*)(func_args_t args) func_t
Type of thread function.
_func_args_t func_args_t
Type of thread function arguments.
static bool is_constructed(const thread &thread)
Check if the thread is constructed.
Periodic timer attributes.
type_t tm_type
Timer type attribute.
User single-shot or periodic timer.
The core of a double linked list, pointers to next, previous.
osEvent osMailGet(osMailQId mail_id, uint32_t millisec)
Get a mail from a queue.
osPoolId osPoolCreate(const osPoolDef_t *pool_def)
Create a memory pool.
osStatus osMailPut(osMailQId mail_id, void *mail)
Put a mail to a queue.
osStatus osPoolFree(osPoolId pool_id, void *block)
Free a memory block.
osEvent osMessageGet(osMessageQId queue_id, uint32_t millisec)
Get a message or Wait for a Message from a Queue.
#define osFeature_Semaphore
void * osMailAlloc(osMailQId mail_id, uint32_t millisec)
Allocate a memory block from a mail.
void * osMailCAlloc(osMailQId mail_id, uint32_t millisec)
Allocate and clear a memory block from a mail.
osEvent osWait(uint32_t millisec)
Wait for Signal, Message, Mail, or Timeout.
osSemaphoreId osSemaphoreCreate(const osSemaphoreDef_t *semaphore_def, int32_t count)
Create a semaphore.
#define osWaitForever
Timeout value.
void * osPoolCAlloc(osPoolId pool_id)
Allocate and clear a memory block.
void * osPoolAlloc(osPoolId pool_id)
Allocate a memory block.
osStatus osMailFree(osMailQId mail_id, void *mail)
Free a memory block from a mail.
osStatus osSemaphoreRelease(osSemaphoreId semaphore_id)
Release the semaphore.
osMailQId osMailCreate(const osMailQDef_t *mail_def, osThreadId thread_id)
Create a mail queue.
osStatus osSemaphoreDelete(osSemaphoreId semaphore_id)
Delete the semaphore.
osStatus osMessagePut(osMessageQId queue_id, uint32_t info, uint32_t millisec)
Put a message to a queue.
int32_t osSemaphoreWait(osSemaphoreId semaphore_id, uint32_t millisec)
Wait until a Semaphore token becomes available.
uint32_t osKernelSysTick(void)
Get the system timer counter.
os_timer_type
Timer type value for the timer definition.
osStatus
Status code values returned by CMSIS-RTOS functions.
osMessageQId osMessageCreate(const osMessageQDef_t *queue_def, osThreadId thread_id)
Create a message queue.
pid_t wait(int *stat_loc)
int kill(pid_t pid, int sig)
ssize_t send(int socket, const void *buffer, size_t length, int flags)
os_clock_timestamp_t os_clock_now(os_clock_t *clock)
Tell the current time, possibly adjusted for epoch.
os_result_t os_sysclock_wait_for(os_clock_duration_t timeout)
Timed wait for an event.
os_result_t os_clock_sleep_for(os_clock_t *clock, os_clock_duration_t duration)
Sleep for a relative duration.
const char * os_clock_get_name(os_clock_t *clock)
Get the clock name.
os_result_t os_clock_wait_for(os_clock_t *clock, os_clock_duration_t timeout)
Timed wait for an event.
os_clock_timestamp_t os_sysclock_now(void)
Tell the current time since startup.
os_clock_offset_t os_clock_get_offset(os_clock_t *clock)
Get adjustment offset.
os_clock_timestamp_t os_clock_steady_now(os_clock_t *clock)
Tell the current time since startup.
os_clock_t * os_clock_get_sysclock(void)
Get sysclock (the system clock).
os_result_t os_sysclock_sleep_until(os_clock_timestamp_t timestamp)
Sleep until an absolute timestamp.
os_clock_t * os_clock_get_rtclock(void)
Get rtclock (the real-time clock).
os_result_t os_sysclock_sleep_for(os_clock_duration_t duration)
Sleep for a relative duration.
os_clock_t * os_clock_get_hrclock(void)
Get hrclock (the high resolution clock).
os_clock_offset_t os_clock_set_offset(os_clock_t *clock, os_clock_offset_t offset)
Set adjustment offset.
os_result_t os_clock_sleep_until(os_clock_t *clock, os_clock_timestamp_t timestamp)
Sleep until an absolute timestamp.
os_result_t os_condvar_timed_wait(os_condvar_t *condvar, os_mutex_t *mutex, os_clock_duration_t timeout)
Timed wait for a condition variable to be notified.
void os_condvar_delete(os_condvar_t *condvar)
Destruct the condition variable object instance and deallocate it.
os_result_t os_condvar_signal(os_condvar_t *condvar)
Notify one thread waiting for a condition variable.
void os_condvar_construct(os_condvar_t *condvar, const char *name, const os_condvar_attr_t *attr)
Construct a statically allocated condition variable object instance.
void os_condvar_destruct(os_condvar_t *condvar)
Destruct the statically allocated condition variable object instance.
os_result_t os_condvar_wait(os_condvar_t *condvar, os_mutex_t *mutex)
Wait for a condition variable to be notified.
os_condvar_t * os_condvar_new(const char *name, const os_condvar_attr_t *attr)
Allocate a condition variable object instance and construct it.
const char * os_condvar_get_name(os_condvar_t *condvar)
Get the condition variable name.
os_result_t os_condvar_broadcast(os_condvar_t *condvar)
Notify all threads waiting for a condition variable.
void os_condvar_attr_init(os_condvar_attr_t *attr)
Initialise the condition variable attributes.
bool os_irq_in_handler_mode(void)
Check if the CPU is in handler mode.
void os_irq_uncritical_exit(os_irq_state_t state)
Exit the interrupts uncritical section.
bool os_sched_is_locked(void)
Check if the scheduler is locked.
os_irq_state_t os_irq_uncritical_enter(void)
Enter an interrupts uncritical section.
void os_sched_start(void)
Start the RTOS scheduler.
bool os_sched_is_started(void)
Check if the scheduler was started.
os_sched_state_t os_sched_set_locked(os_sched_state_t state)
Lock/unlock the scheduler.
bool os_sched_set_preemptive(bool state)
Set the scheduler preemptive mode.
os_result_t os_sched_initialize(void)
Initialise the RTOS scheduler.
os_statistics_duration_t os_sched_stat_get_cpu_cycles(void)
Get the total duration of all threads.
uint32_t os_flags_mask_t
Type of variables holding flags masks.
uint64_t os_statistics_counter_t
Type of variables holding context switches counters.
os_thread_stack_t * os_irq_get_stack(void)
Get the interrupts stack.
os_sched_state_t os_sched_unlock(void)
Unlock the scheduler.
os_sched_state_t os_sched_lock(void)
Lock the scheduler.
os_port_irq_state_t os_irq_state_t
Type of variables holding interrupts priority values.
void os_irq_critical_exit(os_irq_state_t state)
Exit the interrupts critical section.
uint32_t os_flags_mode_t
Type of variables holding flags modes.
os_statistics_counter_t os_sched_stat_get_context_switches(void)
Get the total number of context switches.
bool os_sched_is_preemptive(void)
Check if the scheduler is in preemptive mode.
os_port_scheduler_state_t os_sched_state_t
Type of variables holding scheduler state codes.
os_port_clock_offset_t os_clock_offset_t
Type of variables holding clock offsets.
void * os_iterator_t
Generic iterator, implemented as a pointer.
uint64_t os_statistics_duration_t
Type of variables holding durations in CPU cycles.
os_irq_state_t os_irq_critical_enter(void)
Enter an interrupts critical section.
os_port_clock_duration_t os_clock_duration_t
Type of variables holding clock durations.
os_port_clock_timestamp_t os_clock_timestamp_t
Type of variables holding clock time stamps.
uint32_t os_result_t
Type of values returned by RTOS functions.
os_result_t os_evflags_try_wait(os_evflags_t *evflags, os_flags_mask_t mask, os_flags_mask_t *oflags, os_flags_mode_t mode)
Try to wait for event flags.
os_result_t os_evflags_clear(os_evflags_t *evflags, os_flags_mask_t mask, os_flags_mask_t *oflags)
Clear event flags.
os_result_t os_evflags_wait(os_evflags_t *evflags, os_flags_mask_t mask, os_flags_mask_t *oflags, os_flags_mode_t mode)
Wait for event flags.
const char * os_evflags_get_name(os_evflags_t *evflags)
Get the event flags name.
bool os_evflags_are_waiting(os_evflags_t *evflags)
Check if there are threads waiting.
os_result_t os_evflags_raise(os_evflags_t *evflags, os_flags_mask_t mask, os_flags_mask_t *oflags)
Raise event flags.
void os_evflags_attr_init(os_evflags_attr_t *attr)
Initialise the event flags attributes.
os_flags_mask_t os_evflags_get(os_evflags_t *evflags, os_flags_mask_t mask, os_flags_mode_t mode)
Get (and possibly clear) event flags.
void os_evflags_delete(os_evflags_t *evflags)
Destruct the event flags object instance and deallocate it.
os_result_t os_evflags_timed_wait(os_evflags_t *evflags, os_flags_mask_t mask, os_clock_duration_t timeout, os_flags_mask_t *oflags, os_flags_mode_t mode)
Timed wait for event flags.
void os_evflags_destruct(os_evflags_t *evflags)
Destruct the statically allocated event flags object instance.
os_evflags_t * os_evflags_new(const char *name, const os_evflags_attr_t *attr)
Allocate an event flags object instance and construct it.
void os_evflags_construct(os_evflags_t *evflags, const char *name, const os_evflags_attr_t *attr)
Construct a statically allocated event flags object instance.
os_result_t os_mempool_free(os_mempool_t *mempool, void *block)
Free the memory block.
void os_mempool_construct(os_mempool_t *mempool, const char *name, size_t blocks, size_t block_size_bytes, const os_mempool_attr_t *attr)
Construct a statically allocated memory pool object instance.
void * os_mempool_get_pool(os_mempool_t *mempool)
Get the pool storage address.
void * os_mempool_alloc(os_mempool_t *mempool)
Allocate a memory block.
const char * os_mempool_get_name(os_mempool_t *mempool)
Get the memory pool name.
bool os_mempool_is_empty(os_mempool_t *mempool)
Check if the memory pool is empty.
void * os_mempool_timed_alloc(os_mempool_t *mempool, os_clock_duration_t timeout)
Allocate a memory block with timeout.
void os_mempool_attr_init(os_mempool_attr_t *attr)
Initialise the memory pool attributes.
void * os_mempool_try_alloc(os_mempool_t *mempool)
Try to allocate a memory block.
os_mempool_t * os_mempool_new(const char *name, size_t blocks, size_t block_size_bytes, const os_mempool_attr_t *attr)
Allocate a memory pool object instance and construct it.
os_result_t os_mempool_reset(os_mempool_t *mempool)
Reset the memory pool.
size_t os_mempool_get_count(os_mempool_t *mempool)
Get blocks count.
void os_mempool_delete(os_mempool_t *mempool)
Destruct the memory pool object instance and deallocate it.
void os_mempool_destruct(os_mempool_t *mempool)
Destruct the statically allocated memory pool object instance.
size_t os_mempool_get_block_size(os_mempool_t *mempool)
Get block size.
size_t os_mempool_get_capacity(os_mempool_t *mempool)
Get memory pool capacity.
bool os_mempool_is_full(os_mempool_t *mempool)
Check if the memory pool is full.
os_memory_t * os_memory_get_default(void)
Get the application default memory resource (free store).
size_t os_memory_get_free_bytes(os_memory_t *memory)
Get the total size of free chunks.
void os_memory_reset(os_memory_t *memory)
Reset the memory manager to the initial state.
size_t os_memory_get_allocated_bytes(os_memory_t *memory)
Get the total size of allocated chunks.
bool os_memory_coalesce(os_memory_t *memory)
Coalesce free blocks.
void * os_memory_allocate(os_memory_t *memory, size_t bytes, size_t alignment)
Allocate a block of memory.
size_t os_memory_get_total_bytes(os_memory_t *memory)
Get the total size of managed memory.
size_t os_memory_get_free_chunks(os_memory_t *memory)
Get the number of free chunks.
size_t os_memory_get_allocated_chunks(os_memory_t *memory)
Get the number of allocated chunks.
void free(void *ptr)
Free the allocated memory block.
void os_memory_deallocate(os_memory_t *memory, void *addr, size_t bytes, size_t alignment)
Deallocate the previously allocated block of memory.
bool os_mqueue_is_full(os_mqueue_t *mqueue)
Check if the queue is full.
os_result_t os_mqueue_reset(os_mqueue_t *mqueue)
Reset the message queue.
os_result_t os_mqueue_timed_send(os_mqueue_t *mqueue, const void *msg, size_t nbytes, os_clock_duration_t timeout, os_mqueue_prio_t mprio)
Send a message to the queue with timeout.
os_result_t os_mqueue_receive(os_mqueue_t *mqueue, void *msg, size_t nbytes, os_mqueue_prio_t *mprio)
Receive a message from the queue.
os_result_t os_mqueue_try_receive(os_mqueue_t *mqueue, void *msg, size_t nbytes, os_mqueue_prio_t *mprio)
Try to receive a message from the queue.
void os_mqueue_delete(os_mqueue_t *mqueue)
Destruct the message queue object instance and deallocate it.
size_t os_mqueue_get_msg_size(os_mqueue_t *mqueue)
Get message size.
bool os_mqueue_is_empty(os_mqueue_t *mqueue)
Check if the queue is empty.
const char * os_mqueue_get_name(os_mqueue_t *mqueue)
Get the message queue name.
os_result_t os_mqueue_send(os_mqueue_t *mqueue, const void *msg, size_t nbytes, os_mqueue_prio_t mprio)
Send a message to the queue.
void os_mqueue_destruct(os_mqueue_t *mqueue)
Destruct the statically allocated message queue object instance.
size_t os_mqueue_get_capacity(os_mqueue_t *mqueue)
Get queue capacity.
os_mqueue_t * os_mqueue_new(const char *name, size_t msgs, size_t msg_size_bytes, const os_mqueue_attr_t *attr)
Allocate a message queue object instance and construct it.
size_t os_mqueue_get_length(os_mqueue_t *mqueue)
Get queue length.
void os_mqueue_attr_init(os_mqueue_attr_t *attr)
Initialise the message queue attributes.
void os_mqueue_construct(os_mqueue_t *mqueue, const char *name, size_t msgs, size_t msg_size_bytes, const os_mqueue_attr_t *attr)
Construct a statically allocated message queue object instance.
os_result_t os_mqueue_try_send(os_mqueue_t *mqueue, const void *msg, size_t nbytes, os_mqueue_prio_t mprio)
Try to send a message to the queue.
os_result_t os_mqueue_timed_receive(os_mqueue_t *mqueue, void *msg, size_t nbytes, os_clock_duration_t timeout, os_mqueue_prio_t *mprio)
Receive a message from the queue with timeout.
uint8_t os_mqueue_prio_t
Type of variables holding message queue priorities.
const char * os_mutex_get_name(os_mutex_t *mutex)
Get the mutex name.
void os_mutex_recursive_construct(os_mutex_t *mutex, const char *name, const os_mutex_attr_t *attr)
Construct a statically allocated recursive mutex object instance.
void os_mutex_attr_recursive_init(os_mutex_attr_t *attr)
Initialise the recursive mutex attributes.
os_mutex_type_t os_mutex_get_type(os_mutex_t *mutex)
Get the mutex type.
os_thread_prio_t os_mutex_get_prio_ceiling(os_mutex_t *mutex)
Get the priority ceiling of a mutex.
void os_mutex_destruct(os_mutex_t *mutex)
Destruct the statically allocated mutex object instance.
os_result_t os_mutex_set_prio_ceiling(os_mutex_t *mutex, os_thread_prio_t prio_ceiling, os_thread_prio_t *old_prio_ceiling)
Change the priority ceiling of a mutex.
void os_mutex_attr_init(os_mutex_attr_t *attr)
Initialise the mutex attributes.
os_result_t os_mutex_timed_lock(os_mutex_t *mutex, os_clock_duration_t timeout)
Timed attempt to lock/acquire the mutex.
os_result_t os_mutex_try_lock(os_mutex_t *mutex)
Try to lock/acquire the mutex.
os_mutex_protocol_t os_mutex_get_protocol(os_mutex_t *mutex)
Get the mutex protocol.
void os_mutex_delete(os_mutex_t *mutex)
Destruct the mutex object instance and deallocate it.
os_result_t os_mutex_unlock(os_mutex_t *mutex)
Unlock/release the mutex.
os_thread_t * os_mutex_get_owner(os_mutex_t *mutex)
Get the thread that owns the mutex.
os_mutex_t * os_mutex_recursive_new(const char *name, const os_mutex_attr_t *attr)
Allocated a recursive mutex object instance and construct it.
os_result_t os_mutex_mark_consistent(os_mutex_t *mutex)
Mark mutex as consistent.
os_result_t os_mutex_lock(os_mutex_t *mutex)
Lock/acquire the mutex.
os_mutex_robustness_t os_mutex_get_robustness(os_mutex_t *mutex)
Get the mutex robustness.
os_result_t os_mutex_reset(os_mutex_t *mutex)
Reset the mutex.
const os_mutex_attr_t * os_mutex_attr_get_recursive(void)
Get a recursive mutex attributes object instance.
os_mutex_t * os_mutex_new(const char *name, const os_mutex_attr_t *attr)
Allocate a mutex object instance and construct it.
void os_mutex_construct(os_mutex_t *mutex, const char *name, const os_mutex_attr_t *attr)
Construct a statically allocated mutex object instance.
@ os_mutex_protocol_inherit
Inherit priority from highest priority thread.
@ os_mutex_protocol_protect
Execute at the highest priority.
@ os_mutex_protocol_none
Priority and scheduling not affected by mutex ownership.
@ os_mutex_type_recursive
Recursive mutex behaviour.
@ os_mutex_type_errorcheck
Check mutex behaviour.
@ os_mutex_type_default
Default mutex type.
@ os_mutex_type_normal
Normal mutex behaviour.
@ os_mutex_robustness_robust
Enhanced robustness at thread termination.
@ os_mutex_robustness_stalled
Normal robustness.
os_semaphore_t * os_semaphore_counting_new(const char *name, const os_semaphore_count_t max_value, const os_semaphore_count_t initial_value)
Allocate a counting semaphore object instance and construct it.
os_result_t os_semaphore_timed_wait(os_semaphore_t *semaphore, os_clock_duration_t timeout)
Timed wait to lock the semaphore.
os_semaphore_t * os_semaphore_binary_new(const char *name, const os_semaphore_count_t initial_value)
Allocate a binary semaphore object instance and construct it.
os_semaphore_count_t os_semaphore_get_initial_value(os_semaphore_t *semaphore)
Get the semaphore initial count value.
const os_semaphore_attr_t * os_semaphore_attr_get_binary(void)
Get a binary semaphore attributes object instance.
const char * os_semaphore_get_name(os_semaphore_t *semaphore)
Get the semaphore name.
void os_semaphore_attr_binary_init(os_semaphore_attr_t *attr, const os_semaphore_count_t initial_value)
Initialise the binary semaphore attributes.
void os_semaphore_attr_counting_init(os_semaphore_attr_t *attr, const os_semaphore_count_t max_value, const os_semaphore_count_t initial_value)
Initialise the counting semaphore attributes.
os_result_t os_semaphore_post(os_semaphore_t *semaphore)
Post (unlock) the semaphore.
os_result_t os_semaphore_wait(os_semaphore_t *semaphore)
Lock the semaphore, possibly waiting.
os_semaphore_count_t os_semaphore_get_value(os_semaphore_t *semaphore)
Get the semaphore count value.
void os_semaphore_destruct(os_semaphore_t *semaphore)
Destruct the statically allocated semaphore object instance.
void os_semaphore_binary_construct(os_semaphore_t *semaphore, const char *name, const os_semaphore_count_t initial_value)
Construct a statically allocated binary semaphore object instance.
os_semaphore_count_t os_semaphore_get_max_value(os_semaphore_t *semaphore)
Get the semaphore maximum count value.
void os_semaphore_counting_construct(os_semaphore_t *semaphore, const char *name, const os_semaphore_count_t max_value, const os_semaphore_count_t initial_value)
Construct a statically allocated counting semaphore object instance.
void os_semaphore_delete(os_semaphore_t *semaphore)
Destruct the semaphore object instance.
os_result_t os_semaphore_reset(os_semaphore_t *semaphore)
Reset the semaphore.
os_semaphore_t * os_semaphore_new(const char *name, const os_semaphore_attr_t *attr)
Allocated a semaphore object instance and construct it.
void os_semaphore_attr_init(os_semaphore_attr_t *attr)
Initialise the counting semaphore attributes.
void os_semaphore_construct(os_semaphore_t *semaphore, const char *name, const os_semaphore_attr_t *attr)
Construct a statically allocated semaphore object instance.
int16_t os_semaphore_count_t
Type of variables holding semaphore counts.
os_result_t os_semaphore_try_wait(os_semaphore_t *semaphore)
Try to lock the semaphore.
void os_thread_attr_init(os_thread_attr_t *attr)
Initialise the thread attributes.
os_result_t os_this_thread_flags_timed_wait(os_flags_mask_t mask, os_clock_duration_t timeout, os_flags_mask_t *oflags, os_flags_mode_t mode)
Timed wait for thread event flags.
os_iterator_t os_children_threads_iter_next(os_iterator_t iterator)
Advance the iterator to the next position.
os_thread_user_storage_t * os_thread_get_user_storage(os_thread_t *thread)
Get the thread user storage.
bool os_thread_is_constructed(os_thread_t *thread)
Check if the thread is constructed.
os_flags_mask_t os_this_thread_flags_get(os_flags_mask_t mask, os_flags_mode_t mode)
Get/clear thread event flags.
const char * os_thread_get_name(os_thread_t *thread)
Get the thread name.
os_result_t os_this_thread_flags_wait(os_flags_mask_t mask, os_flags_mask_t *oflags, os_flags_mode_t mode)
Wait for thread event flags.
void *(* os_thread_func_t)(os_thread_func_args_t args)
Type of thread function.
uint8_t os_thread_prio_t
Type of variables holding thread priorities.
os_thread_stack_element_t * os_thread_stack_get_bottom(os_thread_stack_t *stack)
Get the stack lowest reserved address.
struct os_thread_statistics_s os_thread_statistics_t
Thread statistics.
struct os_thread_stack_s os_thread_stack_t
Thread stack.
size_t os_thread_stack_set_default_size(size_t size_bytes)
Set the default stack size.
void os_thread_construct(os_thread_t *thread, const char *name, os_thread_func_t func, const os_thread_func_args_t args, const os_thread_attr_t *attr)
Construct a statically allocated thread object instance.
void os_this_thread_suspend(void)
Suspend the current running thread to wait for an event.
os_statistics_counter_t os_thread_stat_get_context_switches(os_thread_t *thread)
Get the number of thread context switches.
void os_thread_resume(os_thread_t *thread)
Resume the thread.
void os_thread_delete(os_thread_t *thread)
Destruct the thread object instance and deallocate it.
os_result_t os_this_thread_flags_clear(os_flags_mask_t mask, os_flags_mask_t *oflags)
Clear thread event flags.
bool os_thread_stack_check_top_magic(os_thread_stack_t *stack)
Check if top magic word is still there.
os_result_t os_thread_join(os_thread_t *thread, void **exit_ptr)
Wait for thread termination.
os_thread_stack_element_t * os_thread_stack_get_top(os_thread_stack_t *stack)
Get the top stack address.
os_thread_state_t os_thread_get_state(os_thread_t *thread)
Get the thread scheduler state.
os_iterator_t os_children_threads_iter_begin(os_thread_t *thread)
Get the beginning of the list of children threads.
bool os_thread_stack_check_bottom_magic(os_thread_stack_t *stack)
Check if bottom magic word is still there.
os_port_thread_stack_element_t os_thread_stack_element_t
Type of variables holding stack words.
os_thread_prio_t os_thread_get_priority(os_thread_t *thread)
Get the thread current scheduling priority.
void * os_thread_func_args_t
Type of thread function arguments.
os_thread_t * os_this_thread(void)
Get the current running thread.
os_thread_stack_t * os_thread_get_stack(os_thread_t *thread)
Get the thread context stack.
os_result_t os_thread_kill(os_thread_t *thread)
Force thread termination.
os_thread_t * os_thread_new(const char *name, os_thread_func_t func, const os_thread_func_args_t args, const os_thread_attr_t *attr)
Allocate a thread object instance and construct it.
os_thread_t * os_children_threads_iter_get(os_iterator_t iterator)
Get the thread from the current iterator position.
size_t os_thread_stack_get_size(os_thread_stack_t *stack)
Get the stack size.
size_t os_thread_stack_get_min_size(void)
Get the min stack size.
size_t os_thread_stack_get_available(os_thread_stack_t *stack)
Compute how much available stack remains.
os_statistics_duration_t os_thread_stat_get_cpu_cycles(os_thread_t *thread)
Get the thread execution time.
os_result_t os_thread_set_priority(os_thread_t *thread, os_thread_prio_t prio)
Set the thread dynamic scheduling priority.
void os_this_thread_exit(void *exit_ptr)
Terminate the current running thread.
os_result_t os_this_thread_flags_try_wait(os_flags_mask_t mask, os_flags_mask_t *oflags, os_flags_mode_t mode)
Try to wait for thread event flags.
uint8_t os_thread_state_t
Type of variables holding thread states.
size_t os_thread_stack_get_default_size(void)
Get the default stack size.
size_t os_thread_stack_set_min_size(size_t size_bytes)
Set the min stack size.
os_iterator_t os_children_threads_iter_end(os_thread_t *thread)
Get the end of the list of children threads.
os_result_t os_thread_flags_raise(os_thread_t *thread, os_flags_mask_t mask, os_flags_mask_t *oflags)
Raise thread event flags.
void os_thread_destruct(os_thread_t *thread)
Destruct the statically allocated thread object instance.
@ os_thread_state_terminated
No longer usable, but resources not yet released.
@ os_thread_state_suspended
Not present in the READY list, waiting for an event.
@ os_thread_state_undefined
Used to catch uninitialised threads.
@ os_thread_state_ready
Present in the READY list and competing for CPU.
@ os_thread_state_initialising
Used to check reused threads.
@ os_thread_state_destroyed
Terminated and resources (like stack) released.
@ os_thread_state_running
Has the CPU and runs.
@ os_thread_priority_error
@ os_thread_priority_below_normal
@ os_thread_priority_high
@ os_thread_priority_realtime
@ os_thread_priority_idle
@ os_thread_priority_normal
@ os_thread_priority_above_normal
uint8_t os_timer_type_t
Type of variables holding timer types.
void(* os_timer_func_t)(os_timer_func_args_t args)
Type of timer function.
void * os_timer_func_args_t
Type of timer function arguments.
const char * os_timer_get_name(os_timer_t *timer)
Get the timer name.
os_result_t os_timer_stop(os_timer_t *timer)
Stop the timer.
void os_timer_destruct(os_timer_t *timer)
Destruct the statically allocated timer object instance.
uint8_t os_timer_state_t
Type of variables holding timer states.
void os_timer_attr_init(os_timer_attr_t *attr)
Initialise the single shot timer attributes.
os_timer_t * os_timer_new(const char *name, os_timer_func_t function, os_timer_func_args_t args, const os_timer_attr_t *attr)
Allocate a timer object instance and construct it.
os_result_t os_timer_start(os_timer_t *timer, os_clock_duration_t period)
Start or restart the timer.
void os_timer_attr_periodic_init(os_timer_attr_t *attr)
Initialise the periodic timer attributes.
void os_timer_construct(os_timer_t *timer, const char *name, os_timer_func_t function, os_timer_func_args_t args, const os_timer_attr_t *attr)
Construct a statically allocated timer object instance.
void os_timer_delete(os_timer_t *timer)
Destruct the timer object instance and deallocate it.
const os_timer_attr_t * os_timer_attr_get_periodic(void)
Get a periodic timer attributes object instance.
port::clock::duration_t duration_t
Type of variables holding clock durations.
clock_highres hrclock
The high resolution clock object instance.
clock_rtc rtclock
The real time clock object instance.
port::clock::timestamp_t timestamp_t
Type of variables holding clock time stamps.
clock_systick sysclock
The system clock object instance.
port::clock::offset_t offset_t
Type of variables holding clock offsets.
static const attributes initializer
Default condition variable initialiser.
class thread::stack * stack(void)
Get the interrupts stack.
static const attributes initializer
Default event flags initialiser.
uint16_t size_t
Type of memory pool size storage.
static const attributes initializer
Default memory pool initialiser.
memory_resource * get_default_resource(void) noexcept
Get the default RTOS system memory manager.
uint8_t priority_t
Type of message priority storage.
message_queue::size_t index_t
Type of list index storage.
static const attributes initializer
Default message queue initialiser.
uint8_t size_t
Type of a queue size storage.
uint16_t msg_size_t
Type of message size storage.
uint8_t type_t
Type of variables holding mutex behaviours.
uint16_t count_t
Type of variables holding mutex recursion counters.
static const attributes_recursive initializer_recursive
Default recursive mutex initialiser.
uint8_t protocol_t
Type of variables holding mutex protocols.
uint8_t robustness_t
Type of variables holding mutex robustness.
static const attributes initializer_normal
Default normal mutex initialiser.
static const attributes_binary initializer_binary
Default binary semaphore initialiser.
int16_t count_t
Type of semaphore counter storage.
uint8_t priority_t
Type of variables holding thread priorities.
void * func_args_t
Timer call back function arguments.
void(*)(func_args_t args) func_t
Entry point of a timer call back function.
uint8_t type_t
Type of of variables holding timer run types.
uint8_t state_t
Type of of variables holding timer states.
static const attributes_periodic periodic_initializer
Default periodic timer initialiser.
@ all
Return when all flags are set.
@ clear
Ask for flags to be cleared after read.
@ any
Return when at least one flag is set.
uint32_t mode_t
Type of variables holding flags modes.
uint32_t mask_t
Type of variables holding flags masks.
port::interrupts::state_t state_t
Type of variables holding interrupts status codes.
bool in_handler_mode(void)
Check if the CPU is in handler mode.
@ ok
Function completed; no errors or events occurred.
rtos::statistics::duration_t cpu_cycles(void)
Get the total duration of all threads.
rtos::statistics::counter_t context_switches(void)
Get the total number of context switches.
port::scheduler::state_t state_t
Type of variables holding scheduler state codes.
state_t unlock(void)
Unlock the scheduler.
void start(void)
Start the RTOS scheduler.
bool started(void)
Check if the scheduler was started.
thread::threads_list & children_threads(thread *th)
Get the children threads.
state_t lock(void)
Lock the scheduler.
result_t initialize(void)
Initialise the RTOS scheduler.
bool preemptive(void)
Check if the scheduler is in preemptive mode.
bool locked(void)
Check if the scheduler is locked.
uint64_t duration_t
Type of variables holding durations in CPU cycles.
uint64_t counter_t
Type of variables holding context switches counters.
uint32_t result_t
Type of values returned by RTOS functions.
void yield() noexcept
Yield the CPU to the next ready thread.
os_mqueue_size_t os_mqueue_index_t
uint8_t os_mutex_protocol_t
uint8_t os_mutex_robustness_t
uint16_t os_mempool_size_t
uint16_t os_mqueue_msg_size_t
osStatus osMutexRelease(osMutexId mutex_id)
Release the mutex.
osStatus osDelay(uint32_t millisec)
Time Delay.
osStatus osThreadSetPriority(osThreadId thread_id, osPriority priority)
Change thread priority.
osTimerId osTimerCreate(const osTimerDef_t *timer_def, os_timer_type type, void *args)
Create a timer.
osStatus osTimerStart(osTimerId timer_id, uint32_t millisec)
Start the timer.
osEvent osSignalWait(int32_t signals, uint32_t millisec)
Wait for one or more Signal Flags to become signaled for the current RUNNING thread.
int32_t osKernelRunning(void)
Check if the RTOS scheduler is started.
int32_t osSignalSet(osThreadId thread_id, int32_t signals)
Set signal flags.
osPriority osThreadGetPriority(osThreadId thread_id)
Get thread priority.
osStatus osKernelInitialize(void)
Initialize the RTOS.
osStatus osTimerStop(osTimerId timer_id)
Stop the timer.
osMutexId osMutexCreate(const osMutexDef_t *mutex_def)
Create a mutex.
osStatus osMutexWait(osMutexId mutex_id, uint32_t millisec)
Wait for mutex.
osStatus osTimerDelete(osTimerId timer_id)
Delete the timer.
int32_t osSignalClear(osThreadId thread_id, int32_t signals)
Clear the specified Signal Flags of an active thread.
osThreadId osThreadCreate(const osThreadDef_t *thread_def, void *args)
Create a thread.
osStatus osKernelStart(void)
osThreadId osThreadGetId(void)
Get the current thread.
osStatus osMutexDelete(osMutexId mutex_id)
Delete the mutex.
osStatus osThreadTerminate(osThreadId thread_id)
Terminate a thread.
osStatus osThreadYield(void)
Yield control.
Single file µOS++ RTOS definitions.
Event structure contains detailed information about an event.
@ none
Priority and scheduling not affected by mutex ownership.
@ inherit
Inherit priority from highest priority thread.
@ protect
Execute at the highest priority.
@ stalled
Normal robustness.
@ robust
Enhanced robustness at thread termination.
@ normal
Normal mutex behaviour.
@ errorcheck
Check mutex behaviour.
@ recursive
Recursive mutex behaviour.
@ running
Has the CPU and runs.
@ destroyed
Terminated and resources (like stack) released.
@ initializing
Used to check reused threads.
@ terminated
No longer usable, but resources not yet released.
@ ready
Present in the READY list and competing for CPU.
@ undefined
Used to catch uninitialised threads.
@ suspended
Not present in the READY list, waiting for an event.
@ periodic
Run periodically.
Condition variable attributes.
Condition variable object storage.
Event flags object storage.
Definition structure for mail queue.
Memory resource object storage.
Memory pool object storage.
Definition structure for message queue.
Message queue attributes.
Message queue object storage.
Mutex definition structure contains setup information for a mutex.
Definition structure for memory block allocation.
Semaphore definition structure contains setup information for a semaphore.
Semaphore object storage.
Thread definition structure contains startup information of a thread.
Timer definition structure contains timer parameters.