18#if defined(OS_USE_OS_APP_CONFIG_H)
19#include <cmsis-plus/os-app-config.h>
28#pragma clang diagnostic ignored "-Wc++98-compat"
29#elif defined(__GNUC__)
30#pragma GCC diagnostic ignored "-Wuseless-cast"
130#pragma GCC diagnostic push
131#if defined(__clang__)
132#pragma clang diagnostic ignored "-Wanon-enum-enum-conversion"
134#pragma GCC diagnostic ignored "-Wenum-compare"
135#pragma GCC diagnostic ignored "-Wsign-compare"
174#pragma GCC diagnostic pop
181#pragma GCC diagnostic push
182#if defined(__clang__)
183#elif defined(__GNUC__)
184#pragma GCC diagnostic ignored "-Winvalid-offsetof"
232#if defined(OS_INCLUDE_RTOS_STATISTICS_THREAD_CONTEXT_SWITCHES) \
233 || defined(OS_INCLUDE_RTOS_STATISTICS_THREAD_CPU_CYCLES)
239#pragma GCC diagnostic pop
241#pragma GCC diagnostic push
242#if defined(__clang__)
243#pragma clang diagnostic ignored "-Wold-style-cast"
244#elif defined(__GNUC__)
245#pragma GCC diagnostic ignored "-Wold-style-cast"
358#if defined(OS_INCLUDE_RTOS_STATISTICS_THREAD_CONTEXT_SWITCHES)
374#if defined(OS_INCLUDE_RTOS_STATISTICS_THREAD_CPU_CYCLES)
456#if defined(OS_HAS_INTERRUPTS_STACK) || defined(__DOXYGEN__)
496 return this_thread::suspend ();
508 this_thread::exit (exit_ptr);
521 return (
os_result_t) this_thread::flags_wait (mask, oflags, mode);
534 return (
os_result_t) this_thread::flags_try_wait (mask, oflags, mode);
548 return (
os_result_t) this_thread::flags_timed_wait (mask, timeout, oflags,
561 return (
os_result_t) this_thread::flags_clear (mask, oflags);
587 assert (attr !=
nullptr);
604 assert (
thread !=
nullptr);
625 assert (
thread !=
nullptr);
671 assert (
thread !=
nullptr);
684 assert (
thread !=
nullptr);
698 assert (
thread !=
nullptr);
711 assert (
thread !=
nullptr);
724 assert (
thread !=
nullptr);
738 assert (
thread !=
nullptr);
751 assert (
thread !=
nullptr);
764 assert (
thread !=
nullptr);
778 assert (
thread !=
nullptr);
792 assert (
thread !=
nullptr);
796#if defined(OS_INCLUDE_RTOS_CUSTOM_THREAD_USER_STORAGE) || defined(__DOXYGEN__)
808os_thread_user_storage_t*
811 assert(
thread !=
nullptr);
826 assert (
thread !=
nullptr);
889 assert (stack !=
nullptr);
902 assert (stack !=
nullptr);
915 assert (stack !=
nullptr);
928 assert (stack !=
nullptr);
941 assert (stack !=
nullptr);
954 assert (stack !=
nullptr);
960#if defined(OS_INCLUDE_RTOS_STATISTICS_THREAD_CONTEXT_SWITCHES)
971 assert (
thread !=
nullptr);
977#if defined(OS_INCLUDE_RTOS_STATISTICS_THREAD_CPU_CYCLES)
988 assert (
thread !=
nullptr);
1007#pragma GCC diagnostic push
1008#if defined(__clang__)
1009#elif defined(__GNUC__)
1010#pragma GCC diagnostic ignored "-Waggregate-return"
1014#pragma GCC diagnostic pop
1031#pragma GCC diagnostic push
1032#if defined(__clang__)
1033#elif defined(__GNUC__)
1034#pragma GCC diagnostic ignored "-Waggregate-return"
1038#pragma GCC diagnostic pop
1052 thread::threads_list::iterator it
1067 thread::threads_list::iterator it
1071 return reinterpret_cast<os_iterator_t> (it.get_iterator_pointer ());
1085 assert (
clock !=
nullptr);
1098 assert (
clock !=
nullptr);
1111 assert (
clock !=
nullptr);
1124 assert (
clock !=
nullptr);
1138 assert (
clock !=
nullptr);
1152 assert (
clock !=
nullptr);
1166 assert (
clock !=
nullptr);
1180 assert (
clock !=
nullptr);
1181 assert (
clock !=
nullptr);
1284 assert (attr !=
nullptr);
1297 assert (attr !=
nullptr);
1326 assert (
timer !=
nullptr);
1327 if (attr ==
nullptr)
1347 assert (
timer !=
nullptr);
1368 if (attr ==
nullptr)
1393 assert (
timer !=
nullptr);
1406 assert (
timer !=
nullptr);
1419 assert (
timer !=
nullptr);
1432 assert (
timer !=
nullptr);
1447 assert (attr !=
nullptr);
1460 assert (attr !=
nullptr);
1488 assert (
mutex !=
nullptr);
1489 if (attr ==
nullptr)
1508 assert (
mutex !=
nullptr);
1509 if (attr ==
nullptr)
1528 assert (
mutex !=
nullptr);
1548 if (attr ==
nullptr)
1572 if (attr ==
nullptr)
1597 assert (
mutex !=
nullptr);
1610 assert (
mutex !=
nullptr);
1623 assert (
mutex !=
nullptr);
1636 assert (
mutex !=
nullptr);
1649 assert (
mutex !=
nullptr);
1663 assert (
mutex !=
nullptr);
1676 assert (
mutex !=
nullptr);
1690 assert (
mutex !=
nullptr);
1692 prio_ceiling, old_prio_ceiling);
1704 assert (
mutex !=
nullptr);
1717 assert (
mutex !=
nullptr);
1730 assert (
mutex !=
nullptr);
1743 assert (
mutex !=
nullptr);
1756 assert (
mutex !=
nullptr);
1769 assert (
mutex !=
nullptr);
1784 assert (attr !=
nullptr);
1800 assert (condvar !=
nullptr);
1801 if (attr ==
nullptr)
1820 assert (condvar !=
nullptr);
1840 if (attr ==
nullptr)
1864 assert (condvar !=
nullptr);
1877 assert (condvar !=
nullptr);
1890 assert (condvar !=
nullptr);
1903 assert (condvar !=
nullptr);
1916 assert (condvar !=
nullptr);
1931 assert (condvar !=
nullptr);
1947 assert (attr !=
nullptr);
1962 assert (attr !=
nullptr);
1978 assert (attr !=
nullptr);
1980 { max_value, initial_value };
2008 if (attr ==
nullptr)
2030 { name, initial_value };
2048 { name, max_value, initial_value };
2083 if (attr ==
nullptr)
2109 { name, initial_value });
2131 { name, max_value, initial_value });
2284 assert (attr !=
nullptr);
2300 assert (mempool !=
nullptr);
2301 if (attr ==
nullptr)
2305 new (mempool)
memory_pool (name, blocks, block_size_bytes,
2320 assert (mempool !=
nullptr);
2341 if (attr ==
nullptr)
2365 assert (mempool !=
nullptr);
2378 assert (mempool !=
nullptr);
2379 return (
reinterpret_cast<memory_pool&
> (*mempool)).name ();
2391 assert (mempool !=
nullptr);
2392 return (
reinterpret_cast<memory_pool&
> (*mempool)).alloc ();
2404 assert (mempool !=
nullptr);
2405 return (
reinterpret_cast<memory_pool&
> (*mempool)).try_alloc ();
2417 assert (mempool !=
nullptr);
2418 return (
reinterpret_cast<memory_pool&
> (*mempool)).timed_alloc (timeout);
2430 assert (mempool !=
nullptr);
2443 assert (mempool !=
nullptr);
2444 return (
reinterpret_cast<memory_pool&
> (*mempool)).capacity ();
2456 assert (mempool !=
nullptr);
2457 return (
reinterpret_cast<memory_pool&
> (*mempool)).count ();
2469 assert (mempool !=
nullptr);
2470 return (
reinterpret_cast<memory_pool&
> (*mempool)).block_size ();
2482 assert (mempool !=
nullptr);
2483 return (
reinterpret_cast<memory_pool&
> (*mempool)).empty ();
2495 assert (mempool !=
nullptr);
2496 return (
reinterpret_cast<memory_pool&
> (*mempool)).full ();
2508 assert (mempool !=
nullptr);
2521 assert (mempool !=
nullptr);
2522 return (
void*) (
reinterpret_cast<memory_pool&
> (*mempool)).pool ();
2536 assert (attr !=
nullptr);
2552 assert (mqueue !=
nullptr);
2553 if (attr ==
nullptr)
2572 assert (mqueue !=
nullptr);
2593 if (attr ==
nullptr)
2617 assert (mqueue !=
nullptr);
2630 assert (mqueue !=
nullptr);
2631 return (
reinterpret_cast<message_queue&
> (*mqueue)).name ();
2644 assert (mqueue !=
nullptr);
2646 msg, nbytes, mprio);
2659 assert (mqueue !=
nullptr);
2661 msg, nbytes, mprio);
2674 assert (mqueue !=
nullptr);
2676 msg, nbytes, timeout, mprio);
2689 assert (mqueue !=
nullptr);
2691 msg, nbytes, mprio);
2704 assert (mqueue !=
nullptr);
2706 msg, nbytes, mprio);
2719 assert (mqueue !=
nullptr);
2721 msg, nbytes, timeout, mprio);
2733 assert (mqueue !=
nullptr);
2734 return (
reinterpret_cast<message_queue&
> (*mqueue)).length ();
2746 assert (mqueue !=
nullptr);
2747 return (
reinterpret_cast<message_queue&
> (*mqueue)).capacity ();
2759 assert (mqueue !=
nullptr);
2760 return (
reinterpret_cast<message_queue&
> (*mqueue)).msg_size ();
2772 assert (mqueue !=
nullptr);
2773 return (
reinterpret_cast<message_queue&
> (*mqueue)).empty ();
2785 assert (mqueue !=
nullptr);
2786 return (
reinterpret_cast<message_queue&
> (*mqueue)).full ();
2798 assert (mqueue !=
nullptr);
2813 assert (attr !=
nullptr);
2829 assert (evflags !=
nullptr);
2830 if (attr ==
nullptr)
2848 assert (evflags !=
nullptr);
2868 if (attr ==
nullptr)
2892 assert (evflags !=
nullptr);
2905 assert (evflags !=
nullptr);
2906 return (
reinterpret_cast<event_flags&
> (*evflags)).name ();
2919 assert (evflags !=
nullptr);
2935 assert (evflags !=
nullptr);
2937 mask, oflags, mode);
2951 assert (evflags !=
nullptr);
2953 mask, timeout, oflags, mode);
2966 assert (evflags !=
nullptr);
2981 assert (evflags !=
nullptr);
2996 assert (evflags !=
nullptr);
3010 assert (evflags !=
nullptr);
3011 return (
reinterpret_cast<event_flags&
> (*evflags)).waiting ();
3038 assert (memory !=
nullptr);
3039#pragma GCC diagnostic push
3040#pragma GCC diagnostic ignored "-Wcast-align"
3043#pragma GCC diagnostic pop
3057 assert (memory !=
nullptr);
3058#pragma GCC diagnostic push
3059#pragma GCC diagnostic ignored "-Wcast-align"
3061 addr, bytes, alignment);
3062#pragma GCC diagnostic pop
3075 assert (memory !=
nullptr);
3076#pragma GCC diagnostic push
3077#pragma GCC diagnostic ignored "-Wcast-align"
3079#pragma GCC diagnostic pop
3092 assert (memory !=
nullptr);
3093#pragma GCC diagnostic push
3094#pragma GCC diagnostic ignored "-Wcast-align"
3096#pragma GCC diagnostic pop
3109 assert (memory !=
nullptr);
3110#pragma GCC diagnostic push
3111#pragma GCC diagnostic ignored "-Wcast-align"
3113#pragma GCC diagnostic pop
3126 assert (memory !=
nullptr);
3127#pragma GCC diagnostic push
3128#pragma GCC diagnostic ignored "-Wcast-align"
3130#pragma GCC diagnostic pop
3143 assert (memory !=
nullptr);
3144#pragma GCC diagnostic push
3145#pragma GCC diagnostic ignored "-Wcast-align"
3147#pragma GCC diagnostic pop
3160 assert (memory !=
nullptr);
3161#pragma GCC diagnostic push
3162#pragma GCC diagnostic ignored "-Wcast-align"
3164#pragma GCC diagnostic pop
3177 assert (memory !=
nullptr);
3178#pragma GCC diagnostic push
3179#pragma GCC diagnostic ignored "-Wcast-align"
3181#pragma GCC diagnostic pop
3257#if (defined (osFeature_SysTick) && (osFeature_SysTick != 0))
3276 return static_cast<uint32_t
> (
hrclock.
now ());
3306 if (thread_def ==
nullptr)
3322 for (uint32_t i = 0; i < thread_def->
instances; ++i)
3331 * ((thread_def->
stacksize +
sizeof(uint64_t) - 1)
3332 /
sizeof(uint64_t))];
3334#pragma GCC diagnostic push
3335#if defined(__clang__)
3336#pragma clang diagnostic ignored "-Wcast-function-type"
3337#elif defined(__GNUC__)
3338#pragma GCC diagnostic ignored "-Wcast-function-type"
3342#pragma GCC diagnostic pop
3365 return reinterpret_cast<osThreadId> (&this_thread::thread ());
3387 if (thread_id ==
nullptr)
3393 (
reinterpret_cast<rtos::thread&
> (*thread_id)).state ();
3399 if ((
reinterpret_cast<thread*
> (thread_id)) == &this_thread::thread ())
3401 this_thread::exit ();
3449 if (thread_id ==
nullptr)
3455 (
reinterpret_cast<rtos::thread&
> (*thread_id)).state ();
3469 ((
reinterpret_cast<rtos::thread&
> (*thread_id)).priority (prio));
3478 else if (res == EINVAL)
3503 if (thread_id ==
nullptr)
3510 (
reinterpret_cast<rtos::thread&
> (*thread_id)).priority ();
3541 if (res == ETIMEDOUT)
3551#if (defined (osFeature_Wait) && (osFeature_Wait != 0))
3553#pragma GCC diagnostic push
3554#if defined(__clang__)
3555#elif defined(__GNUC__)
3556#pragma GCC diagnostic ignored "-Waggregate-return"
3577osWait (uint32_t millisec)
3591 if (res == ETIMEDOUT)
3603#pragma GCC diagnostic pop
3626 if (timer_def ==
nullptr)
3655 if (timer_id ==
nullptr)
3684 if (timer_id ==
nullptr)
3694 else if (res == EAGAIN)
3718 if (timer_id ==
nullptr)
3739 if (thread_id ==
nullptr)
3741 return (int32_t) 0x80000000;
3744 if (signals == (int32_t) 0x80000000)
3746 return (int32_t) 0x80000000;
3751 return (int32_t) osig;
3763 if (thread_id ==
nullptr)
3765 return (int32_t) 0x80000000;
3770 return (int32_t) 0x80000000;
3775#if defined(OS_INCLUDE_RTOS_THREAD_PUBLIC_FLAGS_CLEAR)
3778 assert(((
thread* ) (thread_id)) == &this_thread::thread ());
3782 return (int32_t) sig;
3785#pragma GCC diagnostic push
3786#if defined(__clang__)
3787#elif defined(__GNUC__)
3788#pragma GCC diagnostic ignored "-Waggregate-return"
3824 if ((uint32_t) signals & 0x80000000)
3836 else if (millisec == 0)
3843 res = this_thread::flags_timed_wait (
3853 else if (res == EWOULDBLOCK)
3855 event.status =
osOK;
3857 else if (res == ETIMEDOUT)
3861 else if (res == EPERM)
3865 else if (res == EINVAL)
3877#pragma GCC diagnostic pop
3897 if (mutex_def ==
nullptr)
3906 new ((
void*) mutex_def->
data)
mutex (mutex_def->
name, attr);
3937 if (mutex_id ==
nullptr)
3945 ret = (
reinterpret_cast<rtos::mutex&
> (*mutex_id)).lock ();
3948 else if (millisec == 0)
3950 ret = (
reinterpret_cast<rtos::mutex&
> (*mutex_id)).try_lock ();
3954 ret = (
reinterpret_cast<rtos::mutex&
> (*mutex_id)).timed_lock (
3964 else if (ret == EWOULDBLOCK)
3970 else if (ret == ENOTRECOVERABLE)
3976 else if (ret == ETIMEDOUT)
4006 if (mutex_id ==
nullptr)
4012 res = (
reinterpret_cast<rtos::mutex&
> (*mutex_id)).unlock ();
4018 else if ((res == EPERM) || (res == ENOTRECOVERABLE))
4045 if (mutex_id ==
nullptr)
4058#if (defined (osFeature_Semaphore) && (osFeature_Semaphore != 0))
4077 if (semaphore_def ==
nullptr)
4126 if (semaphore_id ==
nullptr)
4136 else if (millisec == 0)
4138 res = (
reinterpret_cast<rtos::semaphore&
> (*semaphore_id)).try_wait ();
4139 if (res == EWOULDBLOCK)
4146 res = (
reinterpret_cast<rtos::semaphore&
> (*semaphore_id)).timed_wait (
4148 if (res == ETIMEDOUT)
4157 (int32_t) (
reinterpret_cast<rtos::semaphore&
> (*semaphore_id)).value ();
4176 if (semaphore_id ==
nullptr)
4181 if ((
reinterpret_cast<rtos::semaphore&
> (*semaphore_id)).initial_value ()
4193 else if (res == EAGAIN)
4220 if (semaphore_id ==
nullptr)
4234#if (defined (osFeature_Pool) && (osFeature_Pool != 0))
4250 if (pool_def ==
nullptr)
4260 (std::size_t) pool_def->
items,
4261 (std::size_t) pool_def->
item_sz,
4276 if (pool_id ==
nullptr)
4281 return (
reinterpret_cast<memory_pool&
> (*pool_id)).try_alloc ();
4293 if (pool_id ==
nullptr)
4299 ret = (
reinterpret_cast<memory_pool&
> (*pool_id)).try_alloc ();
4303 (
reinterpret_cast<memory_pool&
> (*pool_id)).block_size ());
4318 if (pool_id ==
nullptr)
4323 if (block ==
nullptr)
4335 else if (res == EINVAL)
4350#if (defined (osFeature_MessageQ) && (osFeature_MessageQ != 0))
4360 osThreadId thread_id __attribute__((unused)))
4367 if (queue_def ==
nullptr)
4377 (std::size_t) queue_def->
items,
4378 (std::size_t) queue_def->
item_sz,
4403#pragma GCC diagnostic push
4404#if defined ( __clang__ )
4405#pragma clang diagnostic ignored "-Wint-to-pointer-cast"
4408 if (queue_id ==
nullptr)
4421 (
const char*) &info,
sizeof(uint32_t), 0);
4424 else if (millisec == 0)
4426 res = (
reinterpret_cast<message_queue&
> (*queue_id)).try_send (
4427 (
const char*) &info,
sizeof(uint32_t), 0);
4436 res = (
reinterpret_cast<message_queue&
> (*queue_id)).timed_send (
4437 (
const char*) &info,
sizeof(uint32_t),
4447 else if (res == EWOULDBLOCK)
4452 else if (res == ETIMEDOUT)
4457 else if (res == EINVAL || res == EMSGSIZE)
4467#pragma GCC diagnostic pop
4470#pragma GCC diagnostic push
4471#if defined(__clang__)
4472#elif defined(__GNUC__)
4473#pragma GCC diagnostic ignored "-Waggregate-return"
4500 if (queue_id ==
nullptr)
4513 res = (
reinterpret_cast<message_queue&
> (*queue_id)).receive (
4514 (
char*) &
event.value.v,
sizeof(uint32_t),
nullptr);
4517 else if (millisec == 0)
4519 res = (
reinterpret_cast<message_queue&
> (*queue_id)).try_receive (
4520 (
char*) &
event.value.v,
sizeof(uint32_t),
nullptr);
4531 res = (
reinterpret_cast<message_queue&
> (*queue_id)).timed_receive (
4532 (
char*) &
event.value.v,
sizeof(uint32_t),
4543 else if (res == ETIMEDOUT)
4548 else if (res == EINVAL || res == EMSGSIZE)
4553 else if (res == EWOULDBLOCK)
4556 event.status =
osOK;
4566#pragma GCC diagnostic pop
4573#if (defined (osFeature_MailQ) && (osFeature_MailQ != 0))
4583 osThreadId thread_id __attribute__((unused)))
4590 if (mail_def ==
nullptr)
4599 mail_def->
name, (std::size_t) mail_def->
items,
4606 mail_def->
name, (std::size_t) mail_def->
items,
4638 if (mail_id ==
nullptr)
4643 void* ret =
nullptr;
4645#pragma GCC diagnostic push
4646#if defined(__clang__)
4647#elif defined(__GNUC__)
4648#pragma GCC diagnostic ignored "-Wstrict-aliasing"
4658 else if (millisec == 0)
4671#pragma GCC diagnostic pop
4704#pragma GCC diagnostic push
4705#if defined(__clang__)
4706#elif defined(__GNUC__)
4707#pragma GCC diagnostic ignored "-Wstrict-aliasing"
4711#pragma GCC diagnostic pop
4726 if (mail_id ==
nullptr)
4730 if (mail ==
nullptr)
4737 if (((
char*) mail < (
char*) (pool->
pool ()))
4745#pragma GCC diagnostic push
4746#if defined(__clang__)
4747#elif defined(__GNUC__)
4748#pragma GCC diagnostic ignored "-Wstrict-aliasing"
4751 (
const char*) &mail,
sizeof(
void*), 0);
4752#pragma GCC diagnostic pop
4763#pragma GCC diagnostic push
4764#if defined(__clang__)
4765#elif defined(__GNUC__)
4766#pragma GCC diagnostic ignored "-Waggregate-return"
4768#pragma GCC diagnostic ignored "-Wstrict-aliasing"
4794 if (mail_id ==
nullptr)
4808 (
char*) &
event.value.p,
sizeof(
void*),
nullptr);
4811 else if (millisec == 0)
4814 (
char*) &
event.value.p,
sizeof(
void*),
nullptr);
4825 (
char*) &
event.value.p,
sizeof(
void*),
4835 else if (res == EWOULDBLOCK)
4838 event.status =
osOK;
4840 else if (res == EINVAL || res == EMSGSIZE)
4845 else if (res == ETIMEDOUT)
4858#pragma GCC diagnostic pop
4869 if (mail_id ==
nullptr)
4873 if (mail ==
nullptr)
4885#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.
void *(*)(func_args_t args) func_t
Type of thread function.
result_t join(void **exit_ptr=nullptr)
Wait for thread termination.
_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
maximum count for osSemaphoreCreate function
void * osMailAlloc(osMailQId mail_id, uint32_t millisec)
Allocate a memory block from a mail.
@ osPriorityError
system cannot determine priority or thread has illegal priority
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.
@ osEventMail
function completed; mail event occurred.
@ osErrorISR
not allowed in ISR context: the function cannot be called from interrupt service routines.
@ osErrorTimeoutResource
resource not available within given time: a specified resource was not available within the timeout p...
@ osErrorValue
value of a parameter is out of range.
@ osEventSignal
function completed; signal event occurred.
@ osErrorOS
unspecified RTOS error: run-time error but no other error message fits.
@ osEventTimeout
function completed; timeout occurred.
@ osErrorResource
resource not available: a specified resource was not available.
@ osOK
function completed; no error or event occurred.
@ osErrorParameter
parameter error: a mandatory parameter was missing or specified an incorrect object.
@ osEventMessage
function completed; message event occurred.
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 statu 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.
osStatus status
status code: event or error information
int32_t signals
signal flags
union osEvent::@0 value
event value
@ 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.
uint32_t items
number of elements in the queue
void * queue
pointer to memory array for queue
uint32_t queue_item_sz
size of a queue item
uint32_t pool_item_sz
size of a pool item
void * pool
pointer to memory array for pool
Memory resource object storage.
Memory pool object storage.
Definition structure for message queue.
void * queue
pointer to memory array for messages
uint32_t items
number of elements in the queue
uint32_t item_sz
size of an item
Message queue attributes.
Message queue object storage.
Mutex definition structure contains setup information for a mutex.
Definition structure for memory block allocation.
uint32_t item_sz
size of an item
void * pool
pointer to memory for pool
uint32_t items
number of items (elements) in the pool
Semaphore definition structure contains setup information for a semaphore.
Semaphore object storage.
Thread definition structure contains startup information of a thread.
os_pthread pthread
start address of thread function
osPriority tpriority
initial thread priority
uint32_t stacksize
stack size requirements in bytes; 0 is default stack size
uint32_t instances
maximum number of instances of that thread function
Timer definition structure contains timer parameters.
os_ptimer ptimer
start address of a timer function