|
SuperTinyKernel™ RTOS 1.08.x
Lightweight, high-performance, deterministic, bare-metal C++ RTOS for resource-constrained embedded systems. MIT Open Source License.
|
C language binding/interface for SuperTinyKernel RTOS. More...
#include <cstdint>#include <cstddef>#include <cstdbool>#include <cassert>#include <stk_config.h>Go to the source code of this file.
Classes | |
| struct | stk_version_info_t |
| Version information descriptor. More... | |
| struct | stk_event_overrider_t |
C-level callback table that mirrors stk::IPlatform::IEventOverrider. More... | |
| struct | stk_hires_clock_mem_t |
| Opaque memory container for a HiResClock instance. More... | |
| struct | stk_mutex_mem_t |
| Opaque memory container for a Mutex instance. More... | |
| struct | stk_fastmutex_mem_t |
| Opaque memory container for a FastMutex instance. More... | |
| struct | stk_spinlock_mem_t |
| Opaque memory container for SpinLock object. More... | |
| struct | stk_cv_mem_t |
| Opaque memory container for a ConditionVariable instance. More... | |
| struct | stk_event_mem_t |
| Opaque memory container for an Event instance. More... | |
| struct | stk_sem_mem_t |
| Opaque memory container for a Semaphore instance. More... | |
| struct | stk_ef_mem_t |
| Opaque memory container for an EventFlags instance. More... | |
| struct | stk_ef_sync_ctx_mem_t |
| Opaque memory container for a rendezvous context. More... | |
| struct | stk_pipe_mem_t |
| Opaque memory container for a Pipe control-block. More... | |
| struct | stk_msgq_mem_t |
| Opaque memory container for a MessageQueue instance. More... | |
| struct | stk_rwmutex_mem_t |
| Opaque memory container for an RWMutex instance. More... | |
| struct | stk_barrier_mem_t |
| Opaque memory container for a Barrier instance. More... | |
Namespaces | |
| namespace | stk |
| Namespace of STK package. | |
| namespace | stk::hw |
| Hardware Abstraction Layer (HAL) for architecture-specific operations. | |
| namespace | stk::sync |
| Synchronization primitives for task coordination and resource protection. | |
Macros | |
| #define | STK_C_VERSION 0x20261028 |
| Interface version. | |
| #define | STK_C_KERNEL_MAX_TASKS (4) |
| Maximum number of tasks per kernel instance (default: 4). | |
| #define | STK_C_CPU_COUNT (1) |
| Number of kernel instances / CPU cores supported (default: 1). | |
| #define | STK_SYNC_DEBUG_NAMES (0) |
| Enable names for synchronization primitives for debugging/tracing purpose. | |
| #define | STK_C_ASSERT(e) |
| Assertion macro used inside STK C bindings. | |
| #define | STK_STATIC_CAST(type, val) |
| Convenience wrapper for static_cast and C-style cast. | |
| #define | STK_MIN(a, b) |
| Returns the minimum of two values. | |
| #define | STK_MAX(a, b) |
| Returns the maximum of two values. | |
| #define | STK_C_CEIL_DIV(size, unit) |
| Performs integer ceiling division (rounds up to the nearest multiple). | |
| #define | STK_ROUND_UP(x, a) |
| Rounds up a value to the nearest multiple of another value. | |
| #define | STK_PERIODICITY_DEFAULT (1000U) |
| Default tick period (1 ms). | |
| #define | STK_WAIT_INFINITE (STK_STATIC_CAST(stk_timeout_t, INT32_MAX)) |
| Infinite timeout constant. | |
| #define | STK_NO_WAIT (STK_STATIC_CAST(stk_timeout_t, 0)) |
| No timeout constant. | |
| #define | STK_ALIGN_SIZE sizeof(stk_word_t) |
| Memory buffer alignment. | |
| #define | STK_ALIGN_MASK (STK_ALIGN_SIZE - 1U) |
| Alignment mask. | |
| #define | STK_STACK_MEMORY_ALIGN (4U) |
| Stack memory alignment. | |
| #define | STK_DEFINE_STACK_POOL(name, max_tasks, stack_size) |
| Allocates a statically bound, multi-dimensional stack pool for tasks. | |
| #define | STK_GET_STACK_FROM_POOL(name, task_id) |
| Retrieves the base stack pointer for a specific task ID from a stack pool. | |
| #define | STK_CALC_ALIGNED_BLOCKS(base, val_size, count) |
| Calculates aligned block counts using nested rounding and ceiling division. | |
| #define | __stk_c_align(x) |
| Align to x bytes. | |
| #define | __stk_c_stack |
| Stack attribute (applies required alignment for a stack memory). | |
| #define | __stk_c_aligned |
| Memory buffer alignment attribute. | |
| #define | STK_HIRES_CLOCK_IMPL_SIZE |
| A memory size (multiples of stk_word_t) required for HiResClock instance. | |
| #define | STK_TLS_GET_T(type) |
| Typed helper for getting TLS value. | |
| #define | STK_TLS_SET_T(ptr) |
| Typed helper for setting TLS value. | |
| #define | STK_DEFAULT_CS_SESSION (0U) |
| Default session value for stk_critical_section_enter_ex()/stk_critical_section_exit_ex(), letting the call auto-detect the calling context's privilege level. | |
| #define | STK_MUTEX_IMPL_SIZE (10U + (STK_SYNC_DEBUG_NAMES ? 1U : 0U)) |
| A memory size (multiples of stk_word_t) required for Mutex instance. | |
| #define | STK_FASTMUTEX_IMPL_SIZE (9U + (STK_SYNC_DEBUG_NAMES ? 1U : 0U)) |
| A memory size (multiples of stk_word_t) required for FastMutex instance. | |
| #define | STK_SPINLOCK_IMPL_SIZE (6) |
| A memory size (multiples of stk_word_t) required for SpinLock instance. | |
| #define | STK_CV_IMPL_SIZE (7U + (STK_SYNC_DEBUG_NAMES ? 1U : 0U)) |
| A memory size (multiples of stk_word_t) required for ConditionVariable instance. | |
| #define | STK_EVENT_IMPL_SIZE (8U + (STK_SYNC_DEBUG_NAMES ? 1U : 0U)) |
| A memory size (multiples of stk_word_t) required for Event instance. | |
| #define | STK_C_SEM_VALUE_TYPE uint16_t |
| Semaphore counter value type (unsigned integer type, default uint16_t). | |
| #define | STK_SEM_BASE_BYTES ((7U + (STK_SYNC_DEBUG_NAMES ? 1U : 0U)) * sizeof(stk_word_t)) |
| A memory size (multiples of stk_word_t) required for Semaphore instance. | |
| #define | STK_SEM_IMPL_SIZE STK_CALC_ALIGNED_BLOCKS(STK_SEM_BASE_BYTES, sizeof(stk_sem_val_t), 2U) |
| #define | STK_C_EF_VALUE_TYPE uint32_t |
| EventFlags flags word type (unsigned integer type, default uint32_t). | |
| #define | STK_EF_OPT_WAIT_ANY (0x00000000U) |
| Options bitmask constants for stk_ef_wait() / stk_ef_trywait(). | |
| #define | STK_EF_OPT_WAIT_ALL (0x00000001U) |
| #define | STK_EF_OPT_NO_CLEAR (0x00000002U) |
| #define | STK_EF_FLAGS_MAX (STK_STATIC_CAST(stk_ef_val_t, ~STK_STATIC_CAST(stk_ef_val_t, 0U))) |
| Word constants derived from stk_ef_val_t. | |
| #define | STK_EF_ERROR_MASK (STK_STATIC_CAST(stk_ef_val_t, ~STK_STATIC_CAST(stk_ef_val_t, STK_EF_FLAGS_MAX >> 1U))) |
| #define | STK_EF_FLAGS_MASK (STK_STATIC_CAST(stk_ef_val_t, ~STK_EF_ERROR_MASK)) |
| #define | STK_EF_ERROR_PARAMETER (STK_STATIC_CAST(stk_ef_val_t, STK_EF_ERROR_MASK | STK_STATIC_CAST(stk_ef_val_t, 0x01U))) |
| Return-value error sentinels (the most significant bit of stk_ef_val_t indicates an error). | |
| #define | STK_EF_ERROR_TIMEOUT (STK_STATIC_CAST(stk_ef_val_t, STK_EF_ERROR_MASK | STK_STATIC_CAST(stk_ef_val_t, 0x02U))) |
| #define | STK_EF_ERROR_ISR (STK_STATIC_CAST(stk_ef_val_t, STK_EF_ERROR_MASK | STK_STATIC_CAST(stk_ef_val_t, 0x04U))) |
| #define | STK_EF_ERROR_CANCELED (STK_STATIC_CAST(stk_ef_val_t, STK_EF_ERROR_MASK | STK_STATIC_CAST(stk_ef_val_t, 0x08U))) |
| #define | STK_EF_ERROR_FAIL (STK_STATIC_CAST(stk_ef_val_t, STK_EF_ERROR_MASK | STK_STATIC_CAST(stk_ef_val_t, 0x10U))) |
| #define | STK_EF_BASE_BYTES ((STK_SYNC_DEBUG_NAMES ? 1U : 0U) * sizeof(stk_word_t)) |
| A memory size (multiples of stk_word_t) required for EventFlags instance. | |
| #define | STK_EF_CV_OFFSET_BYTES STK_ROUND_UP(STK_ROUND_UP(STK_EF_BASE_BYTES, sizeof(stk_ef_val_t)) + sizeof(stk_ef_val_t), sizeof(stk_word_t)) |
| #define | STK_EF_IMPL_SIZE |
| #define | STK_EF_SYNC_CTX_IMPL_SIZE STK_CALC_ALIGNED_BLOCKS(sizeof(uint32_t), sizeof(stk_ef_val_t), 1U) |
| A memory size (multiples of stk_word_t) required for a rendezvous context of stk_ef_sync(). | |
| #define | STK_PIPE_IMPL_SIZE (6U + (2U * STK_CV_IMPL_SIZE) + (STK_SYNC_DEBUG_NAMES ? 1U : 0U)) |
| A memory size (multiples of stk_word_t) required for a Pipe control-block. | |
| #define | STK_PIPE_BUF_SIZE(capacity, element_size) |
| Compute the required data-buffer size (in bytes) for a Pipe. | |
| #define | STK_MSGQ_IMPL_SIZE (6U + (2U * STK_CV_IMPL_SIZE) + (STK_SYNC_DEBUG_NAMES ? 1U : 0U)) |
| A memory size (multiples of stk_word_t) required for a MessageQueue instance. | |
| #define | STK_MSGQ_BUF_SIZE(capacity, msg_size) |
| Compute the required data-buffer size (in bytes) for a MessageQueue. | |
| #define | STK_RWMUTEX_IMPL_SIZE (17U + (STK_SYNC_DEBUG_NAMES ? 3U : 0U)) |
| A memory size (multiples of stk_word_t) required for RWMutex instance. | |
| #define | STK_BARRIER_IMPL_SIZE (STK_MUTEX_IMPL_SIZE + STK_CV_IMPL_SIZE + 4U + (STK_SYNC_DEBUG_NAMES ? 1U : 0U)) |
| A memory size (multiples of stk_word_t) required for Barrier instance. | |
Typedefs | |
| typedef uintptr_t | stk_word_t |
| CPU register type. | |
| typedef stk_word_t | stk_tid_t |
| Task id. | |
| typedef int64_t | stk_tick_t |
| Ticks value. | |
| typedef int64_t | stk_time_t |
| Time value. | |
| typedef int32_t | stk_timeout_t |
| Timeout value. | |
| typedef uint64_t | stk_cycle_t |
| CPU cycles value. | |
| typedef int32_t | stk_weight_t |
| Task weight value. | |
| typedef struct stk_kernel_t | stk_kernel_t |
| Opaque handle to a kernel instance. | |
| typedef struct stk_task_t | stk_task_t |
| Opaque handle to a task instance. | |
| typedef void(* | stk_task_entry_t) (void *arg) |
| Task entry point function type. | |
| typedef enum stk_wait_result_t | stk_wait_result_t |
| Outcome of a cancellable, timed kernel wait (see stk_cv_wait_ex(), stk_mutex_timed_lock_ex(), stk_sem_wait_ex(), ...). | |
| typedef enum stk_add_result_t | stk_add_result_t |
| Result of stk_kernel_add_task() and stk_kernel_add_task_hrt(). | |
| typedef enum stk_suspend_result_t | stk_suspend_result_t |
| Result of stk_kernel_suspend_task(). | |
| typedef enum stk_resume_result_t | stk_resume_result_t |
| Result of stk_kernel_resume_task(). | |
| typedef struct stk_version_info_t | stk_version_info_t |
| Version information descriptor. | |
| typedef enum stk_kernel_state_t | stk_kernel_state_t |
| Kernel state. | |
| typedef struct stk_event_overrider_t | stk_event_overrider_t |
| typedef struct stk_hires_clock_mem_t | stk_hires_clock_mem_t |
| Opaque memory container for a HiResClock instance. | |
| typedef struct stk_hires_clock_t | stk_hires_clock_t |
| Opaque handle to a HiResClock instance (see hw::HiResClock). | |
| typedef uint8_t | stk_cs_session_t |
| Session of Critical Section. | |
| typedef struct stk_mutex_mem_t | stk_mutex_mem_t |
| Opaque memory container for a Mutex instance. | |
| typedef struct stk_mutex_t | stk_mutex_t |
| Opaque handle to a Mutex instance. | |
| typedef struct stk_fastmutex_mem_t | stk_fastmutex_mem_t |
| Opaque memory container for a FastMutex instance. | |
| typedef struct stk_fastmutex_t | stk_fastmutex_t |
| Opaque handle to a FastMutex instance. | |
| typedef struct stk_spinlock_t | stk_spinlock_t |
| Opaque handle to a SpinLock instance. | |
| typedef struct stk_cv_mem_t | stk_cv_mem_t |
| Opaque memory container for a ConditionVariable instance. | |
| typedef struct stk_cv_t | stk_cv_t |
| Opaque handle to a Condition Variable instance. | |
| typedef struct stk_event_mem_t | stk_event_mem_t |
| Opaque memory container for an Event instance. | |
| typedef struct stk_event_t | stk_event_t |
| Opaque handle to an Event instance. | |
| typedef uint16_t | stk_sem_val_t |
| typedef struct stk_sem_mem_t | stk_sem_mem_t |
| Opaque memory container for a Semaphore instance. | |
| typedef struct stk_sem_t | stk_sem_t |
| Opaque handle to a Semaphore instance. | |
| typedef uint32_t | stk_ef_val_t |
| typedef struct stk_ef_mem_t | stk_ef_mem_t |
| Opaque memory container for an EventFlags instance. | |
| typedef struct stk_ef_t | stk_ef_t |
| Opaque handle to an EventFlags instance. | |
| typedef struct stk_ef_sync_ctx_mem_t | stk_ef_sync_ctx_mem_t |
| Opaque memory container for a rendezvous context. | |
| typedef struct stk_ef_sync_ctx_t | stk_ef_sync_ctx_t |
| Opaque handle to a rendezvous context. | |
| typedef struct stk_pipe_mem_t | stk_pipe_mem_t |
| Opaque memory container for a Pipe control-block. | |
| typedef struct stk_pipe_t | stk_pipe_t |
| Opaque handle to a Pipe instance. | |
| typedef struct stk_msgq_mem_t | stk_msgq_mem_t |
| Opaque memory container for a MessageQueue instance. | |
| typedef struct stk_msgq_t | stk_msgq_t |
| Opaque handle to a MessageQueue instance. | |
| typedef struct stk_rwmutex_mem_t | stk_rwmutex_mem_t |
| Opaque memory container for an RWMutex instance. | |
| typedef struct stk_rwmutex_t | stk_rwmutex_t |
| Opaque handle to an RWMutex instance. | |
| typedef struct stk_barrier_mem_t | stk_barrier_mem_t |
| Opaque memory container for a Barrier instance. | |
| typedef struct stk_barrier_t | stk_barrier_t |
| Opaque handle to a Barrier instance. | |
| typedef enum stk_barrier_result_t | stk_barrier_result_t |
| Outcome of a stk_barrier_wait_ex() call. | |
Functions | |
| stk_version_info_t | stk_get_version (void) |
| Get version information of the STK kernel this C binding was built with. | |
| stk_kernel_t * | stk_kernel_create (uint8_t core_nr) |
| Create kernel. | |
| stk::IKernel * | stk_kernel_get_instance (uint8_t core_nr) |
Get the underlying C++ stk::IKernel object for a given core. | |
| void | stk_kernel_init (stk_kernel_t *k, uint32_t tick_period_us) |
| Initialize kernel with given tick period. | |
| stk_add_result_t | stk_kernel_add_task (stk_kernel_t *k, stk_task_t *tsk) |
| Add task to non-HRT kernel (static or dynamic). | |
| stk_add_result_t | stk_kernel_add_task_hrt (stk_kernel_t *k, stk_task_t *tsk, int32_t periodicity_ticks, int32_t deadline_ticks, int32_t start_delay_ticks) |
| Add task with HRT timing parameters (HRT kernels only). | |
| void | stk_kernel_remove_task (stk_kernel_t *k, stk_task_t *tsk) |
| Remove finished task from dynamic kernel. | |
| void | stk_kernel_start (stk_kernel_t *k) |
| Start the scheduler - never returns. | |
| stk_kernel_state_t | stk_kernel_get_state (const stk_kernel_t *k) |
| Get state of the scheduler. | |
| bool | stk_kernel_is_schedulable (const stk_kernel_t *k) |
| Test whether currently configured task set is schedulable. | |
| bool | stk_kernel_is_started (const stk_kernel_t *k) |
| Check whether the scheduler is currently running (first task switch has occurred). | |
| void | stk_kernel_schedule_task_removal (stk_kernel_t *k, stk_task_t *task) |
| Schedule removal of a running task from the kernel on the next tick. | |
| stk_suspend_result_t | stk_kernel_suspend_task (stk_kernel_t *k, stk_task_t *task) |
| Suspend a task (prevent it from being scheduled). | |
| stk_resume_result_t | stk_kernel_resume_task (stk_kernel_t *k, stk_task_t *task) |
| Resume a task suspended by stk_kernel_suspend_task(), or lift its deferred suspension. | |
| stk_timeout_t | stk_kernel_suspend (stk_kernel_t *k) |
| Suspend scheduling (tickless idle entry point). | |
| void | stk_kernel_resume (stk_kernel_t *k, stk_timeout_t elapsed_ticks) |
| Resume scheduling after a prior stk_kernel_suspend() call. | |
| size_t | stk_kernel_enumerate_tasks (stk_kernel_t *k, stk_task_t **tasks, size_t max_count) |
| Enumerate all currently active tasks. | |
| void | stk_kernel_process_tick (stk_kernel_t *k) |
| Manually deliver one scheduler tick to the kernel. | |
| void | stk_kernel_process_hard_fault (stk_kernel_t *k) |
| Trigger a kernel hard fault (safe-state handler). | |
| void | stk_kernel_set_event_overrider (stk_kernel_t *k, stk_event_overrider_t *overrider) |
| Install a platform event overrider on the kernel. | |
| stk_task_t * | stk_task_create_privileged (stk_task_entry_t entry, void *arg, stk_word_t *stack, uint32_t stack_size) |
| Create privileged-mode (kernel-mode) task. | |
| stk_task_t * | stk_task_create_user (stk_task_entry_t entry, void *arg, stk_word_t *stack, uint32_t stack_size) |
| Create user-mode task. | |
| void | stk_task_set_weight (stk_task_t *tsk, stk_weight_t weight) |
| Set task weight (used only by Smooth Weighted Round Robin). | |
| void | stk_task_set_priority (stk_task_t *tsk, uint8_t priority) |
| Set task priority (used only by Fixed Priority scheduler). | |
| void | stk_task_set_name (stk_task_t *tsk, const char *tname) |
| Assign human-readable task name (for tracing/debugging). | |
| const char * | stk_task_get_name (const stk_task_t *tsk) |
| Get human-readable task name previously set with stk_task_set_name(). | |
| stk_tid_t | stk_task_get_id (const stk_task_t *tsk) |
| Get the unique identifier of a task. | |
| stk::ITask * | stk_task_get_instance (stk_task_t *tsk) |
Get the underlying C++ stk::ITask object wrapped by a stk_task_t handle. | |
| stk_tid_t | stk_tid (void) |
| Returns current task/thread ID (the value set by stk_task_set_id). | |
| stk_tick_t | stk_ticks (void) |
| Returns number of ticks elapsed since kernel start. | |
| uint32_t | stk_tick_resolution (void) |
| Returns how many microseconds correspond to one kernel tick. | |
| stk_tick_t | stk_ticks_from_ms (stk_time_t msec) |
| Get ticks from milliseconds using current kernel tick resolution. | |
| stk_timeout_t | stk_ticks_from_ms_clamped_to_timeout (stk_timeout_t ms) |
| Get ticks from milliseconds using current kernel tick resolution, clamped to the maximum value representable by stk_timeout_t (STK_WAIT_INFINITE). | |
| static stk_tick_t | stk_ticks_from_ms_r (stk_time_t msec, uint32_t resolution) |
| Get ticks from milliseconds using an explicit tick resolution. | |
| stk_time_t | stk_time_now_ms (void) |
| Returns current time in milliseconds since kernel start. | |
| static stk_time_t | stk_ms_from_ticks_r (stk_tick_t ticks, uint32_t resolution) |
| Convert ticks to milliseconds using an explicit tick resolution. | |
| static stk_time_t | stk_ms_from_ticks (stk_tick_t ticks) |
| Convert ticks to milliseconds using the current kernel tick resolution. | |
| stk_cycle_t | stk_sys_timer_count (void) |
| Get raw system timer counter value. | |
| uint32_t | stk_sys_timer_frequency (void) |
| Get system timer frequency in Hz. | |
| stk_hires_clock_t * | stk_hires_clock_create (stk_hires_clock_mem_t *const membuf) |
| Create a HiResClock (using provided memory). | |
| void | stk_hires_clock_destroy (stk_hires_clock_t *clk) |
| Destroy a HiResClock. | |
| stk_cycle_t | stk_hires_cycles (stk_hires_clock_t *clk) |
| Get the cycle count of the clock counter (see stk_hires_clock_create() for the time origin). | |
| uint32_t | stk_hires_frequency (const stk_hires_clock_t *clk) |
| Get clock frequency in Hz. | |
| stk_tick_t | stk_hires_time_us (stk_hires_clock_t *clk) |
| Get elapsed time in microseconds (see stk_hires_clock_create() for the time origin). | |
| stk::hw::HiResClock * | stk_hires_clock_get_instance (stk_hires_clock_t *clk) |
Get the underlying C++ stk::hw::HiResClock object wrapped by a stk_hires_clock_t handle. | |
| void | stk_delay (stk_timeout_t ticks) |
| Busy-wait delay (other tasks continue to run). | |
| void | stk_delay_ms (stk_timeout_t ms) |
| Busy-wait delay (other tasks continue to run). | |
| void | stk_sleep (stk_timeout_t ticks) |
| Put current task to sleep (non-HRT kernels only). | |
| void | stk_sleep_ms (stk_timeout_t ms) |
| Put current task to sleep (non-HRT kernels only). | |
| bool | stk_sleep_until (stk_tick_t ts) |
| Put current task to sleep (non-HRT kernels only). | |
| void | stk_yield (void) |
| Voluntarily give up CPU to another ready task (cooperative yield). | |
| void | stk_exit_task (void) |
| Terminate the calling task: schedule its removal and switch it out. Does not return. | |
| void | stk_sleep_cancel (stk_tid_t tid) |
| Cancel the sleep of a task, waking it immediately. | |
| void | stk_kernel_destroy (stk_kernel_t *k) |
| Destroy dynamic kernel instance (only when not running). | |
| void | stk_task_destroy (stk_task_t *tsk) |
| Destroy dynamically created task object. | |
| void * | stk_tls_get (void) |
| Get thread-local pointer (platform-specific slot). | |
| void | stk_tls_set (void *ptr) |
| Set thread-local pointer. | |
| stk_cs_session_t | stk_critical_section_enter_ex (stk_cs_session_t ses) |
| Enter global critical section - disable context switches on current core. | |
| void | stk_critical_section_exit_ex (stk_cs_session_t ses) |
| Leave global critical section - re-enable context switches. | |
| void | stk_critical_section_enter () |
| Enter global critical section - disable context switches on current core. | |
| void | stk_critical_section_exit () |
| Leave global critical section - re-enable context switches. | |
| stk_mutex_t * | stk_mutex_create (stk_mutex_mem_t *const membuf) |
| Create a Mutex (using provided memory). | |
| void | stk_mutex_destroy (stk_mutex_t *mtx) |
| Destroy a Mutex. | |
| void | stk_mutex_lock (stk_mutex_t *mtx) |
| Lock the mutex. Blocks until available. | |
| bool | stk_mutex_trylock (stk_mutex_t *mtx) |
| Try locking the mutex. Does not block if already locked. | |
| void | stk_mutex_unlock (stk_mutex_t *mtx) |
| Unlock the mutex. | |
| bool | stk_mutex_timed_lock (stk_mutex_t *mtx, stk_timeout_t timeout) |
| Try to lock the mutex with a timeout. | |
| stk_wait_result_t | stk_mutex_timed_lock_ex (stk_mutex_t *mtx, stk_timeout_t timeout) |
| Try to lock the mutex with a timeout, preserving the full outcome. | |
| stk::sync::Mutex * | stk_mutex_get_instance (stk_mutex_t *mtx) |
Get the underlying C++ stk::sync::Mutex object wrapped by a stk_mutex_t handle. | |
| stk_fastmutex_t * | stk_fastmutex_create (stk_fastmutex_mem_t *const membuf) |
| Create a FastMutex (using provided memory). | |
| void | stk_fastmutex_destroy (stk_fastmutex_t *mtx) |
| Destroy a FastMutex. | |
| void | stk_fastmutex_lock (stk_fastmutex_t *mtx) |
| Lock the mutex. Blocks until available. | |
| bool | stk_fastmutex_trylock (stk_fastmutex_t *mtx) |
| Try locking the mutex. Does not block if already locked. | |
| void | stk_fastmutex_unlock (stk_fastmutex_t *mtx) |
| Unlock the mutex. | |
| bool | stk_fastmutex_timed_lock (stk_fastmutex_t *mtx, stk_timeout_t timeout) |
| Try to lock the mutex with a timeout. | |
| stk_wait_result_t | stk_fastmutex_timed_lock_ex (stk_fastmutex_t *mtx, stk_timeout_t timeout) |
| Try to lock the FastMutex with a timeout, preserving the full outcome. | |
| stk::sync::FastMutex * | stk_fastmutex_get_instance (stk_fastmutex_t *mtx) |
Get the underlying C++ stk::sync::FastMutex object wrapped by a stk_fastmutex_t handle. | |
| stk_spinlock_t * | stk_spinlock_create (stk_spinlock_mem_t *const membuf) |
| Create a recursive SpinLock. | |
| void | stk_spinlock_destroy (stk_spinlock_t *slock) |
| Destroy the SpinLock. | |
| void | stk_spinlock_lock (stk_spinlock_t *slock) |
| Acquire the SpinLock (recursive). | |
| bool | stk_spinlock_trylock (stk_spinlock_t *slock) |
| Attempt to acquire the SpinLock immediately. | |
| void | stk_spinlock_unlock (stk_spinlock_t *slock) |
| Release the SpinLock. | |
| stk::sync::SpinLock * | stk_spinlock_get_instance (stk_spinlock_t *slock) |
Get the underlying C++ stk::sync::SpinLock object wrapped by a stk_spinlock_t handle. | |
| stk_cv_t * | stk_cv_create (stk_cv_mem_t *const membuf) |
| Create a Condition Variable (using provided memory). | |
| void | stk_cv_destroy (stk_cv_t *cv) |
| Destroy a Condition Variable. | |
| bool | stk_cv_wait (stk_cv_t *cv, stk_mutex_t *mtx, stk_timeout_t timeout) |
| Wait for a signal on the condition variable. | |
| stk_wait_result_t | stk_cv_wait_ex (stk_cv_t *cv, stk_mutex_t *mtx, stk_timeout_t timeout) |
| Wait for a signal on the condition variable, preserving the full outcome. | |
| bool | stk_cv_wait_fastmutex (stk_cv_t *cv, stk_fastmutex_t *mtx, stk_timeout_t timeout) |
| Wait for a signal on the condition variable, protected by a FastMutex. | |
| stk_wait_result_t | stk_cv_wait_ex_fastmutex (stk_cv_t *cv, stk_fastmutex_t *mtx, stk_timeout_t timeout) |
| Wait for a signal on the condition variable protected by a FastMutex, preserving the full outcome. | |
| void | stk_cv_notify_one (stk_cv_t *cv) |
| Wake one task waiting on the condition variable. | |
| void | stk_cv_notify_all (stk_cv_t *cv) |
| Wake all tasks waiting on the condition variable. | |
| stk::sync::ConditionVariable * | stk_cv_get_instance (stk_cv_t *cv) |
Get the underlying C++ stk::sync::ConditionVariable object wrapped by a stk_cv_t handle. | |
| stk_event_t * | stk_event_create (stk_event_mem_t *const membuf, bool manual_reset) |
| Create an Event (using provided memory). | |
| void | stk_event_destroy (stk_event_t *ev) |
| Destroy an Event. | |
| bool | stk_event_wait (stk_event_t *ev, stk_timeout_t timeout) |
| Wait for the event to become signaled. | |
| stk_wait_result_t | stk_event_wait_ex (stk_event_t *ev, stk_timeout_t timeout) |
| Wait for the event to become signaled, preserving the full outcome. | |
| bool | stk_event_trywait (stk_event_t *ev) |
| Wait for the event to become signaled. | |
| bool | stk_event_set (stk_event_t *ev) |
| Set the event to signaled state. | |
| bool | stk_event_reset (stk_event_t *ev) |
| Reset the event to non-signaled state. | |
| void | stk_event_pulse (stk_event_t *ev) |
| Pulse the event (signal then immediately reset). | |
| stk::sync::Event * | stk_event_get_instance (stk_event_t *ev) |
Get the underlying C++ stk::sync::Event object wrapped by a stk_event_t handle. | |
| stk_sem_t * | stk_sem_create (stk_sem_mem_t *const membuf, stk_sem_val_t initial_count, stk_sem_val_t max_count) |
| Create a Semaphore (using provided memory). | |
| void | stk_sem_destroy (stk_sem_t *sem) |
| Destroy a Semaphore. | |
| bool | stk_sem_wait (stk_sem_t *sem, stk_timeout_t timeout) |
| Wait for a semaphore resource. | |
| stk_wait_result_t | stk_sem_wait_ex (stk_sem_t *sem, stk_timeout_t timeout) |
| Wait for a semaphore resource, preserving the full outcome. | |
| bool | stk_sem_trywait (stk_sem_t *sem) |
| Poll the semaphore without blocking. | |
| void | stk_sem_signal (stk_sem_t *sem) |
| Signal/Release a semaphore resource. | |
| bool | stk_sem_trysignal (stk_sem_t *sem) |
| Try to signal/release a semaphore resource without exceeding max_count. | |
| bool | stk_sem_trysignal_ceiling (stk_sem_t *sem, stk_sem_val_t ceiling) |
| Try to signal/release a semaphore resource without exceeding a caller-supplied ceiling. | |
| stk_sem_val_t | stk_sem_get_count (const stk_sem_t *sem) |
| Get the current counter value. | |
| stk::sync::SemaphoreT< stk_sem_val_t > * | stk_sem_get_instance (stk_sem_t *sem) |
Get the underlying C++ stk::sync::SemaphoreT<stk_sem_val_t> object wrapped by a stk_sem_t handle. | |
| static bool | stk_ef_is_error (stk_ef_val_t result) |
| Returns true if a value returned by stk_ef_set(), stk_ef_clear(), stk_ef_wait(), or stk_ef_trywait() is an error sentinel (error bit set). | |
| stk_ef_t * | stk_ef_create (stk_ef_mem_t *const membuf, stk_ef_val_t initial_flags) |
| Create an EventFlags object (using provided memory). | |
| void | stk_ef_destroy (stk_ef_t *ef) |
| Destroy an EventFlags object. | |
| stk_ef_val_t | stk_ef_set (stk_ef_t *ef, stk_ef_val_t flags) |
| Set one or more flags. | |
| stk_ef_val_t | stk_ef_clear (stk_ef_t *ef, stk_ef_val_t flags) |
| Clear one or more flags. | |
| stk_ef_val_t | stk_ef_and (stk_ef_t *ef, stk_ef_val_t mask) |
| AND the flags word with a mask (equivalent of ThreadX tx_event_flags_set(TX_AND)). | |
| stk_ef_val_t | stk_ef_get (stk_ef_t *ef) |
| Read the current flags word without modifying it. | |
| stk_ef_val_t | stk_ef_wait (stk_ef_t *ef, stk_ef_val_t flags, uint32_t options, stk_timeout_t timeout) |
| Wait for one or more flags to be set. | |
| stk_ef_val_t | stk_ef_trywait (stk_ef_t *ef, stk_ef_val_t flags, uint32_t options) |
| Non-blocking flag poll. | |
| stk_wait_result_t | stk_ef_wait_ex (stk_ef_t *ef, stk_ef_val_t flags, uint32_t options, stk_timeout_t timeout, stk_ef_val_t *actual_flags) |
| Wait for one or more flags to be set, reporting the outcome as stk_wait_result_t. | |
| stk_wait_result_t | stk_ef_trywait_ex (stk_ef_t *ef, stk_ef_val_t flags, uint32_t options, stk_ef_val_t *actual_flags) |
| Non-blocking flag poll with stk_wait_result_t and full flags snapshot. | |
| stk_ef_sync_ctx_t * | stk_ef_sync_ctx_create (stk_ef_sync_ctx_mem_t *const membuf) |
| Create a rendezvous context (using provided memory). | |
| void | stk_ef_sync_ctx_destroy (stk_ef_sync_ctx_t *ctx) |
| Destroy a rendezvous context. | |
| stk_wait_result_t | stk_ef_sync (stk_ef_t *ef, stk_ef_sync_ctx_t *ctx, stk_ef_val_t set_flags, stk_ef_val_t wait_flags, stk_timeout_t timeout, stk_ef_val_t *actual_flags) |
| Atomically set flags and wait for a group of flags: a multi-task rendezvous (equivalent of FreeRTOS xEventGroupSync()). | |
| stk::sync::EventFlagsT< stk_ef_val_t > * | stk_ef_get_instance (stk_ef_t *ef) |
Get the underlying C++ stk::sync::EventFlagsT<stk_ef_val_t> object wrapped by a stk_ef_t handle. | |
| stk_pipe_t * | stk_pipe_create (stk_pipe_mem_t *const membuf, uint8_t *buf, uint32_t buf_size, size_t capacity, size_t element_size) |
| Create a Pipe (using provided memory). | |
| void | stk_pipe_destroy (stk_pipe_t *pipe) |
| Destroy a Pipe. | |
| bool | stk_pipe_write (stk_pipe_t *pipe, const void *data, stk_timeout_t timeout) |
| Write a single element to the pipe. | |
| stk_wait_result_t | stk_pipe_write_ex (stk_pipe_t *pipe, const void *data, stk_timeout_t timeout) |
| Write a single element to the pipe, preserving the full outcome. | |
| bool | stk_pipe_trywrite (stk_pipe_t *pipe, const void *data) |
| Attempt to write a single element to the pipe without blocking. | |
| bool | stk_pipe_read (stk_pipe_t *pipe, void *data, stk_timeout_t timeout) |
| Read a single element from the pipe. | |
| stk_wait_result_t | stk_pipe_read_ex (stk_pipe_t *pipe, void *data, stk_timeout_t timeout) |
| Read a single element from the pipe, preserving the full outcome. | |
| bool | stk_pipe_tryread (stk_pipe_t *pipe, void *data) |
| Attempt to read a single element from the pipe without blocking. | |
| size_t | stk_pipe_write_bulk (stk_pipe_t *pipe, const void *src, size_t count, stk_timeout_t timeout) |
| Write multiple elements to the pipe. | |
| stk_wait_result_t | stk_pipe_write_bulk_ex (stk_pipe_t *pipe, const void *src, size_t count, size_t *written, stk_timeout_t timeout) |
| Write multiple elements to the pipe, preserving the full outcome. | |
| size_t | stk_pipe_trywrite_bulk (stk_pipe_t *pipe, const void *src, size_t count) |
| Attempt to write multiple elements to the pipe without blocking. | |
| size_t | stk_pipe_read_bulk (stk_pipe_t *pipe, void *dst, size_t count, stk_timeout_t timeout) |
| Read multiple elements from the pipe. | |
| stk_wait_result_t | stk_pipe_read_bulk_ex (stk_pipe_t *pipe, void *dst, size_t count, size_t *read_count, stk_timeout_t timeout) |
| Read multiple elements from the pipe, preserving the full outcome. | |
| size_t | stk_pipe_tryread_bulk (stk_pipe_t *pipe, void *dst, size_t count) |
| Attempt to read multiple elements from the pipe without blocking. | |
| size_t | stk_pipe_read_bulk_triggered (stk_pipe_t *pipe, void *dst, size_t trigger, size_t max_count, stk_timeout_t timeout) |
| Read at least trigger elements, then drain up to max_count without blocking. | |
| stk_wait_result_t | stk_pipe_read_bulk_triggered_ex (stk_pipe_t *pipe, void *dst, size_t trigger, size_t max_count, size_t *read_count, stk_timeout_t timeout) |
| Read at least trigger elements, then drain up to max_count, preserving the full outcome. | |
| size_t | stk_pipe_tryread_bulk_triggered (stk_pipe_t *pipe, void *dst, size_t max_count) |
| Non-blocking variant of stk_pipe_read_bulk_triggered. | |
| void | stk_pipe_reset (stk_pipe_t *pipe) |
| Discard all elements and reset the pipe to the empty state. | |
| size_t | stk_pipe_get_capacity (const stk_pipe_t *pipe) |
| Get the maximum number of elements the pipe can hold. | |
| size_t | stk_pipe_get_element_size (const stk_pipe_t *pipe) |
| Get the size of each element in bytes. | |
| size_t | stk_pipe_get_count (const stk_pipe_t *pipe) |
| Get the current number of elements in the pipe. | |
| size_t | stk_pipe_get_space (const stk_pipe_t *pipe) |
| Get the number of free slots currently available. | |
| bool | stk_pipe_is_empty (const stk_pipe_t *pipe) |
| Check whether the pipe is currently empty. | |
| bool | stk_pipe_is_full (const stk_pipe_t *pipe) |
| Check whether the pipe is currently full. | |
| bool | stk_pipe_is_storage_valid (const stk_pipe_t *pipe) |
| Verify that the backing storage is valid and the pipe is ready for use. | |
| stk::sync::Pipe * | stk_pipe_get_instance (stk_pipe_t *pipe) |
Get the underlying C++ stk::sync::Pipe object wrapped by a stk_pipe_t handle. | |
| stk_msgq_t * | stk_msgq_create (stk_msgq_mem_t *const membuf, uint8_t *buf, uint32_t buf_size, size_t capacity, size_t msg_size) |
| Create a MessageQueue (using provided memory). | |
| void | stk_msgq_destroy (stk_msgq_t *mq) |
| Destroy a MessageQueue. | |
| bool | stk_msgq_put (stk_msgq_t *mq, const void *msg, stk_timeout_t timeout) |
| Put a message into the queue. | |
| stk_wait_result_t | stk_msgq_put_ex (stk_msgq_t *mq, const void *msg, stk_timeout_t timeout) |
| Put a message into the queue, preserving the full outcome. | |
| bool | stk_msgq_tryput (stk_msgq_t *mq, const void *msg) |
| Attempt to put a message into the queue without blocking. | |
| bool | stk_msgq_putfront (stk_msgq_t *mq, const void *msg, stk_timeout_t timeout) |
| Put a message into the front of the queue (priority insert). | |
| stk_wait_result_t | stk_msgq_putfront_ex (stk_msgq_t *mq, const void *msg, stk_timeout_t timeout) |
| Put a message into the front of the queue, preserving the full outcome. | |
| bool | stk_msgq_tryputfront (stk_msgq_t *mq, const void *msg) |
| Attempt to put a message into the front of the queue without blocking. | |
| bool | stk_msgq_get (stk_msgq_t *mq, void *msg, stk_timeout_t timeout) |
| Get a message from the queue. | |
| stk_wait_result_t | stk_msgq_get_ex (stk_msgq_t *mq, void *msg, stk_timeout_t timeout) |
| Get a message from the queue, preserving the full outcome. | |
| bool | stk_msgq_tryget (stk_msgq_t *mq, void *msg) |
| Attempt to get a message from the queue without blocking. | |
| bool | stk_msgq_peek (stk_msgq_t *mq, void *msg, stk_timeout_t timeout) |
| Peek at the next message to be delivered without removing it. | |
| stk_wait_result_t | stk_msgq_peek_ex (stk_msgq_t *mq, void *msg, stk_timeout_t timeout) |
| Peek at the next message without removing it, preserving the full outcome. | |
| bool | stk_msgq_trypeek (stk_msgq_t *mq, void *msg) |
| Attempt to peek at the next message without blocking. | |
| bool | stk_msgq_peekfront (stk_msgq_t *mq, void *msg, stk_timeout_t timeout) |
| Peek at the most recently front-inserted message without removing it. | |
| stk_wait_result_t | stk_msgq_peekfront_ex (stk_msgq_t *mq, void *msg, stk_timeout_t timeout) |
| Peek at the front-inserted message without removing it, preserving the full outcome. | |
| bool | stk_msgq_trypeekfront (stk_msgq_t *mq, void *msg) |
| Attempt to peek at the front message without blocking. | |
| void | stk_msgq_reset (stk_msgq_t *mq) |
| Discard all messages and reset the queue to the empty state. | |
| size_t | stk_msgq_get_capacity (const stk_msgq_t *mq) |
| Get the maximum number of messages the queue can hold. | |
| size_t | stk_msgq_get_msg_size (const stk_msgq_t *mq) |
| Get the size of each message in bytes. | |
| size_t | stk_msgq_get_count (const stk_msgq_t *mq) |
| Get the current number of messages waiting in the queue. | |
| size_t | stk_msgq_get_space (const stk_msgq_t *mq) |
| Get the number of free slots currently available. | |
| bool | stk_msgq_is_empty (const stk_msgq_t *mq) |
| Check whether the queue is currently empty. | |
| uint8_t * | stk_msgq_get_buffer (stk_msgq_t *mq) |
| Get a pointer to the raw message data buffer. | |
| bool | stk_msgq_is_full (const stk_msgq_t *mq) |
| Check whether the queue is currently full. | |
| bool | stk_msgq_is_storage_valid (const stk_msgq_t *mq) |
| Verify that the backing storage is valid and the queue is ready for use. | |
| stk::sync::MessageQueue * | stk_msgq_get_instance (stk_msgq_t *mq) |
Get the underlying C++ stk::sync::MessageQueue object wrapped by a stk_msgq_t handle. | |
| stk_rwmutex_t * | stk_rwmutex_create (stk_rwmutex_mem_t *const membuf) |
| Create an RWMutex (using provided memory). | |
| void | stk_rwmutex_destroy (stk_rwmutex_t *rw) |
| Destroy an RWMutex. | |
| void | stk_rwmutex_read_lock (stk_rwmutex_t *rw) |
| Acquire the lock for shared reading. Blocks until available. | |
| bool | stk_rwmutex_try_read_lock (stk_rwmutex_t *rw) |
| Try to acquire the read lock without blocking. | |
| bool | stk_rwmutex_timed_read_lock (stk_rwmutex_t *rw, stk_timeout_t timeout) |
| Try to acquire the read lock with a timeout. | |
| stk_wait_result_t | stk_rwmutex_timed_read_lock_ex (stk_rwmutex_t *rw, stk_timeout_t timeout) |
| Try to acquire the read lock with a timeout, preserving the full outcome. | |
| void | stk_rwmutex_read_unlock (stk_rwmutex_t *rw) |
| Release the shared reader lock. | |
| void | stk_rwmutex_lock (stk_rwmutex_t *rw) |
| Acquire the lock for exclusive writing. Blocks until available. | |
| bool | stk_rwmutex_trylock (stk_rwmutex_t *rw) |
| Try to acquire the write lock without blocking. | |
| bool | stk_rwmutex_timed_lock (stk_rwmutex_t *rw, stk_timeout_t timeout) |
| Try to acquire the write lock with a timeout. | |
| stk_wait_result_t | stk_rwmutex_timed_lock_ex (stk_rwmutex_t *rw, stk_timeout_t timeout) |
| Try to acquire the write lock with a timeout, preserving the full outcome. | |
| void | stk_rwmutex_unlock (stk_rwmutex_t *rw) |
| Release the exclusive writer lock. | |
| stk::sync::RWMutex * | stk_rwmutex_get_instance (stk_rwmutex_t *rw) |
Get the underlying C++ stk::sync::RWMutex object wrapped by a stk_rwmutex_t handle. | |
| stk_barrier_t * | stk_barrier_create (stk_barrier_mem_t *const membuf, uint32_t count) |
| Create a Barrier (using provided memory). | |
| void | stk_barrier_destroy (stk_barrier_t *barrier) |
| Destroy a Barrier. | |
| bool | stk_barrier_wait (stk_barrier_t *barrier) |
Block the calling task until count tasks have called stk_barrier_wait(). | |
| stk_barrier_result_t | stk_barrier_wait_ex (stk_barrier_t *barrier) |
| Block the calling task until count tasks have arrived, preserving the full outcome. | |
| uint32_t | stk_barrier_get_threshold (const stk_barrier_t *barrier) |
| Get the number of tasks required to trip the barrier. | |
| stk::sync::Barrier * | stk_barrier_get_instance (stk_barrier_t *barrier) |
Get the underlying C++ stk::sync::Barrier object wrapped by a stk_barrier_t handle. | |
| template<typename T, typename Mem, typename... Args> | |
| static T * | stk::ConstructIn (Mem &mem, Args &&... args) |
| Construct object T in-place inside a C memory container. | |
C language binding/interface for SuperTinyKernel RTOS.
This header provides a pure C API to create, configure and run STK kernel from C code.
Definition in file stk_c.h.