SuperTinyKernel™ RTOS 1.08.x
Lightweight, high-performance, deterministic, bare-metal C++ RTOS for resource-constrained embedded systems. MIT Open Source License.
Loading...
Searching...
No Matches
STK C API

Pure C interface for C++ API of SuperTinyKernel RTOS. More...

Collaboration diagram for STK C API:

Namespaces

namespace  stk
 Namespace of STK package.

Classes

struct  stk_event_overrider_t
 C-level callback table that mirrors stk::IPlatform::IEventOverrider. More...
struct  stk_mutex_mem_t
 Opaque memory container for a Mutex 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_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...

Macros

#define STK_C_VERSION   (0x20261004)
 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_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_c_stack
 Stack attribute (applies required alignment for a stack memory).
#define __stk_c_aligned
 Memory buffer alignment attribute.
#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_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_SEM_IMPL_SIZE   (8U + (STK_SYNC_DEBUG_NAMES ? 1U : 0U))
 A memory size (multiples of stk_word_t) required for Semaphore instance.
#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_ERROR_PARAMETER   (0x80000001U)
 Return-value error sentinels (bit 31 set indicates an error).
#define STK_EF_ERROR_TIMEOUT   (0x80000002U)
#define STK_EF_ERROR_ISR   (0x80000004U)
#define STK_EF_ERROR_CANCELED   (0x80000008U)
#define STK_EF_ERROR_MASK   (0x80000000U)
#define STK_EF_IMPL_SIZE   (STK_CV_IMPL_SIZE + 1U + (STK_SYNC_DEBUG_NAMES ? 1U : 0U))
 A memory size (multiples of stk_word_t) required for EventFlags instance.
#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_kernel_state_t stk_kernel_state_t
 Kernel state.
typedef struct stk_event_overrider_t stk_event_overrider_t
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_spinlock_t stk_spinlock_t
 Opaque handle to a SpinLock instance.
typedef enum stk_wait_result_t stk_wait_result_t
 Outcome of a cancellable, timed kernel wait (see stk_cv_wait_ex()).
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 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 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_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.

Enumerations

enum  stk_kernel_state_t {
  STK_KERNEL_STATE_INACTIVE = 0 ,
  STK_KERNEL_STATE_READY = 1 ,
  STK_KERNEL_STATE_RUNNING = 2 ,
  STK_KERNEL_STATE_SUSPENDED = 3
}
 Kernel state. More...
enum  stk_wait_result_t {
  STK_WAIT_RESULT_FAIL = -1 ,
  STK_WAIT_RESULT_SIGNAL = 0 ,
  STK_WAIT_RESULT_TIMEOUT = 1 ,
  STK_WAIT_RESULT_CANCELED = 2
}
 Outcome of a cancellable, timed kernel wait (see stk_cv_wait_ex()). More...
enum  stk_barrier_result_t {
  STK_BARRIER_RELEASED = 0 ,
  STK_BARRIER_LAST_ARRIVAL = 1 ,
  STK_BARRIER_CANCELED = 2
}
 Outcome of a stk_barrier_wait_ex() call. More...

Functions

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.
void stk_kernel_add_task (stk_kernel_t *k, stk_task_t *tsk)
 Add task to non-HRT kernel (static or dynamic).
void 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.
void stk_kernel_suspend_task (stk_kernel_t *k, stk_task_t *task, bool *suspended)
 Suspend a task (prevent it from being scheduled).
void stk_kernel_resume_task (stk_kernel_t *k, stk_task_t *task)
 Resume a previously suspended task.
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_cycle_t stk_hires_cycles (void)
 Get raw CPU cycle counter.
uint32_t stk_hires_frequency (void)
 Get CPU clock frequency in Hz.
stk_tick_t stk_hires_time_us (void)
 Get elapsed time in microseconds from the high-resolution clock.
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_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::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_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.
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.
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, uint32_t initial_count, uint32_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.
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.
uint16_t stk_sem_get_count (const stk_sem_t *sem)
 Get the current counter value.
stk::sync::Semaphore * stk_sem_get_instance (stk_sem_t *sem)
 Get the underlying C++ stk::sync::Semaphore object wrapped by a stk_sem_t handle.
static bool stk_ef_is_error (uint32_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 (bit 31 set).
stk_ef_t * stk_ef_create (stk_ef_mem_t *const membuf, uint32_t initial_flags)
 Create an EventFlags object (using provided memory).
void stk_ef_destroy (stk_ef_t *ef)
 Destroy an EventFlags object.
uint32_t stk_ef_set (stk_ef_t *ef, uint32_t flags)
 Set one or more flags.
uint32_t stk_ef_clear (stk_ef_t *ef, uint32_t flags)
 Clear one or more flags.
uint32_t stk_ef_get (stk_ef_t *ef)
 Read the current flags word without modifying it.
uint32_t stk_ef_wait (stk_ef_t *ef, uint32_t flags, uint32_t options, stk_timeout_t timeout)
 Wait for one or more flags to be set.
uint32_t stk_ef_trywait (stk_ef_t *ef, uint32_t flags, uint32_t options)
 Non-blocking flag poll.
stk::sync::EventFlags * stk_ef_get_instance (stk_ef_t *ef)
 Get the underlying C++ stk::sync::EventFlags 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.
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.
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.
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.
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.
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.
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).
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.
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.
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.
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.
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.
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.

Detailed Description

Pure C interface for C++ API of SuperTinyKernel RTOS.

Macro Definition Documentation

◆ __stk_c_aligned

#define __stk_c_aligned

Memory buffer alignment attribute.

Examples
D:/SVN/private/stk/interop/c/include/stk_c.h.

Definition at line 216 of file stk_c.h.

◆ __stk_c_stack

#define __stk_c_stack

Stack attribute (applies required alignment for a stack memory).

Definition at line 207 of file stk_c.h.

◆ STK_ALIGN_MASK

#define STK_ALIGN_MASK   (STK_ALIGN_SIZE - 1U)

Alignment mask.

Definition at line 164 of file stk_c.h.

Referenced by pthread_attr_setstack().

◆ STK_ALIGN_SIZE

#define STK_ALIGN_SIZE   sizeof(stk_word_t)

Memory buffer alignment.

Definition at line 160 of file stk_c.h.

◆ STK_BARRIER_IMPL_SIZE

#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.

Note
Composed of one Mutex (STK_MUTEX_IMPL_SIZE), one ConditionVariable (STK_CV_IMPL_SIZE), three uint32_t counters (threshold, count, generation), plus Barrier's own debug name if enabled.
Examples
D:/SVN/private/stk/interop/c/include/stk_c.h.

Definition at line 2109 of file stk_c.h.

◆ STK_C_ASSERT

#define STK_C_ASSERT ( e)
Value:
assert(e)

Assertion macro used inside STK C bindings.

Definition at line 80 of file stk_c.h.

Referenced by stk::pthread::EnqueueReap(), stk::pthread::EnsureReaper(), pthread_create(), pthread_exit(), stk::pthread::ReaperEntry(), and stk_pthread_bind_kernel().

◆ STK_C_CPU_COUNT

#define STK_C_CPU_COUNT   (1)

Number of kernel instances / CPU cores supported (default: 1).

Note
Each core usually gets its own independent kernel instance.

Definition at line 65 of file stk_c.h.

Referenced by SetEventOverrider(), stk_kernel_create(), stk_kernel_get_instance(), stk_timerhost_get(), and UnregisterKernel().

◆ STK_C_KERNEL_MAX_TASKS

#define STK_C_KERNEL_MAX_TASKS   (4)

Maximum number of tasks per kernel instance (default: 4).

Note
Increase this value if you need more tasks. Has direct impact on RAM and FLASH usage.

Definition at line 57 of file stk_c.h.

◆ STK_C_VERSION

#define STK_C_VERSION   (0x20261004)

Interface version.

Definition at line 45 of file stk_c.h.

◆ STK_CV_IMPL_SIZE

#define STK_CV_IMPL_SIZE   (7U + (STK_SYNC_DEBUG_NAMES ? 1U : 0U))

A memory size (multiples of stk_word_t) required for ConditionVariable instance.

Examples
D:/SVN/private/stk/interop/c/include/stk_c.h.

Definition at line 1074 of file stk_c.h.

◆ STK_DEFAULT_CS_SESSION

#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.

Definition at line 892 of file stk_c.h.

◆ STK_DEFINE_STACK_POOL

#define STK_DEFINE_STACK_POOL ( name,
max_tasks,
stack_size )
Value:
static stk_word_t name[max_tasks][stack_size] __stk_c_stack
#define __stk_c_stack
Stack attribute (applies required alignment for a stack memory).
Definition stk_c.h:207
uintptr_t stk_word_t
CPU register type.
Definition stk_c.h:99

Allocates a statically bound, multi-dimensional stack pool for tasks.

Parameters
[in]nameIdentifier name of the generated array.
[in]max_tasksMaximum number of tasks (rows in the array).
[in]stack_sizeSize of each individual stack in words (columns).
See also
STK_GET_STACK_FROM_POOL

Definition at line 186 of file stk_c.h.

186#define STK_DEFINE_STACK_POOL(name, max_tasks, stack_size) \
187 static stk_word_t name[max_tasks][stack_size] __stk_c_stack

◆ STK_EF_ERROR_CANCELED

#define STK_EF_ERROR_CANCELED   (0x80000008U)

Wait was cancelled before the flag condition was met

Definition at line 1332 of file stk_c.h.

◆ STK_EF_ERROR_ISR

#define STK_EF_ERROR_ISR   (0x80000004U)

Wait called from an ISR with a blocking timeout

Definition at line 1331 of file stk_c.h.

◆ STK_EF_ERROR_MASK

#define STK_EF_ERROR_MASK   (0x80000000U)

Mask for testing any error; bit 31 set means error

Examples
D:/SVN/private/stk/interop/c/include/stk_c.h.

Definition at line 1333 of file stk_c.h.

Referenced by stk_ef_is_error().

◆ STK_EF_ERROR_PARAMETER

#define STK_EF_ERROR_PARAMETER   (0x80000001U)

Return-value error sentinels (bit 31 set indicates an error).

flags argument is 0 or has bit 31 set

Definition at line 1329 of file stk_c.h.

◆ STK_EF_ERROR_TIMEOUT

#define STK_EF_ERROR_TIMEOUT   (0x80000002U)

Timeout expired before the flag condition was met

Definition at line 1330 of file stk_c.h.

◆ STK_EF_IMPL_SIZE

#define STK_EF_IMPL_SIZE   (STK_CV_IMPL_SIZE + 1U + (STK_SYNC_DEBUG_NAMES ? 1U : 0U))

A memory size (multiples of stk_word_t) required for EventFlags instance.

Note
EventFlags contains one ConditionVariable (STK_CV_IMPL_SIZE words) plus one 32-bit flags word and alignment padding.
Examples
D:/SVN/private/stk/interop/c/include/stk_c.h.

Definition at line 1347 of file stk_c.h.

◆ STK_EF_OPT_NO_CLEAR

#define STK_EF_OPT_NO_CLEAR   (0x00000002U)

Do not clear matched bits on a successful return

Definition at line 1325 of file stk_c.h.

◆ STK_EF_OPT_WAIT_ALL

#define STK_EF_OPT_WAIT_ALL   (0x00000001U)

Unblock when ALL requested bits are simultaneously set (AND semantics)

Definition at line 1324 of file stk_c.h.

◆ STK_EF_OPT_WAIT_ANY

#define STK_EF_OPT_WAIT_ANY   (0x00000000U)

Options bitmask constants for stk_ef_wait() / stk_ef_trywait().

Unblock when ANY requested bit is set (OR semantics, default)

Definition at line 1323 of file stk_c.h.

◆ STK_EVENT_IMPL_SIZE

#define STK_EVENT_IMPL_SIZE   (8U + (STK_SYNC_DEBUG_NAMES ? 1U : 0U))

A memory size (multiples of stk_word_t) required for Event instance.

Examples
D:/SVN/private/stk/interop/c/include/stk_c.h.

Definition at line 1154 of file stk_c.h.

◆ STK_GET_STACK_FROM_POOL

#define STK_GET_STACK_FROM_POOL ( name,
task_id )
Value:
(name[task_id])

Retrieves the base stack pointer for a specific task ID from a stack pool.

Parameters
[in]nameIdentifier name of the allocated stack pool.
[in]task_idIndex of the task whose stack pointer is requested.
See also
STK_DEFINE_STACK_POOL

Definition at line 195 of file stk_c.h.

◆ STK_MSGQ_BUF_SIZE

#define STK_MSGQ_BUF_SIZE ( capacity,
msg_size )
Value:
((capacity) * (msg_size))

Compute the required data-buffer size (in bytes) for a MessageQueue.

Parameters
[in]capacityMaximum number of messages.
[in]msg_sizeSize of each message in bytes.
Note
Use this macro when declaring the uint8_t buffer passed to stk_msgq_create():
#define MY_QUEUE_CAP 8
#define MY_MSG_SIZE sizeof(MyMsg_t)
static uint8_t s_msgq_buf[STK_MSGQ_BUF_SIZE(MY_QUEUE_CAP, MY_MSG_SIZE)];
static stk_msgq_mem_t s_msgq_mem;
stk_msgq_t *g_queue = stk_msgq_create(&s_msgq_mem,
s_msgq_buf, sizeof(s_msgq_buf),
MY_QUEUE_CAP, MY_MSG_SIZE);
#define STK_MSGQ_BUF_SIZE(capacity, msg_size)
Compute the required data-buffer size (in bytes) for a MessageQueue.
Definition stk_c.h:1765
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).
struct stk_msgq_t stk_msgq_t
Opaque handle to a MessageQueue instance.
Definition stk_c.h:1746
Opaque memory container for a MessageQueue instance.
Definition stk_c.h:1740

Definition at line 1765 of file stk_c.h.

◆ STK_MSGQ_IMPL_SIZE

#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.

Covers the fixed-overhead fields of stk::sync::MessageQueue: six size_t members (buffer ptr, capacity, msg_size, count, head, tail) plus two ConditionVariable objects (cv_not_empty, cv_not_full) and optional debug-name word.

Note
The backing data buffer is allocated separately by the caller and passed to stk_msgq_create() via the buf / buf_size parameters.
Examples
D:/SVN/private/stk/interop/c/include/stk_c.h.

Definition at line 1736 of file stk_c.h.

◆ STK_MUTEX_IMPL_SIZE

#define STK_MUTEX_IMPL_SIZE   (10U + (STK_SYNC_DEBUG_NAMES ? 1U : 0U))

A memory size (multiples of stk_word_t) required for Mutex instance.

Examples
D:/SVN/private/stk/interop/c/include/stk_c.h.

Definition at line 947 of file stk_c.h.

◆ STK_NO_WAIT

#define STK_NO_WAIT   (STK_STATIC_CAST(stk_timeout_t, 0))

No timeout constant.

Definition at line 156 of file stk_c.h.

◆ STK_PERIODICITY_DEFAULT

#define STK_PERIODICITY_DEFAULT   (1000U)

Default tick period (1 ms).

in microseconds

Definition at line 139 of file stk_c.h.

◆ STK_PIPE_BUF_SIZE

#define STK_PIPE_BUF_SIZE ( capacity,
element_size )
Value:
((((capacity) * (element_size)) + STK_ALIGN_MASK) & ~STK_ALIGN_MASK)
#define STK_ALIGN_MASK
Alignment mask.
Definition stk_c.h:164

Compute the required data-buffer size (in bytes) for a Pipe.

Parameters
[in]capacityMaximum number of elements the pipe can hold.
[in]element_sizeSize of a single element in bytes.
Note
Use this macro when declaring the uint8_t buffer passed to stk_pipe_create():
#define MY_PIPE_CAP 16
#define MY_ELEM_SIZE sizeof(MyMsg_t)
static uint8_t s_pipe_buf[STK_PIPE_BUF_SIZE(MY_PIPE_CAP, MY_ELEM_SIZE)] __stk_c_aligned;
static stk_pipe_mem_t s_pipe_mem;
stk_pipe_t *g_pipe = stk_pipe_create(&s_pipe_mem,
s_pipe_buf, sizeof(s_pipe_buf),
MY_PIPE_CAP, MY_ELEM_SIZE);
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).
#define STK_PIPE_BUF_SIZE(capacity, element_size)
Compute the required data-buffer size (in bytes) for a Pipe.
Definition stk_c.h:1486
#define __stk_c_aligned
Memory buffer alignment attribute.
Definition stk_c.h:216
struct stk_pipe_t stk_pipe_t
Opaque handle to a Pipe instance.
Definition stk_c.h:1467
Opaque memory container for a Pipe control-block.
Definition stk_c.h:1461

Definition at line 1486 of file stk_c.h.

1486#define STK_PIPE_BUF_SIZE(capacity, element_size) \
1487 ((((capacity) * (element_size)) + STK_ALIGN_MASK) & ~STK_ALIGN_MASK)

◆ STK_PIPE_IMPL_SIZE

#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.

Covers the fixed-overhead fields of stk::sync::Pipe: one uint8_t pointer plus five size_t members (capacity, element_size, count, head, tail), two ConditionVariable objects (cv_not_empty, cv_not_full) and an optional debug-name word.

Note
The backing data buffer is allocated separately by the caller and passed to stk_pipe_create() via the buf / buf_size parameters.
Examples
D:/SVN/private/stk/interop/c/include/stk_c.h.

Definition at line 1457 of file stk_c.h.

◆ STK_RWMUTEX_IMPL_SIZE

#define STK_RWMUTEX_IMPL_SIZE   (17U + (STK_SYNC_DEBUG_NAMES ? 3U : 0U))

A memory size (multiples of stk_word_t) required for RWMutex instance.

Examples
D:/SVN/private/stk/interop/c/include/stk_c.h.

Definition at line 2007 of file stk_c.h.

◆ STK_SEM_IMPL_SIZE

#define STK_SEM_IMPL_SIZE   (8U + (STK_SYNC_DEBUG_NAMES ? 1U : 0U))

A memory size (multiples of stk_word_t) required for Semaphore instance.

Examples
D:/SVN/private/stk/interop/c/include/stk_c.h.

Definition at line 1229 of file stk_c.h.

◆ STK_SPINLOCK_IMPL_SIZE

#define STK_SPINLOCK_IMPL_SIZE   (6)

A memory size (multiples of stk_word_t) required for SpinLock instance.

Examples
D:/SVN/private/stk/interop/c/include/stk_c.h.

Definition at line 1011 of file stk_c.h.

◆ STK_STACK_MEMORY_ALIGN

#define STK_STACK_MEMORY_ALIGN   (4U)

Stack memory alignment.

Definition at line 175 of file stk_c.h.

◆ STK_STATIC_CAST

#define STK_STATIC_CAST ( type,
val )
Value:
static_cast<type>(val)

Convenience wrapper for static_cast and C-style cast.

Parameters
[in]typeValue type.
[in]valValue.
Examples
D:/SVN/private/stk/interop/c/include/stk_c.h.

Definition at line 88 of file stk_c.h.

Referenced by stk_ms_from_ticks_r(), and stk_ticks_from_ms_r().

◆ STK_SYNC_DEBUG_NAMES

#define STK_SYNC_DEBUG_NAMES   (0)

Enable names for synchronization primitives for debugging/tracing purpose.

Definition at line 74 of file stk_c.h.

◆ STK_TLS_GET_T

#define STK_TLS_GET_T ( type)
Value:
((type *)stk_tls_get())
void * stk_tls_get(void)
Get thread-local pointer (platform-specific slot).

Typed helper for getting TLS value.

Note
Expands to ((type *)stk_tls_get())

Definition at line 867 of file stk_c.h.

◆ STK_TLS_SET_T

#define STK_TLS_SET_T ( ptr)
Value:
stk_tls_set((void *)(ptr))
void stk_tls_set(void *ptr)
Set thread-local pointer.

Typed helper for setting TLS value.

Note
Expands to stk_tls_set((void *)(ptr))

Definition at line 872 of file stk_c.h.

◆ STK_WAIT_INFINITE

#define STK_WAIT_INFINITE   (STK_STATIC_CAST(stk_timeout_t, INT32_MAX))

Infinite timeout constant.

Definition at line 152 of file stk_c.h.

Typedef Documentation

◆ stk_barrier_mem_t

typedef struct stk_barrier_mem_t stk_barrier_mem_t

Opaque memory container for a Barrier instance.

◆ stk_barrier_result_t

Outcome of a stk_barrier_wait_ex() call.

Note
It is a direct match for stk::sync::Barrier::EResult.

◆ stk_barrier_t

typedef struct stk_barrier_t stk_barrier_t

Opaque handle to a Barrier instance.

Definition at line 2119 of file stk_c.h.

◆ stk_cs_session_t

typedef uint8_t stk_cs_session_t

Session of Critical Section.

Opaque token returned by stk_critical_section_enter_ex() that carries the state which must be restored by the matching stk_critical_section_exit_ex() (e.g. the previous interrupt masking level, such as BASEPRI on ARM Cortex-M, and the privilege-level handling path that was selected on entry).

Note
Do not modify or interpret the value, pass it unchanged to stk_critical_section_exit_ex().
Examples
D:/SVN/private/stk/interop/c/include/stk_c.h.

Definition at line 887 of file stk_c.h.

◆ stk_cv_mem_t

typedef struct stk_cv_mem_t stk_cv_mem_t

Opaque memory container for a ConditionVariable instance.

◆ stk_cv_t

typedef struct stk_cv_t stk_cv_t

Opaque handle to a Condition Variable instance.

Definition at line 1084 of file stk_c.h.

◆ stk_cycle_t

typedef uint64_t stk_cycle_t

CPU cycles value.

See also
stk_sys_timer_count, stk_hires_cycles
Examples
D:/SVN/private/stk/interop/c/include/stk_c.h.

Definition at line 123 of file stk_c.h.

◆ stk_ef_mem_t

typedef struct stk_ef_mem_t stk_ef_mem_t

Opaque memory container for an EventFlags instance.

◆ stk_ef_t

typedef struct stk_ef_t stk_ef_t

Opaque handle to an EventFlags instance.

Definition at line 1357 of file stk_c.h.

◆ stk_event_mem_t

typedef struct stk_event_mem_t stk_event_mem_t

Opaque memory container for an Event instance.

◆ stk_event_overrider_t

typedef struct stk_event_overrider_t stk_event_overrider_t

◆ stk_event_t

typedef struct stk_event_t stk_event_t

Opaque handle to an Event instance.

Definition at line 1164 of file stk_c.h.

◆ stk_kernel_state_t

Kernel state.

Note
It is a direct match for IKernel::EState enum.
See also
stk_kernel_get_state()

◆ stk_kernel_t

typedef struct stk_kernel_t stk_kernel_t

Opaque handle to a kernel instance.

Examples
D:/SVN/private/stk/interop/c/include/stk_c.h.

Definition at line 131 of file stk_c.h.

◆ stk_msgq_mem_t

typedef struct stk_msgq_mem_t stk_msgq_mem_t

Opaque memory container for a MessageQueue instance.

◆ stk_msgq_t

typedef struct stk_msgq_t stk_msgq_t

Opaque handle to a MessageQueue instance.

Definition at line 1746 of file stk_c.h.

◆ stk_mutex_mem_t

typedef struct stk_mutex_mem_t stk_mutex_mem_t

Opaque memory container for a Mutex instance.

◆ stk_mutex_t

typedef struct stk_mutex_t stk_mutex_t

Opaque handle to a Mutex instance.

Definition at line 957 of file stk_c.h.

◆ stk_pipe_mem_t

typedef struct stk_pipe_mem_t stk_pipe_mem_t

Opaque memory container for a Pipe control-block.

◆ stk_pipe_t

typedef struct stk_pipe_t stk_pipe_t

Opaque handle to a Pipe instance.

Definition at line 1467 of file stk_c.h.

◆ stk_rwmutex_mem_t

typedef struct stk_rwmutex_mem_t stk_rwmutex_mem_t

Opaque memory container for an RWMutex instance.

◆ stk_rwmutex_t

typedef struct stk_rwmutex_t stk_rwmutex_t

Opaque handle to an RWMutex instance.

Definition at line 2017 of file stk_c.h.

◆ stk_sem_mem_t

typedef struct stk_sem_mem_t stk_sem_mem_t

Opaque memory container for a Semaphore instance.

◆ stk_sem_t

typedef struct stk_sem_t stk_sem_t

Opaque handle to a Semaphore instance.

Definition at line 1239 of file stk_c.h.

◆ stk_spinlock_t

typedef struct stk_spinlock_t stk_spinlock_t

Opaque handle to a SpinLock instance.

Definition at line 1022 of file stk_c.h.

◆ stk_task_entry_t

typedef void(* stk_task_entry_t) (void *arg)

Task entry point function type.

Parameters
[in]argUser-supplied argument (may be NULL)
Note
If KERNEL_STATIC, the function must never return. If KERNEL_DYNAMIC, it may return and then task will be considered as finished.
KERNEL_TICKLESS is compatible with both KERNEL_STATIC and KERNEL_DYNAMIC, but is incompatible with KERNEL_HRT (see kernel type definitions below).
Examples
D:/SVN/private/stk/interop/c/include/stk_c.h.

Definition at line 148 of file stk_c.h.

◆ stk_task_t

typedef struct stk_task_t stk_task_t

Opaque handle to a task instance.

Definition at line 135 of file stk_c.h.

◆ stk_tick_t

typedef int64_t stk_tick_t

Ticks value.

See also
stk_ticks
Examples
D:/SVN/private/stk/interop/c/include/stk_c.h.

Definition at line 108 of file stk_c.h.

◆ stk_tid_t

Task id.

Examples
D:/SVN/private/stk/interop/c/include/stk_c.h.

Definition at line 103 of file stk_c.h.

◆ stk_time_t

typedef int64_t stk_time_t

Time value.

See also
stk_time_now_ms
Examples
D:/SVN/private/stk/interop/c/include/stk_c.h.

Definition at line 113 of file stk_c.h.

◆ stk_timeout_t

typedef int32_t stk_timeout_t

Timeout value.

See also
stk_sleep, stk_delay
Examples
D:/SVN/private/stk/interop/c/include/stk_c.h.

Definition at line 118 of file stk_c.h.

◆ stk_wait_result_t

Outcome of a cancellable, timed kernel wait (see stk_cv_wait_ex()).

Note
It is a direct match for stk::EWaitResult.

◆ stk_weight_t

typedef int32_t stk_weight_t

Task weight value.

Examples
D:/SVN/private/stk/interop/c/include/stk_c.h.

Definition at line 127 of file stk_c.h.

◆ stk_word_t

typedef uintptr_t stk_word_t

CPU register type.

Examples
D:/SVN/private/stk/interop/c/include/stk_c.h.

Definition at line 99 of file stk_c.h.

Enumeration Type Documentation

◆ stk_barrier_result_t

Outcome of a stk_barrier_wait_ex() call.

Note
It is a direct match for stk::sync::Barrier::EResult.
Enumerator
STK_BARRIER_RELEASED 

Released because the barrier tripped; this task was not the last arrival.

STK_BARRIER_LAST_ARRIVAL 

This task was the last arrival and tripped the barrier.

STK_BARRIER_CANCELED 

Wait was cancelled before the barrier tripped; this task's arrival was rolled back and does not count toward the generation it was waiting on.

Examples
D:/SVN/private/stk/interop/c/include/stk_c.h.

Definition at line 2137 of file stk_c.h.

2137 {
stk_barrier_result_t
Outcome of a stk_barrier_wait_ex() call.
Definition stk_c.h:2137
@ STK_BARRIER_CANCELED
Definition stk_c.h:2140
@ STK_BARRIER_RELEASED
Released because the barrier tripped; this task was not the last arrival.
Definition stk_c.h:2138
@ STK_BARRIER_LAST_ARRIVAL
This task was the last arrival and tripped the barrier.
Definition stk_c.h:2139

◆ stk_kernel_state_t

Kernel state.

Note
It is a direct match for IKernel::EState enum.
See also
stk_kernel_get_state()
Enumerator
STK_KERNEL_STATE_INACTIVE 

not ready, stk_kernel_init() must be called

STK_KERNEL_STATE_READY 

ready to start, stk_kernel_start() must be called

STK_KERNEL_STATE_RUNNING 

initialized and running, stk_kernel_start() was called successfully

STK_KERNEL_STATE_SUSPENDED 

scheduling suspended via stk_kernel_service_suspend() (tickless idle)

Examples
D:/SVN/private/stk/interop/c/include/stk_c.h.

Definition at line 384 of file stk_c.h.

384 {
stk_kernel_state_t
Kernel state.
Definition stk_c.h:384
@ STK_KERNEL_STATE_INACTIVE
not ready, stk_kernel_init() must be called
Definition stk_c.h:385
@ STK_KERNEL_STATE_READY
ready to start, stk_kernel_start() must be called
Definition stk_c.h:386
@ STK_KERNEL_STATE_RUNNING
initialized and running, stk_kernel_start() was called successfully
Definition stk_c.h:387
@ STK_KERNEL_STATE_SUSPENDED
scheduling suspended via stk_kernel_service_suspend() (tickless idle)
Definition stk_c.h:388

◆ stk_wait_result_t

Outcome of a cancellable, timed kernel wait (see stk_cv_wait_ex()).

Note
It is a direct match for stk::EWaitResult.
Enumerator
STK_WAIT_RESULT_FAIL 

The kernel returned an error without actually waiting.

STK_WAIT_RESULT_SIGNAL 

The wake was caused by a signal.

STK_WAIT_RESULT_TIMEOUT 

The wake was caused by a timeout expiry.

STK_WAIT_RESULT_CANCELED 

The wait was cancelled by another task, independent of signal/timeout.

Examples
D:/SVN/private/stk/interop/c/include/stk_c.h.

Definition at line 1063 of file stk_c.h.

1063 {
stk_wait_result_t
Outcome of a cancellable, timed kernel wait (see stk_cv_wait_ex()).
Definition stk_c.h:1063
@ STK_WAIT_RESULT_TIMEOUT
The wake was caused by a timeout expiry.
Definition stk_c.h:1066
@ STK_WAIT_RESULT_SIGNAL
The wake was caused by a signal.
Definition stk_c.h:1065
@ STK_WAIT_RESULT_CANCELED
The wait was cancelled by another task, independent of signal/timeout.
Definition stk_c.h:1067
@ STK_WAIT_RESULT_FAIL
The kernel returned an error without actually waiting.
Definition stk_c.h:1064

Function Documentation

◆ stk_barrier_create()

stk_barrier_t * stk_barrier_create ( stk_barrier_mem_t *const membuf,
uint32_t count )

Create a Barrier (using provided memory).

Parameters
[in]membufPointer to static memory container.
[in]countNumber of tasks that must call stk_barrier_wait() before any of them is released. Must not be 0.
Returns
Barrier handle.
Examples
D:/SVN/private/stk/interop/c/include/stk_c.h.

Definition at line 926 of file stk_c_sync.cpp.

928{
929 STK_ASSERT(membuf != nullptr);
930 STK_ASSERT(count != 0U);
931
932 stk_barrier_t *result = nullptr;
933 if ((membuf != nullptr) && (count != 0U))
934 {
935 result = ConstructIn<stk_barrier_t>(*membuf, count);
936 }
937
938 return result;
939}
#define STK_ASSERT(e)
Runtime assertion. Halts execution if the expression e evaluates to false.
Definition stk_defs.h:516
static T * ConstructIn(Mem &mem, Args &&... args)
Construct object T in-place inside a C memory container.
Definition stk_c.h:2198

References stk::ConstructIn(), and STK_ASSERT.

Here is the call graph for this function:

◆ stk_barrier_destroy()

void stk_barrier_destroy ( stk_barrier_t * barrier)

Destroy a Barrier.

Parameters
[in]barrierBarrier handle.
Examples
D:/SVN/private/stk/interop/c/include/stk_c.h.

Definition at line 941 of file stk_c_sync.cpp.

942{
943 if (barrier != nullptr)
944 {
945 barrier->~stk_barrier_t();
946 }
947}

◆ stk_barrier_get_instance()

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.

Parameters
[in]barrierBarrier handle obtained via stk_barrier_create().
Returns
Pointer to the wrapped stk::sync::Barrier instance. Never NULL for a valid handle.
Note
C++ callers only (guarded by __cplusplus); not part of the C ABI.
Examples
D:/SVN/private/stk/interop/c/include/stk_c.h.

Definition at line 979 of file stk_c_sync.cpp.

980{
981 STK_ASSERT(barrier != nullptr);
982
983 return &barrier->handle;
984}

References stk_barrier_t::handle, and STK_ASSERT.

◆ stk_barrier_get_threshold()

uint32_t stk_barrier_get_threshold ( const stk_barrier_t * barrier)

Get the number of tasks required to trip the barrier.

Parameters
[in]barrierBarrier handle.
Returns
Construction-time threshold.
Note
ISR-safe.
Examples
D:/SVN/private/stk/interop/c/include/stk_c.h.

Definition at line 972 of file stk_c_sync.cpp.

973{
974 STK_ASSERT(barrier != nullptr);
975
976 return barrier->handle.GetThreshold();
977}
uint32_t GetThreshold() const
Get the number of tasks required to trip the barrier.

References stk::sync::Barrier::GetThreshold(), stk_barrier_t::handle, and STK_ASSERT.

Here is the call graph for this function:

◆ stk_barrier_wait()

bool stk_barrier_wait ( stk_barrier_t * barrier)

Block the calling task until count tasks have called stk_barrier_wait().

Once the last task arrives, all currently waiting tasks are woken up and the barrier resets itself so it can be reused for the next round.

Parameters
[in]barrierBarrier handle.
Note
Cannot report a cancellation - returns False the same as a normal (non-last) release. Use stk_barrier_wait_ex() to tell the two apart.
Warning
ISR-unsafe.
Returns
True if the calling task was the last one to arrive (and thus released the others), False if the calling task was one of the released waiters.
Examples
D:/SVN/private/stk/interop/c/include/stk_c.h.

Definition at line 949 of file stk_c_sync.cpp.

950{
951 STK_ASSERT(barrier != nullptr);
952
953 return barrier->handle.Wait();
954}
bool Wait()
Block the calling task until count tasks have called Wait().

References stk_barrier_t::handle, STK_ASSERT, and stk::sync::Barrier::Wait().

Here is the call graph for this function:

◆ stk_barrier_wait_ex()

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.

Identical to stk_barrier_wait(), except the caller can distinguish a normal release, being the last arrival, and a cancellation.

Parameters
[in]barrierBarrier handle.
Returns
STK_BARRIER_LAST_ARRIVAL, STK_BARRIER_RELEASED, or STK_BARRIER_CANCELED.
Warning
ISR-unsafe.
Examples
D:/SVN/private/stk/interop/c/include/stk_c.h.

Definition at line 956 of file stk_c_sync.cpp.

957{
958 STK_ASSERT(barrier != nullptr);
959
961
962 switch (barrier->handle.WaitEx())
963 {
966 default: result = STK_BARRIER_RELEASED; break;
967 }
968
969 return result;
970}
@ BARRIER_LAST_ARRIVAL
This task was the last arrival and tripped the barrier.
EResult WaitEx()
Block the calling task until count tasks have called Wait(), preserving the full outcome.

References stk::sync::Barrier::BARRIER_CANCELED, stk::sync::Barrier::BARRIER_LAST_ARRIVAL, stk_barrier_t::handle, STK_ASSERT, STK_BARRIER_CANCELED, STK_BARRIER_LAST_ARRIVAL, STK_BARRIER_RELEASED, and stk::sync::Barrier::WaitEx().

Here is the call graph for this function:

◆ stk_critical_section_enter()

void stk_critical_section_enter ( )

Enter global critical section - disable context switches on current core.

Warning
Can be used from a Privileged thread ONLY. When called from a User thread the section cannot be left properly: the matching stk_critical_section_exit() has no session to restore, and in User privilege it is not permitted to clear the interrupt masking (e.g. BASEPRI on ARM Cortex-M) that was set on entry. Use stk_critical_section_enter_ex() / stk_critical_section_exit_ex() in code that may run in a User thread (e.g. shared library or middleware code).
Note
Misuse is caught by STK_ASSERT(IsPrivilegedContext()) when assertions are enabled; with assertions disabled the call is not checked and the behavior is undefined.
Supports nesting (number of enter calls must match number of exit calls).
See also
stk_critical_section_enter_ex
Examples
D:/SVN/private/stk/interop/c/include/stk_c.h.

Definition at line 681 of file stk_c.cpp.

682{
684
686}
#define STK_UNUSED(X)
Explicitly marks a variable as unused to suppress compiler warnings.
Definition stk_defs.h:715
bool IsPrivilegedContext()
Check if caller context is Privileged.
static constexpr Session DEFAULT_SESSION
Default session value passed to Enter()/Exit() when the caller does not need to force a specific hand...
Definition stk_arch.h:478
static Session Enter(const Session ses=DEFAULT_SESSION)
Enter a critical section.

References stk::hw::CriticalSection::DEFAULT_SESSION, stk::hw::CriticalSection::Enter(), stk::hw::IsPrivilegedContext(), STK_ASSERT, and STK_UNUSED.

Here is the call graph for this function:

◆ stk_critical_section_enter_ex()

stk_cs_session_t stk_critical_section_enter_ex ( stk_cs_session_t ses)

Enter global critical section - disable context switches on current core.

Preferred API for entering a critical section. It works from both Privileged and User thread contexts: the returned session preserves the state of the entry, so that the matching stk_critical_section_exit_ex() can restore it correctly regardless of the privilege level the caller is running at.

Note
Supports nesting (number of enter calls must match number of exit calls). Every call must be paired with stk_critical_section_exit_ex() using the session returned by that very call, and nested sections must be left in reverse (LIFO) order.
Keep the section as short as possible: context switches on the current core are disabled until the matching exit.
Parameters
[in]sesSTK_DEFAULT_CS_SESSION to auto-detect the calling context's privilege level, or an explicit session value to force a specific handling path.
Returns
Session value that must be supplied to the matching stk_critical_section_exit_ex().
See also
stk_critical_section_exit_ex
Examples
D:/SVN/private/stk/interop/c/include/stk_c.h.

Definition at line 671 of file stk_c.cpp.

672{
673 return hw::CriticalSection::Enter(ses);
674}

References stk::hw::CriticalSection::Enter().

Here is the call graph for this function:

◆ stk_critical_section_exit()

void stk_critical_section_exit ( )

Leave global critical section - re-enable context switches.

Warning
Can be used from a Privileged thread ONLY, see the warning of stk_critical_section_enter(). Use stk_critical_section_exit_ex() in code that may run in a User thread.
Note
Must be called once for each previous stk_critical_section_enter().
See also
stk_critical_section_exit_ex
Examples
D:/SVN/private/stk/interop/c/include/stk_c.h.

Definition at line 688 of file stk_c.cpp.

689{
691}
static void Exit(const Session ses=DEFAULT_SESSION)
Exit a critical section.

References stk::hw::CriticalSection::DEFAULT_SESSION, and stk::hw::CriticalSection::Exit().

Here is the call graph for this function:

◆ stk_critical_section_exit_ex()

void stk_critical_section_exit_ex ( stk_cs_session_t ses)

Leave global critical section - re-enable context switches.

Restores the state captured by the matching stk_critical_section_enter_ex().

Note
Must be called exactly once for each previous stk_critical_section_enter_ex(), with the session value returned by that call.
Parameters
[in]sesSession value returned by the matching stk_critical_section_enter_ex() call.
See also
stk_critical_section_enter_ex
Examples
D:/SVN/private/stk/interop/c/include/stk_c.h.

Definition at line 676 of file stk_c.cpp.

677{
679}

References stk::hw::CriticalSection::Exit().

Here is the call graph for this function:

◆ stk_cv_create()

stk_cv_t * stk_cv_create ( stk_cv_mem_t *const membuf)

Create a Condition Variable (using provided memory).

Parameters
[in]membufPointer to static memory container.
Returns
CV handle.
Examples
D:/SVN/private/stk/interop/c/include/stk_c.h.

Definition at line 152 of file stk_c_sync.cpp.

153{
154 STK_ASSERT(membuf != nullptr);
155
156 stk_cv_t *result = nullptr;
157 if (membuf != nullptr)
158 {
159 result = ConstructIn<stk_cv_t>(*membuf);
160 }
161
162 return result;
163}

References stk::ConstructIn(), and STK_ASSERT.

Here is the call graph for this function:

◆ stk_cv_destroy()

void stk_cv_destroy ( stk_cv_t * cv)

Destroy a Condition Variable.

Parameters
[in]cvCV handle.
Examples
D:/SVN/private/stk/interop/c/include/stk_c.h.

Definition at line 165 of file stk_c_sync.cpp.

166{
167 if (cv != nullptr)
168 {
169 cv->~stk_cv_t();
170 }
171}

◆ stk_cv_get_instance()

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.

Parameters
[in]cvCV handle obtained via stk_cv_create().
Returns
Pointer to the wrapped stk::sync::ConditionVariable instance. Never NULL for a valid handle.
Note
C++ callers only (guarded by __cplusplus); not part of the C ABI.
Examples
D:/SVN/private/stk/interop/c/include/stk_c.h.

Definition at line 213 of file stk_c_sync.cpp.

214{
215 STK_ASSERT(cv != nullptr);
216
217 return &cv->handle;
218}
ConditionVariable handle

References stk_cv_t::handle, and STK_ASSERT.

◆ stk_cv_notify_all()

void stk_cv_notify_all ( stk_cv_t * cv)

Wake all tasks waiting on the condition variable.

Parameters
[in]cvCV handle.
Examples
D:/SVN/private/stk/interop/c/include/stk_c.h.

Definition at line 206 of file stk_c_sync.cpp.

207{
208 STK_ASSERT(cv != nullptr);
209
210 cv->handle.NotifyAll();
211}
void NotifyAll()
Wake all waiting tasks.

References stk_cv_t::handle, stk::sync::ConditionVariable::NotifyAll(), and STK_ASSERT.

Here is the call graph for this function:

◆ stk_cv_notify_one()

void stk_cv_notify_one ( stk_cv_t * cv)

Wake one task waiting on the condition variable.

Parameters
[in]cvCV handle.
Examples
D:/SVN/private/stk/interop/c/include/stk_c.h.

Definition at line 199 of file stk_c_sync.cpp.

200{
201 STK_ASSERT(cv != nullptr);
202
203 cv->handle.NotifyOne();
204}
void NotifyOne()
Wake one waiting task.

References stk_cv_t::handle, stk::sync::ConditionVariable::NotifyOne(), and STK_ASSERT.

Here is the call graph for this function:

◆ stk_cv_wait()

bool stk_cv_wait ( stk_cv_t * cv,
stk_mutex_t * mtx,
stk_timeout_t timeout )

Wait for a signal on the condition variable.

Atomically releases the mutex and suspends the task. The mutex is re-acquired before returning.

Parameters
[in]cvCV handle.
[in]mtxLocked mutex handle protecting the state.
[in]timeoutMaximum time to wait in OS ticks or STK_WAIT_INFINITE.
Returns
True if signaled, False if the wait did not end in a signal (timeout or an externally cancelled wait).
Note
Collapses the distinction between timeout and cancellation. Use stk_cv_wait_ex() if the caller needs to tell them apart.
If OS tick rate is 1 kHz then 1 tick = 1 ms. Use stk_ticks_from_ms() to convert a millisecond value to ticks for best portability across different tick rates.
Examples
D:/SVN/private/stk/interop/c/include/stk_c.h.

Definition at line 173 of file stk_c_sync.cpp.

174{
175 STK_ASSERT(cv != nullptr);
176 STK_ASSERT(mtx != nullptr);
177
178 return cv->handle.Wait(mtx->handle, timeout);
179}
bool Wait(IMutex &mutex, Timeout timeout_ticks=WAIT_INFINITE)
Wait for a signal.

References stk_cv_t::handle, stk_mutex_t::handle, STK_ASSERT, and stk::sync::ConditionVariable::Wait().

Here is the call graph for this function:

◆ stk_cv_wait_ex()

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.

Identical to stk_cv_wait(), except the caller gets the raw stk_wait_result_t instead of a collapsed bool, so a cancellation can be distinguished from a timeout.

Parameters
[in]cvCV handle.
[in]mtxLocked mutex handle protecting the state.
[in]timeoutMaximum time to wait in OS ticks or STK_WAIT_INFINITE.
Returns
STK_WAIT_RESULT_SIGNAL, STK_WAIT_RESULT_TIMEOUT, or STK_WAIT_RESULT_CANCELED.
Note
If OS tick rate is 1 kHz then 1 tick = 1 ms. Use stk_ticks_from_ms() to convert a millisecond value to ticks for best portability across different tick rates.
Warning
ISR-safe only with timeout = STK_NO_WAIT, ISR-unsafe otherwise.
Examples
D:/SVN/private/stk/interop/c/include/stk_c.h.

Definition at line 181 of file stk_c_sync.cpp.

182{
183 STK_ASSERT(cv != nullptr);
184 STK_ASSERT(mtx != nullptr);
185
186 stk_wait_result_t result;
187
188 switch (cv->handle.WaitEx(mtx->handle, timeout))
189 {
190 case WAIT_RESULT_SIGNAL: result = STK_WAIT_RESULT_SIGNAL; break;
191 case WAIT_RESULT_TIMEOUT: result = STK_WAIT_RESULT_TIMEOUT; break;
193 default: result = STK_WAIT_RESULT_FAIL; break;
194 }
195
196 return result;
197}
@ WAIT_RESULT_CANCELED
The wait was cancelled by another task via IKernel::CancelTaskWait(), independent of signal/timeout.
Definition stk_common.h:125
@ WAIT_RESULT_TIMEOUT
The wake was caused by a timeout expiry.
Definition stk_common.h:124
@ WAIT_RESULT_SIGNAL
The wake was caused by a signal.
Definition stk_common.h:123
EWaitResult WaitEx(IMutex &mutex, Timeout timeout_ticks=WAIT_INFINITE)
Wait for a signal, preserving the full wait outcome.

References stk_cv_t::handle, stk_mutex_t::handle, STK_ASSERT, STK_WAIT_RESULT_CANCELED, STK_WAIT_RESULT_FAIL, STK_WAIT_RESULT_SIGNAL, STK_WAIT_RESULT_TIMEOUT, stk::WAIT_RESULT_CANCELED, stk::WAIT_RESULT_SIGNAL, stk::WAIT_RESULT_TIMEOUT, and stk::sync::ConditionVariable::WaitEx().

Here is the call graph for this function:

◆ stk_delay()

void stk_delay ( stk_timeout_t ticks)

Busy-wait delay (other tasks continue to run).

Parameters
[in]ticksTicks to delay.
Examples
D:/SVN/private/stk/interop/c/include/stk_c.h.

Definition at line 644 of file stk_c.cpp.

644{ stk::Delay(ticks); }
static void Delay(Timeout tick_count)
Delay calling process by busy-waiting until the deadline expires.
Definition stk_helper.h:575

References stk::Delay().

Here is the call graph for this function:

◆ stk_delay_ms()

void stk_delay_ms ( stk_timeout_t ms)

Busy-wait delay (other tasks continue to run).

Parameters
[in]msMilliseconds to delay.
Examples
D:/SVN/private/stk/interop/c/include/stk_c.h.

Definition at line 646 of file stk_c.cpp.

646{ stk::DelayMs(ms); }
static void DelayMs(Timeout ms)
Delay calling process by busy-waiting until the deadline expires.
Definition stk_helper.h:586

References stk::DelayMs().

Here is the call graph for this function:

◆ stk_ef_clear()

uint32_t stk_ef_clear ( stk_ef_t * ef,
uint32_t flags )

Clear one or more flags.

Atomically clears the specified bits.

Parameters
[in]efEventFlags handle.
[in]flagsBitmask of bits to clear. Must not be 0 and must not have bit 31 set.
Returns
Flags word value before clearing, or STK_EF_ERROR_PARAMETER on invalid input.
Note
ISR-safe.
Examples
D:/SVN/private/stk/interop/c/include/stk_c.h.

Definition at line 415 of file stk_c_sync.cpp.

416{
417 STK_ASSERT(ef != nullptr);
418
419 return ef->handle.Clear(flags);
420}
uint32_t Clear(uint32_t flags)
Clear one or more flags.
EventFlags handle

References stk::sync::EventFlags::Clear(), stk_ef_t::handle, and STK_ASSERT.

Here is the call graph for this function:

◆ stk_ef_create()

stk_ef_t * stk_ef_create ( stk_ef_mem_t *const membuf,
uint32_t initial_flags )

Create an EventFlags object (using provided memory).

Parameters
[in]membufPointer to static memory container.
[in]initial_flagsInitial value of the 32-bit flags word (bits 0..30 only; bit 31 is reserved and must not be set).
Returns
EventFlags handle.
Examples
D:/SVN/private/stk/interop/c/include/stk_c.h.

Definition at line 386 of file stk_c_sync.cpp.

388{
389 STK_ASSERT(membuf != nullptr);
390
391 stk_ef_t *result = nullptr;
392 if (membuf != nullptr)
393 {
394 result = ConstructIn<stk_ef_t>(*membuf, initial_flags);
395 }
396
397 return result;
398}

References stk::ConstructIn(), and STK_ASSERT.

Here is the call graph for this function:

◆ stk_ef_destroy()

void stk_ef_destroy ( stk_ef_t * ef)

Destroy an EventFlags object.

Parameters
[in]efEventFlags handle.
Examples
D:/SVN/private/stk/interop/c/include/stk_c.h.

Definition at line 400 of file stk_c_sync.cpp.

401{
402 if (ef != nullptr)
403 {
404 ef->~stk_ef_t();
405 }
406}

◆ stk_ef_get()

uint32_t stk_ef_get ( stk_ef_t * ef)

Read the current flags word without modifying it.

Parameters
[in]efEventFlags handle.
Returns
Point-in-time snapshot of the 32-bit flags word.
Note
ISR-safe. Never blocks or modifies state.
Examples
D:/SVN/private/stk/interop/c/include/stk_c.h.

Definition at line 422 of file stk_c_sync.cpp.

423{
424 STK_ASSERT(ef != nullptr);
425
426 return ef->handle.Get();
427}
uint32_t Get() const
Read the current flags word without modifying it.

References stk::sync::EventFlags::Get(), stk_ef_t::handle, and STK_ASSERT.

Here is the call graph for this function:

◆ stk_ef_get_instance()

stk::sync::EventFlags * stk_ef_get_instance ( stk_ef_t * ef)

Get the underlying C++ stk::sync::EventFlags object wrapped by a stk_ef_t handle.

Parameters
[in]efEventFlags handle obtained via stk_ef_create().
Returns
Pointer to the wrapped stk::sync::EventFlags instance. Never NULL for a valid handle.
Note
C++ callers only (guarded by __cplusplus); not part of the C ABI.
Examples
D:/SVN/private/stk/interop/c/include/stk_c.h.

Definition at line 443 of file stk_c_sync.cpp.

444{
445 STK_ASSERT(ef != nullptr);
446
447 return &ef->handle;
448}

References stk_ef_t::handle, and STK_ASSERT.

◆ stk_ef_is_error()

bool stk_ef_is_error ( uint32_t result)
inlinestatic

Returns true if a value returned by stk_ef_set(), stk_ef_clear(), stk_ef_wait(), or stk_ef_trywait() is an error sentinel (bit 31 set).

< Mask for testing any error; bit 31 set means error

Examples
D:/SVN/private/stk/interop/c/include/stk_c.h.

Definition at line 1338 of file stk_c.h.

1339{
1340 return ((result & STK_EF_ERROR_MASK) != 0U);
1341}
#define STK_EF_ERROR_MASK
Definition stk_c.h:1333

References STK_EF_ERROR_MASK.

◆ stk_ef_set()

uint32_t stk_ef_set ( stk_ef_t * ef,
uint32_t flags )

Set one or more flags.

Atomically OR-sets the specified bits and wakes all current waiters so each can re-evaluate its own predicate.

Parameters
[in]efEventFlags handle.
[in]flagsBitmask of bits to set. Must not be 0 and must not have bit 31 set.
Returns
Flags word value after setting, or STK_EF_ERROR_PARAMETER on invalid input.
Note
ISR-safe.
Examples
D:/SVN/private/stk/interop/c/include/stk_c.h.

Definition at line 408 of file stk_c_sync.cpp.

409{
410 STK_ASSERT(ef != nullptr);
411
412 return ef->handle.Set(flags);
413}
uint32_t Set(uint32_t flags)
Set one or more flags.

References stk_ef_t::handle, stk::sync::EventFlags::Set(), and STK_ASSERT.

Here is the call graph for this function:

◆ stk_ef_trywait()

uint32_t stk_ef_trywait ( stk_ef_t * ef,
uint32_t flags,
uint32_t options )

Non-blocking flag poll.

Checks immediately whether the flag condition is satisfied. Clears matched bits on success unless STK_EF_OPT_NO_CLEAR is set.

Parameters
[in]efEventFlags handle.
[in]flagsBitmask of flag bits to watch.
[in]optionsSTK_EF_OPT_WAIT_ANY (default) or STK_EF_OPT_WAIT_ALL, optionally OR-ed with STK_EF_OPT_NO_CLEAR.
Returns
Matched flags bitmask on success, or STK_EF_ERROR_TIMEOUT immediately if the condition is not met.
Note
ISR-safe.
Examples
D:/SVN/private/stk/interop/c/include/stk_c.h.

Definition at line 436 of file stk_c_sync.cpp.

437{
438 STK_ASSERT(ef != nullptr);
439
440 return ef->handle.TryWait(flags, options);
441}
uint32_t TryWait(uint32_t flags, uint32_t options=OPT_WAIT_ANY)
Non-blocking flag poll.

References stk_ef_t::handle, STK_ASSERT, and stk::sync::EventFlags::TryWait().

Here is the call graph for this function:

◆ stk_ef_wait()

uint32_t stk_ef_wait ( stk_ef_t * ef,
uint32_t flags,
uint32_t options,
stk_timeout_t timeout )

Wait for one or more flags to be set.

Suspends the calling task until the requested flag condition is satisfied or the timeout expires. On success, matched bits are atomically cleared unless STK_EF_OPT_NO_CLEAR is set in options.

Parameters
[in]efEventFlags handle.
[in]flagsBitmask of flag bits to watch. Must not be 0 and must not have bit 31 set.
[in]optionsCombination of STK_EF_OPT_WAIT_ANY / STK_EF_OPT_WAIT_ALL and optionally STK_EF_OPT_NO_CLEAR.
[in]timeoutMaximum time to wait in OS ticks or STK_WAIT_INFINITE. Use STK_NO_WAIT for a non-blocking poll.
Returns
Bitmask of the matched flags on success, or a STK_EF_ERROR_* sentinel on failure. Always check stk_ef_is_error() before using the return value as a flags mask.
Note
If the predicate becomes satisfied in the same tick that the deadline expires, the wait succeeds and returns the matched flags.
Returns STK_EF_ERROR_CANCELED, not STK_EF_ERROR_TIMEOUT, if the wait was cancelled before either the flag condition was met or the deadline expired.
If OS tick rate is 1 kHz then 1 tick = 1 ms. Use stk_ticks_from_ms() to convert a millisecond value to ticks for best portability across different tick rates.
Warning
ISR-safe only with timeout = STK_NO_WAIT, ISR-unsafe otherwise.
Examples
D:/SVN/private/stk/interop/c/include/stk_c.h.

Definition at line 429 of file stk_c_sync.cpp.

430{
431 STK_ASSERT(ef != nullptr);
432
433 return ef->handle.Wait(flags, options, timeout);
434}
uint32_t Wait(uint32_t flags, uint32_t options=OPT_WAIT_ANY, Timeout timeout_ticks=WAIT_INFINITE)
Wait for one or more flags to be set.

References stk_ef_t::handle, STK_ASSERT, and stk::sync::EventFlags::Wait().

Here is the call graph for this function:

◆ stk_event_create()

stk_event_t * stk_event_create ( stk_event_mem_t *const membuf,
bool manual_reset )

Create an Event (using provided memory).

Parameters
[in]membufPointer to static memory container.
[in]manual_resetTrue for manual-reset, False for auto-reset.
Returns
Event handle.
Examples
D:/SVN/private/stk/interop/c/include/stk_c.h.

Definition at line 231 of file stk_c_sync.cpp.

233{
234 STK_ASSERT(membuf != nullptr);
235
236 stk_event_t *result = nullptr;
237 if (membuf != nullptr)
238 {
239 result = ConstructIn<stk_event_t>(*membuf, manual_reset);
240 }
241
242 return result;
243}

References stk::ConstructIn(), and STK_ASSERT.

Here is the call graph for this function:

◆ stk_event_destroy()

void stk_event_destroy ( stk_event_t * ev)

Destroy an Event.

Parameters
[in]evEvent handle.
Examples
D:/SVN/private/stk/interop/c/include/stk_c.h.

Definition at line 245 of file stk_c_sync.cpp.

246{
247 if (ev != nullptr)
248 {
249 ev->~stk_event_t();
250 }
251}

◆ stk_event_get_instance()

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.

Parameters
[in]evEvent handle obtained via stk_event_create().
Returns
Pointer to the wrapped stk::sync::Event instance. Never NULL for a valid handle.
Note
C++ callers only (guarded by __cplusplus); not part of the C ABI.
Examples
D:/SVN/private/stk/interop/c/include/stk_c.h.

Definition at line 288 of file stk_c_sync.cpp.

289{
290 STK_ASSERT(ev != nullptr);
291
292 return &ev->handle;
293}

References stk_event_t::handle, and STK_ASSERT.

◆ stk_event_pulse()

void stk_event_pulse ( stk_event_t * ev)

Pulse the event (signal then immediately reset).

Parameters
[in]evEvent handle.
Examples
D:/SVN/private/stk/interop/c/include/stk_c.h.

Definition at line 281 of file stk_c_sync.cpp.

282{
283 STK_ASSERT(ev != nullptr);
284
285 ev->handle.Pulse();
286}
void Pulse()
Pulse event: attempt to release waiters and then reset (Win32 PulseEvent() semantics).

References stk_event_t::handle, stk::sync::Event::Pulse(), and STK_ASSERT.

Here is the call graph for this function:

◆ stk_event_reset()

bool stk_event_reset ( stk_event_t * ev)

Reset the event to non-signaled state.

Parameters
[in]evEvent handle.
Returns
true if state was changed from signaled to non-signaled, false if event was already non-signaled.
Examples
D:/SVN/private/stk/interop/c/include/stk_c.h.

Definition at line 274 of file stk_c_sync.cpp.

275{
276 STK_ASSERT(ev != nullptr);
277
278 return ev->handle.Reset();
279}
bool Reset()
Reset event to non-signaled state.

References stk_event_t::handle, stk::sync::Event::Reset(), and STK_ASSERT.

Here is the call graph for this function:

◆ stk_event_set()

bool stk_event_set ( stk_event_t * ev)

Set the event to signaled state.

Parameters
[in]evEvent handle.
Returns
true if state was changed from non-signaled to signaled, false if event was already signaled.
Examples
D:/SVN/private/stk/interop/c/include/stk_c.h.

Definition at line 267 of file stk_c_sync.cpp.

268{
269 STK_ASSERT(ev != nullptr);
270
271 return ev->handle.Set();
272}
bool Set()
Set event to signaled state.

References stk_event_t::handle, stk::sync::Event::Set(), and STK_ASSERT.

Here is the call graph for this function:

◆ stk_event_trywait()

bool stk_event_trywait ( stk_event_t * ev)

Wait for the event to become signaled.

Parameters
[in]evEvent handle.
Returns
True if signaled, False on timeout.
Examples
D:/SVN/private/stk/interop/c/include/stk_c.h.

Definition at line 260 of file stk_c_sync.cpp.

261{
262 STK_ASSERT(ev != nullptr);
263
264 return ev->handle.TryWait();
265}
bool TryWait()
Poll event state without blocking.

References stk_event_t::handle, STK_ASSERT, and stk::sync::Event::TryWait().

Here is the call graph for this function:

◆ stk_event_wait()

bool stk_event_wait ( stk_event_t * ev,
stk_timeout_t timeout )

Wait for the event to become signaled.

Parameters
[in]evEvent handle.
[in]timeoutMaximum time to wait in OS ticks or STK_WAIT_INFINITE.
Returns
True if signaled, False on timeout.
Note
If OS tick rate is 1 kHz then 1 tick = 1 ms. Use stk_ticks_from_ms() to convert a millisecond value to ticks for best portability across different tick rates.
Examples
D:/SVN/private/stk/interop/c/include/stk_c.h.

Definition at line 253 of file stk_c_sync.cpp.

254{
255 STK_ASSERT(ev != nullptr);
256
257 return ev->handle.Wait(timeout);
258}
bool Wait(Timeout timeout_ticks=WAIT_INFINITE)
Wait until event becomes signaled or the timeout expires.

References stk_event_t::handle, STK_ASSERT, and stk::sync::Event::Wait().

Here is the call graph for this function:

◆ stk_hires_cycles()

stk_cycle_t stk_hires_cycles ( void )

Get raw CPU cycle counter.

Returns
64-bit cycle count. Resolution is one clock cycle.
Note
ISR-safe. Use stk_hires_frequency() to convert to real time.
Examples
D:/SVN/private/stk/interop/c/include/stk_c.h.

Definition at line 641 of file stk_c.cpp.

static Cycles GetCycles()
Get number of clock cycles elapsed.

References stk::hw::HiResClock::GetCycles().

Here is the call graph for this function:

◆ stk_hires_frequency()

uint32_t stk_hires_frequency ( void )

Get CPU clock frequency in Hz.

Returns
Clock frequency in Hz.
Note
ISR-safe.
Examples
D:/SVN/private/stk/interop/c/include/stk_c.h.

Definition at line 642 of file stk_c.cpp.

static uint32_t GetFrequency()
Get clock frequency.

References stk::hw::HiResClock::GetFrequency().

Here is the call graph for this function:

◆ stk_hires_time_us()

stk_tick_t stk_hires_time_us ( void )

Get elapsed time in microseconds from the high-resolution clock.

Returns
Microseconds since an arbitrary but fixed epoch (typically reset).
Note
ISR-safe. Equivalent to stk_hires_cycles() * 1000000 / stk_hires_frequency().
Examples
D:/SVN/private/stk/interop/c/include/stk_c.h.

Definition at line 643 of file stk_c.cpp.

static Ticks GetTimeUs()
Get elapsed time in microseconds.
Definition stk_arch.h:692

References stk::hw::HiResClock::GetTimeUs().

Here is the call graph for this function:

◆ stk_kernel_add_task()

void stk_kernel_add_task ( stk_kernel_t * k,
stk_task_t * tsk )

Add task to non-HRT kernel (static or dynamic).

Parameters
[in]kKernel handle.
[in]tskTask handle created with one of stk_task_create_* functions.
Note
For static kernels this must be done before stk_kernel_start().
Examples
D:/SVN/private/stk/interop/c/include/stk_c.h.

Definition at line 428 of file stk_c.cpp.

429{
430 STK_ASSERT(k != nullptr);
431 STK_ASSERT(tsk != nullptr);
432
434}
static IKernel * CastCToKernelInterface(stk_kernel_t *const k)
Definition stk_c.cpp:43
virtual void AddTask(ITask *user_task)=0
Add user task.
TaskWrapper handle
Definition stk_c.cpp:126

References stk::IKernel::AddTask(), CastCToKernelInterface(), stk_task_t::handle, and STK_ASSERT.

Referenced by stk::pthread::EnsureReaper().

Here is the call graph for this function:
Here is the caller graph for this function:

◆ stk_kernel_add_task_hrt()

void 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).

Parameters
[in]kKernel handle.
[in]tskTask handle.
[in]periodicity_ticksPeriod in ticks.
[in]deadline_ticksRelative deadline in ticks.
[in]start_delay_ticksInitial offset / phase in ticks (>= 0).
Note
Must be called after stk_kernel_init() and before stk_kernel_start().
Examples
D:/SVN/private/stk/interop/c/include/stk_c.h.

Definition at line 536 of file stk_c.cpp.

541{
542 STK_ASSERT(k != nullptr);
543 STK_ASSERT(tsk != nullptr);
544
546 &tsk->handle,
547 periodicity_ticks,
548 deadline_ticks,
549 start_delay_ticks);
550}

References stk::IKernel::AddTask(), CastCToKernelInterface(), stk_task_t::handle, and STK_ASSERT.

Here is the call graph for this function:

◆ stk_kernel_create()

stk_kernel_t * stk_kernel_create ( uint8_t core_nr)

Create kernel.

Note
At least STK_C_KERNEL_TYPE_CPU_0 must be defined with the type of the kernel. Place STK_C_KERNEL_TYPE_CPU_X defines inside the stk_config.h file which is per project. STK_C_KERNEL_TYPE_CPU_X type will be assigned to X core.
Parameters
[in]core_nrCPU core number (starts with 0). Max: 7 (for 8 cores).
Examples
D:/SVN/private/stk/interop/c/include/stk_c.h.

Definition at line 331 of file stk_c.cpp.

332{
333 STK_STATIC_ASSERT((STK_C_CPU_COUNT <= 8U)); // switch (core_nr) below handles cases 0..7; STK_C_KERNEL_TYPE_CPU_N is only defined up to N=7
334 STK_ASSERT(core_nr < STK_C_CPU_COUNT);
335
336 IKernel *k;
337
338 switch (core_nr)
339 {
340#ifdef STK_C_KERNEL_TYPE_CPU_0
342#endif
343#ifdef STK_C_KERNEL_TYPE_CPU_1
345#endif
346#ifdef STK_C_KERNEL_TYPE_CPU_2
348#endif
349#ifdef STK_C_KERNEL_TYPE_CPU_3
351#endif
352#ifdef STK_C_KERNEL_TYPE_CPU_4
354#endif
355#ifdef STK_C_KERNEL_TYPE_CPU_5
357#endif
358#ifdef STK_C_KERNEL_TYPE_CPU_6
360#endif
361#ifdef STK_C_KERNEL_TYPE_CPU_7
363#endif
364 default: {
365 k = nullptr;
366 break; }
367 }
368
370}
#define STK_STATIC_ASSERT(X)
Compile-time assertion. Produces a compilation error if X is false.
Definition stk_defs.h:553
static stk_kernel_t * CastCppKernelInterfaceToC(IKernel *const k)
Definition stk_c.cpp:55
#define STK_KERNEL_CASE(X)
Definition stk_c.cpp:318
#define STK_C_CPU_COUNT
Number of kernel instances / CPU cores supported (default: 1).
Definition stk_c.h:65
Interface for the implementation of the kernel of the scheduler. It supports Soft and Hard Real-Time ...

References CastCppKernelInterfaceToC(), STK_ASSERT, STK_C_CPU_COUNT, STK_KERNEL_CASE, and STK_STATIC_ASSERT.

Here is the call graph for this function:

◆ stk_kernel_destroy()

void stk_kernel_destroy ( stk_kernel_t * k)

Destroy dynamic kernel instance (only when not running).

Parameters
[in]kKernel handle.
Note
Kernel must not be running (all tasks must have exited or been removed). Only valid for kernels created with dynamic factory functions.
Examples
D:/SVN/private/stk/interop/c/include/stk_c.h.

Definition at line 385 of file stk_c.cpp.

386{
387 STK_ASSERT(k != nullptr);
388
389 // Detach the event overrider and clear the registry entry BEFORE calling
390 // the destructor: the platform teardown inside ~IKernel() may still invoke
391 // GetPlatform() paths, and we must not leave a dangling overrider pointer
392 // registered at that point.
394}
static void UnregisterKernel(const IKernel *k)
Definition stk_c.cpp:225

References CastCToKernelInterface(), STK_ASSERT, and UnregisterKernel().

Here is the call graph for this function:

◆ stk_kernel_enumerate_tasks()

size_t stk_kernel_enumerate_tasks ( stk_kernel_t * k,
stk_task_t ** tasks,
size_t max_count )

Enumerate all currently active tasks.

Parameters
[in]kKernel handle.
[out]tasksCaller-allocated array of opaque task pointers. Each element is a stk_task_t* that can be passed to other stk_task_* / stk_kernel_* functions.
[in]max_countCapacity of the tasks array (number of elements).
Returns
Number of active tasks written into tasks (0 .. max_count).
Note
ISR-safe.
Examples
D:/SVN/private/stk/interop/c/include/stk_c.h.

Definition at line 477 of file stk_c.cpp.

478{
479 STK_ASSERT(k != nullptr);
480 STK_ASSERT(tasks != nullptr);
481
482 stk::ITask *itasks[STK_C_TASKS_MAX] = {};
483
484 // Determine the safe upper bound for the temporary buffer
485 const size_t requested_size = (max_count < static_cast<size_t>(STK_C_TASKS_MAX)) ? max_count :
486 static_cast<size_t>(STK_C_TASKS_MAX);
487
488 // Pass via ArrayView temporary object
489 const size_t ret_count = CastCToKernelInterface(k)->EnumerateTasks(
490 ArrayView<stk::ITask *>(itasks, requested_size));
491
492 ArrayView<stk_task_t *> output_view(tasks, max_count);
493 for (size_t i = 0U; i < ret_count; ++i)
494 {
495 output_view[i] = CastCppTaskInterfaceToC(itasks[i]);
496 }
497
498 return ret_count;
499}
static stk_task_t * CastCppTaskInterfaceToC(ITask *const t)
Definition stk_c.cpp:140
#define STK_C_TASKS_MAX
Definition stk_c.cpp:37
Lightweight, non-owning view over a contiguous sequence of elements.
Definition stk_common.h:255
Interface for a user task.
Definition stk_common.h:772
virtual size_t EnumerateTasks(ArrayView< ITask * > user_tasks)=0
Enumerate user tasks.

References CastCppTaskInterfaceToC(), CastCToKernelInterface(), stk::IKernel::EnumerateTasks(), STK_ASSERT, and STK_C_TASKS_MAX.

Here is the call graph for this function:

◆ stk_kernel_get_instance()

stk::IKernel * stk_kernel_get_instance ( uint8_t core_nr)

Get the underlying C++ stk::IKernel object for a given core.

Parameters
[in]core_nrCore id (0U = first core, ...). Must be < STK_C_CPU_COUNT.
Returns
Pointer to the stk::IKernel instance registered for core_nr. Never NULL.
Note
C++ callers only (guarded by __cplusplus); not part of the C ABI.
Warning
core_nr must refer to a kernel already created via stk_kernel_create() and not yet destroyed via stk_kernel_destroy(), otherwise this triggers an assertion failure.
Examples
D:/SVN/private/stk/interop/c/include/stk_c.h.

Definition at line 372 of file stk_c.cpp.

373{
374 STK_ASSERT(core_nr < STK_C_CPU_COUNT);
375
376 IKernel *const k = s_KernelMap[core_nr].kernel;
377
378 // Kernel not found: stk_kernel_get_instance() called before
379 // stk_kernel_create() or after stk_kernel_destroy().
380 STK_ASSERT(k != nullptr);
381
382 return k;
383}
static KernelRegistryEntry s_KernelMap[(1)]
Definition stk_c.cpp:216

References s_KernelMap, STK_ASSERT, and STK_C_CPU_COUNT.

◆ stk_kernel_get_state()

stk_kernel_state_t stk_kernel_get_state ( const stk_kernel_t * k)

Get state of the scheduler.

Parameters
[in]kKernel handle.
Returns
State value, see stk_kernel_state_t.
Examples
D:/SVN/private/stk/interop/c/include/stk_c.h.

Definition at line 413 of file stk_c.cpp.

414{
415 STK_ASSERT(k != nullptr);
416
418}
static const IKernel * CastCToKernelInterfaceConst(const stk_kernel_t *const k)
Definition stk_c.cpp:49
virtual EKernelState GetState() const =0
Get a snapshot of the kernel state.

References CastCToKernelInterfaceConst(), stk::IKernel::GetState(), and STK_ASSERT.

Here is the call graph for this function:

◆ stk_kernel_init()

void stk_kernel_init ( stk_kernel_t * k,
uint32_t tick_period_us )

Initialize kernel with given tick period.

Parameters
[in]kKernel handle.
[in]tick_period_usSystem tick period in microseconds (usually 100–10000).
Note
Must be called exactly once before adding tasks or starting scheduler.
Examples
D:/SVN/private/stk/interop/c/include/stk_c.h.

Definition at line 399 of file stk_c.cpp.

400{
401 STK_ASSERT(k != nullptr);
402
403 CastCToKernelInterface(k)->Initialize(tick_period_us);
404}
virtual void Initialize(uint32_t resolution_us=PERIODICITY_DEFAULT)=0
Initialize kernel.

References CastCToKernelInterface(), stk::IKernel::Initialize(), and STK_ASSERT.

Here is the call graph for this function:

◆ stk_kernel_is_schedulable()

bool stk_kernel_is_schedulable ( const stk_kernel_t * k)

Test whether currently configured task set is schedulable.

Parameters
[in]kKernel handle.
Returns
True if task set passes schedulability test, False otherwise.
Note
Only meaningful for HRT RM/DM kernels.
Examples
D:/SVN/private/stk/interop/c/include/stk_c.h.

Definition at line 420 of file stk_c.cpp.

421{
422 STK_ASSERT(k != nullptr);
423
425 const_cast<IKernel *>(CastCToKernelInterfaceConst(k))->GetSwitchStrategy());
426}
static SchedulabilityCheckResult< TTaskCount > IsSchedulableWCRT(const ITaskSwitchStrategy *strategy)
Perform WCRT schedulability analysis on the task set registered with strategy.

References CastCToKernelInterfaceConst(), stk::SchedulabilityCheck::IsSchedulableWCRT(), and STK_ASSERT.

Here is the call graph for this function:

◆ stk_kernel_is_started()

bool stk_kernel_is_started ( const stk_kernel_t * k)

Check whether the scheduler is currently running (first task switch has occurred).

Parameters
[in]kKernel handle.
Returns
True if stk_kernel_start() has been called and the first context switch has occurred, False before stk_kernel_start() or after all tasks have exited.
Examples
D:/SVN/private/stk/interop/c/include/stk_c.h.

Definition at line 444 of file stk_c.cpp.

445{
446 STK_ASSERT(k != nullptr);
447
450}
EKernelState
Kernel state.
@ KSTATE_RUNNING
Initialized and running, IKernel::Start() was called successfully.
@ KSTATE_SUSPENDED
Scheduling is suspended with IKernelService::Suspend().

References CastCToKernelInterfaceConst(), stk::IKernel::GetState(), stk::IKernel::KSTATE_RUNNING, stk::IKernel::KSTATE_SUSPENDED, and STK_ASSERT.

Here is the call graph for this function:

◆ stk_kernel_process_hard_fault()

void stk_kernel_process_hard_fault ( stk_kernel_t * k)

Trigger a kernel hard fault (safe-state handler).

Parameters
[in]kKernel handle.
Note
Normally invoked automatically by the kernel when an HRT task misses its deadline. Exposed here for custom fault handlers or test harnesses that need to force a controlled system halt via the platform driver's fault path.
This call does not return.
Examples
D:/SVN/private/stk/interop/c/include/stk_c.h.

Definition at line 522 of file stk_c.cpp.

523{
524 STK_ASSERT(k != nullptr);
525
527}
virtual void ProcessHardFault()=0
Cause a hard fault of the system.
virtual IPlatform * GetPlatform()=0
Get platform driver instance.

References CastCToKernelInterface(), stk::IKernel::GetPlatform(), stk::IPlatform::ProcessHardFault(), and STK_ASSERT.

Here is the call graph for this function:

◆ stk_kernel_process_tick()

void stk_kernel_process_tick ( stk_kernel_t * k)

Manually deliver one scheduler tick to the kernel.

Parameters
[in]kKernel handle.
Note
Use this when the platform driver's built-in SysTick handler is disabled (STK_SYSTICK_HANDLER = _STK_SYSTICK_HANDLER_DISABLE in stk_config.h) and the application provides its own tick source. Call from your custom tick ISR at the rate matching the tick period configured in stk_kernel_init().
ISR-safe.
Examples
D:/SVN/private/stk/interop/c/include/stk_c.h.

Definition at line 515 of file stk_c.cpp.

516{
517 STK_ASSERT(k != nullptr);
518
520}
virtual void ProcessTick()=0
Process one tick.

References CastCToKernelInterface(), stk::IKernel::GetPlatform(), stk::IPlatform::ProcessTick(), and STK_ASSERT.

Here is the call graph for this function:

◆ stk_kernel_remove_task()

void stk_kernel_remove_task ( stk_kernel_t * k,
stk_task_t * tsk )

Remove finished task from dynamic kernel.

Parameters
[in]kKernel handle.
[in]tskTask that has already returned from its entry function.
Note
Only valid in dynamic kernels. Task must have exited (returned from entry function).
Examples
D:/SVN/private/stk/interop/c/include/stk_c.h.

Definition at line 436 of file stk_c.cpp.

437{
438 STK_ASSERT(k != nullptr);
439 STK_ASSERT(tsk != nullptr);
440
442}
virtual void RemoveTask(ITask *user_task)=0
Remove a previously added task from the kernel when it is not started.

References CastCToKernelInterface(), stk_task_t::handle, stk::IKernel::RemoveTask(), and STK_ASSERT.

Here is the call graph for this function:

◆ stk_kernel_resume()

void stk_kernel_resume ( stk_kernel_t * k,
stk_timeout_t elapsed_ticks )

Resume scheduling after a prior stk_kernel_suspend() call.

Parameters
[in]kKernel handle.
[in]elapsed_ticksNumber of ticks that elapsed during the suspended period. The kernel uses this value to advance internal time counters and wake tasks whose sleep deadlines have expired.
Note
ISR-safe.
See also
stk_kernel_suspend
Examples
D:/SVN/private/stk/interop/c/include/stk_c.h.

Definition at line 508 of file stk_c.cpp.

509{
510 STK_ASSERT(k != nullptr);
511
512 CastCToKernelInterface(k)->GetPlatform()->Resume(static_cast<stk::Timeout>(elapsed_ticks));
513}
int32_t Timeout
Timeout time (ticks).
Definition stk_common.h:154
virtual void Resume(Timeout elapsed_ticks)=0
Resume scheduling after a prior Suspend() call.

References CastCToKernelInterface(), stk::IKernel::GetPlatform(), stk::IPlatform::Resume(), and STK_ASSERT.

Here is the call graph for this function:

◆ stk_kernel_resume_task()

void stk_kernel_resume_task ( stk_kernel_t * k,
stk_task_t * task )

Resume a previously suspended task.

Parameters
[in]kKernel handle.
[in]taskTask to resume. Must have been suspended with stk_kernel_suspend_task().
Examples
D:/SVN/private/stk/interop/c/include/stk_c.h.

Definition at line 469 of file stk_c.cpp.

470{
471 STK_ASSERT(k != nullptr);
472 STK_ASSERT(tsk != nullptr);
473
474 CastCToKernelInterface(k)->ResumeTask(&tsk->handle);
475}
virtual void ResumeTask(ITask *user_task)=0
Resume task.

References CastCToKernelInterface(), stk_task_t::handle, stk::IKernel::ResumeTask(), and STK_ASSERT.

Here is the call graph for this function:

◆ stk_kernel_schedule_task_removal()

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.

Parameters
[in]kKernel handle.
[in]taskTask to remove. Must be currently scheduled.
Note
KERNEL_DYNAMIC only. The task is removed on the next scheduling tick and its OnExit() callback is invoked automatically.
To remove a task before stk_kernel_start(), use stk_kernel_remove_task() instead.
See also
stk_kernel_remove_task
Examples
D:/SVN/private/stk/interop/c/include/stk_c.h.

Definition at line 452 of file stk_c.cpp.

453{
454 STK_ASSERT(k != nullptr);
455 STK_ASSERT(tsk != nullptr);
456
458}
virtual void ScheduleTaskRemoval(ITask *user_task)=0
Schedule task removal from scheduling (exit).

References CastCToKernelInterface(), stk_task_t::handle, stk::IKernel::ScheduleTaskRemoval(), and STK_ASSERT.

Here is the call graph for this function:

◆ stk_kernel_set_event_overrider()

void stk_kernel_set_event_overrider ( stk_kernel_t * k,
stk_event_overrider_t * overrider )

Install a platform event overrider on the kernel.

Forwards to IPlatform::SetEventOverrider() via an internal C++ bridge object. Any previously installed overrider is replaced.

Parameters
[in]kKernel handle obtained from stk_kernel_create().
[in]overriderPointer to a caller-owned stk_event_overrider_t. Pass NULL to remove a previously installed overrider. When non-NULL, the struct must remain valid for the entire lifetime of the kernel (static or global storage is recommended).
Note
Must be called after stk_kernel_init() and before stk_kernel_start().
Not ISR-safe.
See also
stk_event_overrider_t
Examples
D:/SVN/private/stk/interop/c/include/stk_c.h.

Definition at line 529 of file stk_c.cpp.

530{
531 STK_ASSERT(k != nullptr);
532
534}
static void SetEventOverrider(IKernel *k, stk_event_overrider_t *overrider)
Definition stk_c.cpp:238

References CastCToKernelInterface(), SetEventOverrider(), and STK_ASSERT.

Here is the call graph for this function:

◆ stk_kernel_start()

void stk_kernel_start ( stk_kernel_t * k)

Start the scheduler - never returns.

Parameters
[in]kKernel handle.
Note
Transfers control to the scheduler and a first ready task. May return if all tasks are finished and kernel is dynamic.
Examples
D:/SVN/private/stk/interop/c/include/stk_c.h.

Definition at line 406 of file stk_c.cpp.

407{
408 STK_ASSERT(k != nullptr);
409
411}
virtual void Start()=0
Start kernel scheduling.

References CastCToKernelInterface(), stk::IKernel::Start(), and STK_ASSERT.

Here is the call graph for this function:

◆ stk_kernel_suspend()

stk_timeout_t stk_kernel_suspend ( stk_kernel_t * k)

Suspend scheduling (tickless idle entry point).

Parameters
[in]kKernel handle.
Returns
Number of ticks available for the suspension period, determined by the nearest pending wake-up deadline across all sleeping tasks. The caller may program a hardware timer with this value to suppress SysTick wakeups.
Note
ISR-safe. Pair every call with stk_kernel_resume().
Only meaningful when the kernel was created with KERNEL_TICKLESS mode.
See also
stk_kernel_resume, STK_KERNEL_STATE_SUSPENDED
Examples
D:/SVN/private/stk/interop/c/include/stk_c.h.

Definition at line 501 of file stk_c.cpp.

502{
503 STK_ASSERT(k != nullptr);
504
505 return static_cast<stk_timeout_t>(CastCToKernelInterface(k)->GetPlatform()->Suspend());
506}
int32_t stk_timeout_t
Timeout value.
Definition stk_c.h:118
virtual Timeout Suspend()=0
Suspend scheduling.

References CastCToKernelInterface(), stk::IKernel::GetPlatform(), STK_ASSERT, and stk::IPlatform::Suspend().

Here is the call graph for this function:

◆ stk_kernel_suspend_task()

void stk_kernel_suspend_task ( stk_kernel_t * k,
stk_task_t * task,
bool * suspended )

Suspend a task (prevent it from being scheduled).

Parameters
[in]kKernel handle.
[in]taskTask to suspend.
[out]suspendedSet to true if the task was successfully suspended (was awake), false if the task was already sleeping (e.g. blocked on a mutex or timed Sleep).
Note
Do not hold a critical section when suspending the calling task - this will deadlock.
If the task suspends itself, the call blocks until the kernel switches it out.
Examples
D:/SVN/private/stk/interop/c/include/stk_c.h.

Definition at line 460 of file stk_c.cpp.

461{
462 STK_ASSERT(k != nullptr);
463 STK_ASSERT(tsk != nullptr);
464 STK_ASSERT(suspended != nullptr);
465
466 CastCToKernelInterface(k)->SuspendTask(&tsk->handle, *suspended);
467}
virtual void SuspendTask(ITask *user_task, bool &suspended)=0
Suspend task.

References CastCToKernelInterface(), stk_task_t::handle, STK_ASSERT, and stk::IKernel::SuspendTask().

Here is the call graph for this function:

◆ stk_ms_from_ticks()

stk_time_t stk_ms_from_ticks ( stk_tick_t ticks)
inlinestatic

Convert ticks to milliseconds using the current kernel tick resolution.

Parameters
[in]ticksTick count to convert.
Returns
Equivalent time in milliseconds.
Note
Requires the kernel to be initialized before calling.
Examples
D:/SVN/private/stk/interop/c/include/stk_c.h.

Definition at line 715 of file stk_c.h.

716{
718}
uint32_t stk_tick_resolution(void)
Returns how many microseconds correspond to one kernel tick.
Definition stk_c.cpp:635
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.
Definition stk_c.h:704

References stk_ms_from_ticks_r(), and stk_tick_resolution().

Here is the call graph for this function:

◆ stk_ms_from_ticks_r()

stk_time_t stk_ms_from_ticks_r ( stk_tick_t ticks,
uint32_t resolution )
inlinestatic

Convert ticks to milliseconds using an explicit tick resolution.

Parameters
[in]ticksTick count to convert.
[in]resolutionMicroseconds per tick (see stk_tick_resolution()).
Returns
Equivalent time in milliseconds.
Note
ISR-safe (arithmetic only).
Examples
D:/SVN/private/stk/interop/c/include/stk_c.h.

Definition at line 704 of file stk_c.h.

705{
706 const stk_tick_t total_ticks = ticks * STK_STATIC_CAST(stk_tick_t, resolution);
707 return STK_STATIC_CAST(stk_time_t, total_ticks / 1000LL);
708}
#define STK_STATIC_CAST(type, val)
Convenience wrapper for static_cast and C-style cast.
Definition stk_c.h:88
int64_t stk_tick_t
Ticks value.
Definition stk_c.h:108
int64_t stk_time_t
Time value.
Definition stk_c.h:113

References STK_STATIC_CAST.

Referenced by stk_ms_from_ticks().

Here is the caller graph for this function:

◆ stk_msgq_create()

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).

Constructs a stk::sync::MessageQueue in-place inside membuf. The queue will hold up to capacity messages, each msg_size bytes wide. The backing storage for messages must be supplied by the caller via buf / buf_size.

Parameters
[in]membufPointer to static memory container for the queue object.
[in]bufPointer to the message data buffer. Must be at least capacity * msg_size bytes.
[in]buf_sizeSize of buf in bytes (used only for the safety assertion; must equal capacity * msg_size).
[in]capacityMaximum number of messages [1, 65534].
[in]msg_sizeSize of each individual message in bytes (>= 1).
Returns
MessageQueue handle, or NULL if any size assertion fails.
Note
Convenience macro STK_MSGQ_BUF_SIZE(capacity, msg_size) computes the required buf_size.
Only available when kernel is compiled with KERNEL_SYNC mode enabled.
Examples
D:/SVN/private/stk/interop/c/include/stk_c.h.

Definition at line 644 of file stk_c_sync.cpp.

649{
650 STK_ASSERT(membuf != nullptr);
651 STK_ASSERT(buf != nullptr);
652 STK_ASSERT(capacity >= 1U);
653 STK_ASSERT(msg_size >= 1U);
654 STK_ASSERT(buf_size >= capacity * msg_size);
655
656 stk_msgq_t *result = nullptr;
657 if ((membuf != nullptr) && (buf_size >= (capacity * msg_size)))
658 {
659 result = ConstructIn<stk_msgq_t>(*membuf, buf, capacity, msg_size);
660 }
661
662 return result;
663}

References stk::ConstructIn(), and STK_ASSERT.

Here is the call graph for this function:

◆ stk_msgq_destroy()

void stk_msgq_destroy ( stk_msgq_t * mq)

Destroy a MessageQueue.

Parameters
[in]mqMessageQueue handle.
Note
Any tasks still blocked on Put/Get at destruction time are considered a logic error; an assertion is triggered in debug builds.
Examples
D:/SVN/private/stk/interop/c/include/stk_c.h.

Definition at line 665 of file stk_c_sync.cpp.

666{
667 if (mq != nullptr)
668 {
669 mq->~stk_msgq_t();
670 }
671}

◆ stk_msgq_get()

bool stk_msgq_get ( stk_msgq_t * mq,
void * msg,
stk_timeout_t timeout )

Get a message from the queue.

Copies the oldest message into msg. Blocks if the queue is empty until a message arrives or the timeout expires.

Parameters
[in]mqMessageQueue handle.
[out]msgDestination buffer (must be >= msg_size bytes).
[in]timeoutMaximum time to wait in OS ticks or STK_WAIT_INFINITE. Use STK_NO_WAIT for a non-blocking attempt.
Returns
True if a message was retrieved, False on timeout.
Note
If OS tick rate is 1 kHz then 1 tick = 1 ms. Use stk_ticks_from_ms() to convert a millisecond value to ticks for best portability across different tick rates.
Warning
ISR-safe only with timeout = STK_NO_WAIT.
Examples
D:/SVN/private/stk/interop/c/include/stk_c.h.

Definition at line 705 of file stk_c_sync.cpp.

706{
707 STK_ASSERT(mq != nullptr);
708 STK_ASSERT(msg != nullptr);
709
710 return mq->handle.Get(msg, timeout);
711}
bool Get(void *msg_ptr, Timeout timeout_ticks=WAIT_INFINITE)
Get a message from the queue.
MessageQueue handle

References stk::sync::MessageQueue::Get(), stk_msgq_t::handle, and STK_ASSERT.

Here is the call graph for this function:

◆ stk_msgq_get_buffer()

uint8_t * stk_msgq_get_buffer ( stk_msgq_t * mq)

Get a pointer to the raw message data buffer.

Parameters
[in]mqMessageQueue handle.
Returns
Pointer to the beginning of the backing byte buffer supplied at construction time.
Note
ISR-safe.
Examples
D:/SVN/private/stk/interop/c/include/stk_c.h.

Definition at line 802 of file stk_c_sync.cpp.

803{
804 STK_ASSERT(mq != nullptr);
805
806 return mq->handle.GetBuffer();
807}
uint8_t * GetBuffer()
Get pointer to the message buffer.

References stk::sync::MessageQueue::GetBuffer(), stk_msgq_t::handle, and STK_ASSERT.

Here is the call graph for this function:

◆ stk_msgq_get_capacity()

size_t stk_msgq_get_capacity ( const stk_msgq_t * mq)

Get the maximum number of messages the queue can hold.

Parameters
[in]mqMessageQueue handle.
Returns
Construction-time capacity.
Note
ISR-safe.
Examples
D:/SVN/private/stk/interop/c/include/stk_c.h.

Definition at line 760 of file stk_c_sync.cpp.

761{
762 STK_ASSERT(mq != nullptr);
763
764 return mq->handle.GetCapacity();
765}
size_t GetCapacity() const
Get the maximum number of messages the queue can hold.

References stk::sync::MessageQueue::GetCapacity(), stk_msgq_t::handle, and STK_ASSERT.

Here is the call graph for this function:

◆ stk_msgq_get_count()

size_t stk_msgq_get_count ( const stk_msgq_t * mq)

Get the current number of messages waiting in the queue.

Parameters
[in]mqMessageQueue handle.
Returns
Point-in-time snapshot of the message count.
Note
ISR-safe on targets where a size_t-aligned read is atomic.
Examples
D:/SVN/private/stk/interop/c/include/stk_c.h.

Definition at line 774 of file stk_c_sync.cpp.

775{
776 STK_ASSERT(mq != nullptr);
777
778 return mq->handle.GetCount();
779}
size_t GetCount() const
Get the current number of messages in the queue.

References stk::sync::MessageQueue::GetCount(), stk_msgq_t::handle, and STK_ASSERT.

Here is the call graph for this function:

◆ stk_msgq_get_instance()

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.

Parameters
[in]mqMessageQueue handle obtained via stk_msgq_create().
Returns
Pointer to the wrapped stk::sync::MessageQueue instance. Never NULL for a valid handle.
Note
C++ callers only (guarded by __cplusplus); not part of the C ABI.
Examples
D:/SVN/private/stk/interop/c/include/stk_c.h.

Definition at line 816 of file stk_c_sync.cpp.

817{
818 STK_ASSERT(mq != nullptr);
819
820 return &mq->handle;
821}

References stk_msgq_t::handle, and STK_ASSERT.

◆ stk_msgq_get_msg_size()

size_t stk_msgq_get_msg_size ( const stk_msgq_t * mq)

Get the size of each message in bytes.

Parameters
[in]mqMessageQueue handle.
Returns
Construction-time message size.
Note
ISR-safe.
Examples
D:/SVN/private/stk/interop/c/include/stk_c.h.

Definition at line 767 of file stk_c_sync.cpp.

768{
769 STK_ASSERT(mq != nullptr);
770
771 return mq->handle.GetMsgSize();
772}
size_t GetMsgSize() const
Get the size of each message in bytes.

References stk::sync::MessageQueue::GetMsgSize(), stk_msgq_t::handle, and STK_ASSERT.

Here is the call graph for this function:

◆ stk_msgq_get_space()

size_t stk_msgq_get_space ( const stk_msgq_t * mq)

Get the number of free slots currently available.

Parameters
[in]mqMessageQueue handle.
Returns
Point-in-time snapshot of the free-slot count.
Note
ISR-safe.
Examples
D:/SVN/private/stk/interop/c/include/stk_c.h.

Definition at line 781 of file stk_c_sync.cpp.

782{
783 STK_ASSERT(mq != nullptr);
784
785 return mq->handle.GetSpace();
786}
size_t GetSpace() const
Get the number of free slots currently available.

References stk::sync::MessageQueue::GetSpace(), stk_msgq_t::handle, and STK_ASSERT.

Here is the call graph for this function:

◆ stk_msgq_is_empty()

bool stk_msgq_is_empty ( const stk_msgq_t * mq)

Check whether the queue is currently empty.

Parameters
[in]mqMessageQueue handle.
Returns
True if the queue contains no messages.
Note
ISR-safe.
Examples
D:/SVN/private/stk/interop/c/include/stk_c.h.

Definition at line 788 of file stk_c_sync.cpp.

789{
790 STK_ASSERT(mq != nullptr);
791
792 return mq->handle.IsEmpty();
793}
bool IsEmpty() const
Check whether the queue is currently empty.

References stk_msgq_t::handle, stk::sync::MessageQueue::IsEmpty(), and STK_ASSERT.

Here is the call graph for this function:

◆ stk_msgq_is_full()

bool stk_msgq_is_full ( const stk_msgq_t * mq)

Check whether the queue is currently full.

Parameters
[in]mqMessageQueue handle.
Returns
True if the queue contains capacity messages.
Note
ISR-safe.
Examples
D:/SVN/private/stk/interop/c/include/stk_c.h.

Definition at line 795 of file stk_c_sync.cpp.

796{
797 STK_ASSERT(mq != nullptr);
798
799 return mq->handle.IsFull();
800}
bool IsFull() const
Check whether the queue is currently full.

References stk_msgq_t::handle, stk::sync::MessageQueue::IsFull(), and STK_ASSERT.

Here is the call graph for this function:

◆ stk_msgq_is_storage_valid()

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.

Always true for queues constructed with a non-NULL buffer. Useful as a post-construction sanity check in no-exceptions environments; stk_msgq_create() returning NULL already covers the primary failure path.

Parameters
[in]mqMessageQueue handle.
Returns
True if the queue is ready for use.
Note
ISR-safe.
Examples
D:/SVN/private/stk/interop/c/include/stk_c.h.

Definition at line 809 of file stk_c_sync.cpp.

810{
811 STK_ASSERT(mq != nullptr);
812
813 return mq->handle.IsStorageValid();
814}
bool IsStorageValid() const
Verify that the backing storage is valid and the pool is ready for use.

References stk_msgq_t::handle, stk::sync::MessageQueue::IsStorageValid(), and STK_ASSERT.

Here is the call graph for this function:

◆ stk_msgq_peek()

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.

Copies msg_size bytes from the oldest slot into msg, leaving the message in place so that a subsequent stk_msgq_get() returns the same message. Blocks if the queue is empty until a message is available or the timeout expires.

Parameters
[in]mqMessageQueue handle.
[out]msgDestination buffer (must be >= msg_size bytes).
[in]timeoutMaximum time to wait in OS ticks or STK_WAIT_INFINITE. Use STK_NO_WAIT for a non-blocking attempt.
Returns
True if a message was peeked, False on timeout.
Note
If OS tick rate is 1 kHz then 1 tick = 1 ms. Use stk_ticks_from_ms() to convert a millisecond value to ticks for best portability across different tick rates.
Warning
ISR-safe only with timeout = STK_NO_WAIT.
Examples
D:/SVN/private/stk/interop/c/include/stk_c.h.

Definition at line 721 of file stk_c_sync.cpp.

722{
723 STK_ASSERT(mq != nullptr);
724 STK_ASSERT(msg != nullptr);
725
726 return mq->handle.Peek(msg, timeout);
727}
bool Peek(void *msg_ptr, Timeout timeout_ticks=WAIT_INFINITE)
Peek at the next message to be delivered (back of the FIFO) without removing it.

References stk_msgq_t::handle, stk::sync::MessageQueue::Peek(), and STK_ASSERT.

Here is the call graph for this function:

◆ stk_msgq_peekfront()

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.

Copies msg_size bytes from the front slot (i.e. the message that stk_msgq_putfront() most recently placed) into msg, leaving the message in the queue. Blocks if the queue is empty until a message is available or the timeout expires.

Parameters
[in]mqMessageQueue handle.
[out]msgDestination buffer (must be >= msg_size bytes).
[in]timeoutMaximum time to wait in OS ticks or STK_WAIT_INFINITE. Use STK_NO_WAIT for a non-blocking attempt.
Returns
True if a message was peeked, False on timeout.
Note
If OS tick rate is 1 kHz then 1 tick = 1 ms. Use stk_ticks_from_ms() to convert a millisecond value to ticks for best portability across different tick rates.
Warning
ISR-safe only with timeout = STK_NO_WAIT.
Examples
D:/SVN/private/stk/interop/c/include/stk_c.h.

Definition at line 737 of file stk_c_sync.cpp.

738{
739 STK_ASSERT(mq != nullptr);
740 STK_ASSERT(msg != nullptr);
741
742 return mq->handle.PeekFront(msg, timeout);
743}
bool PeekFront(void *msg_ptr, Timeout timeout_ticks=WAIT_INFINITE)
Peek at the most recently front-inserted message (front of the FIFO) without removing it.

References stk_msgq_t::handle, stk::sync::MessageQueue::PeekFront(), and STK_ASSERT.

Here is the call graph for this function:

◆ stk_msgq_put()

bool stk_msgq_put ( stk_msgq_t * mq,
const void * msg,
stk_timeout_t timeout )

Put a message into the queue.

Copies msg_size bytes from msg into the next available slot. Blocks if the queue is full until space becomes available or the timeout expires.

Parameters
[in]mqMessageQueue handle.
[in]msgPointer to the message payload (must be >= msg_size bytes).
[in]timeoutMaximum time to wait in OS ticks or STK_WAIT_INFINITE. Use STK_NO_WAIT for a non-blocking attempt.
Returns
True if the message was enqueued, False on timeout.
Note
If OS tick rate is 1 kHz then 1 tick = 1 ms. Use stk_ticks_from_ms() to convert a millisecond value to ticks for best portability across different tick rates.
Warning
ISR-safe only with timeout = STK_NO_WAIT.
Examples
D:/SVN/private/stk/interop/c/include/stk_c.h.

Definition at line 673 of file stk_c_sync.cpp.

674{
675 STK_ASSERT(mq != nullptr);
676 STK_ASSERT(msg != nullptr);
677
678 return mq->handle.Put(msg, timeout);
679}
bool Put(const void *msg_ptr, Timeout timeout_ticks=WAIT_INFINITE)
Put a message into the back of the queue (FIFO order).

References stk_msgq_t::handle, stk::sync::MessageQueue::Put(), and STK_ASSERT.

Here is the call graph for this function:

◆ stk_msgq_putfront()

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).

Copies msg_size bytes from msg into the slot immediately before the current read pointer, making it the next message that stk_msgq_get() will return. Blocks if the queue is full until space becomes available or the timeout expires.

Parameters
[in]mqMessageQueue handle.
[in]msgPointer to the message payload (must be >= msg_size bytes).
[in]timeoutMaximum time to wait in OS ticks or STK_WAIT_INFINITE. Use STK_NO_WAIT for a non-blocking attempt.
Returns
True if the message was enqueued at the front, False on timeout.
Note
If OS tick rate is 1 kHz then 1 tick = 1 ms. Use stk_ticks_from_ms() to convert a millisecond value to ticks for best portability across different tick rates.
Warning
ISR-safe only with timeout = STK_NO_WAIT.
Examples
D:/SVN/private/stk/interop/c/include/stk_c.h.

Definition at line 689 of file stk_c_sync.cpp.

690{
691 STK_ASSERT(mq != nullptr);
692 STK_ASSERT(msg != nullptr);
693
694 return mq->handle.PutFront(msg, timeout);
695}
bool PutFront(const void *msg_ptr, Timeout timeout_ticks=WAIT_INFINITE)
Put a message into the front of the queue (LIFO / priority-insert order).

References stk_msgq_t::handle, stk::sync::MessageQueue::PutFront(), and STK_ASSERT.

Here is the call graph for this function:

◆ stk_msgq_reset()

void stk_msgq_reset ( stk_msgq_t * mq)

Discard all messages and reset the queue to the empty state.

Tasks blocked in Put() are woken so they can re-enqueue into the now-empty queue.

Parameters
[in]mqMessageQueue handle.
Warning
Messages that were in the queue are silently discarded.
ISR-safe.
Examples
D:/SVN/private/stk/interop/c/include/stk_c.h.

Definition at line 753 of file stk_c_sync.cpp.

754{
755 STK_ASSERT(mq != nullptr);
756
757 mq->handle.Reset();
758}
void Reset()
Discard all messages and reset the queue to the empty state.

References stk_msgq_t::handle, stk::sync::MessageQueue::Reset(), and STK_ASSERT.

Here is the call graph for this function:

◆ stk_msgq_tryget()

bool stk_msgq_tryget ( stk_msgq_t * mq,
void * msg )

Attempt to get a message from the queue without blocking.

Parameters
[in]mqMessageQueue handle.
[out]msgDestination buffer.
Returns
True if a message was retrieved, False if the queue was empty.
Warning
ISR-safe.
Examples
D:/SVN/private/stk/interop/c/include/stk_c.h.

Definition at line 713 of file stk_c_sync.cpp.

714{
715 STK_ASSERT(mq != nullptr);
716 STK_ASSERT(msg != nullptr);
717
718 return mq->handle.TryGet(msg);
719}
bool TryGet(void *msg_ptr)
Attempt to get a message from the queue without blocking.

References stk_msgq_t::handle, STK_ASSERT, and stk::sync::MessageQueue::TryGet().

Here is the call graph for this function:

◆ stk_msgq_trypeek()

bool stk_msgq_trypeek ( stk_msgq_t * mq,
void * msg )

Attempt to peek at the next message without blocking.

Parameters
[in]mqMessageQueue handle.
[out]msgDestination buffer (must be >= msg_size bytes).
Returns
True if a message was peeked, False if the queue was empty.
Warning
ISR-safe.
Examples
D:/SVN/private/stk/interop/c/include/stk_c.h.

Definition at line 729 of file stk_c_sync.cpp.

730{
731 STK_ASSERT(mq != nullptr);
732 STK_ASSERT(msg != nullptr);
733
734 return mq->handle.TryPeek(msg);
735}
bool TryPeek(void *msg_ptr)
Attempt to peek at the next message without blocking.

References stk_msgq_t::handle, STK_ASSERT, and stk::sync::MessageQueue::TryPeek().

Here is the call graph for this function:

◆ stk_msgq_trypeekfront()

bool stk_msgq_trypeekfront ( stk_msgq_t * mq,
void * msg )

Attempt to peek at the front message without blocking.

Parameters
[in]mqMessageQueue handle.
[out]msgDestination buffer (must be >= msg_size bytes).
Returns
True if a message was peeked, False if the queue was empty.
Warning
ISR-safe.
Examples
D:/SVN/private/stk/interop/c/include/stk_c.h.

Definition at line 745 of file stk_c_sync.cpp.

746{
747 STK_ASSERT(mq != nullptr);
748 STK_ASSERT(msg != nullptr);
749
750 return mq->handle.TryPeekFront(msg);
751}
bool TryPeekFront(void *msg_ptr)
Attempt to peek at the front message without blocking.

References stk_msgq_t::handle, STK_ASSERT, and stk::sync::MessageQueue::TryPeekFront().

Here is the call graph for this function:

◆ stk_msgq_tryput()

bool stk_msgq_tryput ( stk_msgq_t * mq,
const void * msg )

Attempt to put a message into the queue without blocking.

Parameters
[in]mqMessageQueue handle.
[in]msgPointer to the message payload.
Returns
True if enqueued, False if the queue was full.
Warning
ISR-safe.
Examples
D:/SVN/private/stk/interop/c/include/stk_c.h.

Definition at line 681 of file stk_c_sync.cpp.

682{
683 STK_ASSERT(mq != nullptr);
684 STK_ASSERT(msg != nullptr);
685
686 return mq->handle.TryPut(msg);
687}
bool TryPut(const void *msg_ptr)
Attempt to put a message into the back of the queue without blocking.

References stk_msgq_t::handle, STK_ASSERT, and stk::sync::MessageQueue::TryPut().

Here is the call graph for this function:

◆ stk_msgq_tryputfront()

bool stk_msgq_tryputfront ( stk_msgq_t * mq,
const void * msg )

Attempt to put a message into the front of the queue without blocking.

Parameters
[in]mqMessageQueue handle.
[in]msgPointer to the message payload.
Returns
True if enqueued at the front, False if the queue was full.
Warning
ISR-safe.
Examples
D:/SVN/private/stk/interop/c/include/stk_c.h.

Definition at line 697 of file stk_c_sync.cpp.

698{
699 STK_ASSERT(mq != nullptr);
700 STK_ASSERT(msg != nullptr);
701
702 return mq->handle.TryPutFront(msg);
703}
bool TryPutFront(const void *msg_ptr)
Attempt to put a message into the front of the queue without blocking.

References stk_msgq_t::handle, STK_ASSERT, and stk::sync::MessageQueue::TryPutFront().

Here is the call graph for this function:

◆ stk_mutex_create()

stk_mutex_t * stk_mutex_create ( stk_mutex_mem_t *const membuf)

Create a Mutex (using provided memory).

Parameters
[in]membufPointer to static memory container.
Returns
Mutex handle.
Examples
D:/SVN/private/stk/interop/c/include/stk_c.h.

Definition at line 34 of file stk_c_sync.cpp.

35{
36 STK_ASSERT(membuf != nullptr);
37
38 stk_mutex_t *result = nullptr;
39 if (membuf != nullptr)
40 {
41 result = ConstructIn<stk_mutex_t>(*membuf);
42 }
43
44 return result;
45}

References stk::ConstructIn(), and STK_ASSERT.

Here is the call graph for this function:

◆ stk_mutex_destroy()

void stk_mutex_destroy ( stk_mutex_t * mtx)

Destroy a Mutex.

Parameters
[in]mtxMutex handle.
Examples
D:/SVN/private/stk/interop/c/include/stk_c.h.

Definition at line 47 of file stk_c_sync.cpp.

48{
49 if (mtx != nullptr)
50 {
51 mtx->~stk_mutex_t();
52 }
53}

◆ stk_mutex_get_instance()

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.

Parameters
[in]mtxMutex handle obtained via stk_mutex_create().
Returns
Pointer to the wrapped stk::sync::Mutex instance. Never NULL for a valid handle.
Note
C++ callers only (guarded by __cplusplus); not part of the C ABI.
Examples
D:/SVN/private/stk/interop/c/include/stk_c.h.

Definition at line 83 of file stk_c_sync.cpp.

84{
85 STK_ASSERT(mtx != nullptr);
86
87 return &mtx->handle;
88}

References stk_mutex_t::handle, and STK_ASSERT.

◆ stk_mutex_lock()

void stk_mutex_lock ( stk_mutex_t * mtx)

Lock the mutex. Blocks until available.

Parameters
[in]mtxMutex handle.
Examples
D:/SVN/private/stk/interop/c/include/stk_c.h.

Definition at line 55 of file stk_c_sync.cpp.

56{
57 STK_ASSERT(mtx != nullptr);
58
59 mtx->handle.Lock();
60}
void Lock() override
Acquire lock.

References stk_mutex_t::handle, stk::sync::Mutex::Lock(), and STK_ASSERT.

Here is the call graph for this function:

◆ stk_mutex_timed_lock()

bool stk_mutex_timed_lock ( stk_mutex_t * mtx,
stk_timeout_t timeout )

Try to lock the mutex with a timeout.

Parameters
[in]mtxMutex handle.
[in]timeoutMaximum time to wait in OS ticks or STK_WAIT_INFINITE.
Returns
True if locked successfully, False on timeout.
Note
If OS tick rate is 1 kHz then 1 tick = 1 ms. Use stk_ticks_from_ms() to convert a millisecond value to ticks for best portability across different tick rates.
Examples
D:/SVN/private/stk/interop/c/include/stk_c.h.

Definition at line 76 of file stk_c_sync.cpp.

77{
78 STK_ASSERT(mtx != nullptr);
79
80 return mtx->handle.TimedLock(timeout);
81}
bool TimedLock(Timeout timeout_ticks)
Acquire lock.

References stk_mutex_t::handle, STK_ASSERT, and stk::sync::Mutex::TimedLock().

Here is the call graph for this function:

◆ stk_mutex_trylock()

bool stk_mutex_trylock ( stk_mutex_t * mtx)

Try locking the mutex. Does not block if already locked.

Parameters
[in]mtxMutex handle.
Returns
True if locked successfully, False on timeout.
Examples
D:/SVN/private/stk/interop/c/include/stk_c.h.

Definition at line 62 of file stk_c_sync.cpp.

63{
64 STK_ASSERT(mtx != nullptr);
65
66 return mtx->handle.TryLock();
67}
bool TryLock()
Acquire the lock.

References stk_mutex_t::handle, STK_ASSERT, and stk::sync::Mutex::TryLock().

Here is the call graph for this function:

◆ stk_mutex_unlock()

void stk_mutex_unlock ( stk_mutex_t * mtx)

Unlock the mutex.

Parameters
[in]mtxMutex handle.
Examples
D:/SVN/private/stk/interop/c/include/stk_c.h.

Definition at line 69 of file stk_c_sync.cpp.

70{
71 STK_ASSERT(mtx != nullptr);
72
73 mtx->handle.Unlock();
74}
void Unlock() override
Release lock.

References stk_mutex_t::handle, STK_ASSERT, and stk::sync::Mutex::Unlock().

Here is the call graph for this function:

◆ stk_pipe_create()

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).

Constructs a stk::sync::Pipe in-place inside membuf. The pipe will hold up to capacity elements, each element_size bytes wide. The backing ring-buffer storage must be supplied by the caller via buf / buf_size.

Parameters
[in]membufPointer to static memory container for the Pipe control-block.
[in]bufPointer to the element data buffer. Must be at least capacity * element_size bytes.
[in]buf_sizeSize of buf in bytes (used for the safety assertion; must equal capacity * element_size).
[in]capacityMaximum number of elements [1, 65534].
[in]element_sizeSize of each individual element in bytes (>= 1).
Returns
Pipe handle, or NULL if any size assertion fails.
Note
Convenience macro STK_PIPE_BUF_SIZE(capacity, element_size) computes the required buf_size.
Only available when kernel is compiled with KERNEL_SYNC mode enabled.
Examples
D:/SVN/private/stk/interop/c/include/stk_c.h.

Definition at line 462 of file stk_c_sync.cpp.

467{
468 STK_ASSERT(membuf != nullptr);
469 STK_ASSERT(buf != nullptr);
470 STK_ASSERT(capacity >= 1U);
471 STK_ASSERT(element_size >= 1U);
472 STK_ASSERT(buf_size >= capacity * element_size);
473
474 stk_pipe_t *result = nullptr;
475 if ((membuf != nullptr) && (buf_size >= (capacity * element_size)))
476 {
477 result = ConstructIn<stk_pipe_t>(*membuf, buf, capacity, element_size);
478 }
479
480 return result;
481}

References stk::ConstructIn(), and STK_ASSERT.

Here is the call graph for this function:

◆ stk_pipe_destroy()

void stk_pipe_destroy ( stk_pipe_t * pipe)

Destroy a Pipe.

Parameters
[in]pipePipe handle.
Note
Any tasks still blocked on Write/Read at destruction time are considered a logic error; an assertion is triggered in debug builds.
Examples
D:/SVN/private/stk/interop/c/include/stk_c.h.

Definition at line 483 of file stk_c_sync.cpp.

484{
485 if (pipe != nullptr)
486 {
487 pipe->~stk_pipe_t();
488 }
489}

◆ stk_pipe_get_capacity()

size_t stk_pipe_get_capacity ( const stk_pipe_t * pipe)

Get the maximum number of elements the pipe can hold.

Parameters
[in]pipePipe handle.
Returns
Construction-time capacity.
Note
ISR-safe.
Examples
D:/SVN/private/stk/interop/c/include/stk_c.h.

Definition at line 576 of file stk_c_sync.cpp.

577{
578 STK_ASSERT(pipe != nullptr);
579
580 return pipe->handle.GetCapacity();
581}
size_t GetCapacity() const
Get the maximum number of elements the pipe can hold.

References stk::sync::Pipe::GetCapacity(), stk_pipe_t::handle, and STK_ASSERT.

Here is the call graph for this function:

◆ stk_pipe_get_count()

size_t stk_pipe_get_count ( const stk_pipe_t * pipe)

Get the current number of elements in the pipe.

Parameters
[in]pipePipe handle.
Returns
Point-in-time snapshot of the element count.
Note
ISR-safe on targets where a size_t-aligned read is atomic.
Examples
D:/SVN/private/stk/interop/c/include/stk_c.h.

Definition at line 590 of file stk_c_sync.cpp.

591{
592 STK_ASSERT(pipe != nullptr);
593
594 return pipe->handle.GetCount();
595}
size_t GetCount() const
Get the current number of elements in the pipe.

References stk::sync::Pipe::GetCount(), stk_pipe_t::handle, and STK_ASSERT.

Here is the call graph for this function:

◆ stk_pipe_get_element_size()

size_t stk_pipe_get_element_size ( const stk_pipe_t * pipe)

Get the size of each element in bytes.

Parameters
[in]pipePipe handle.
Returns
Construction-time element size.
Note
ISR-safe.
Examples
D:/SVN/private/stk/interop/c/include/stk_c.h.

Definition at line 583 of file stk_c_sync.cpp.

584{
585 STK_ASSERT(pipe != nullptr);
586
587 return pipe->handle.GetElementSize();
588}
size_t GetElementSize() const
Get the size of each element in bytes.

References stk::sync::Pipe::GetElementSize(), stk_pipe_t::handle, and STK_ASSERT.

Here is the call graph for this function:

◆ stk_pipe_get_instance()

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.

Parameters
[in]pipePipe handle obtained via stk_pipe_create().
Returns
Pointer to the wrapped stk::sync::Pipe instance. Never NULL for a valid handle.
Note
C++ callers only (guarded by __cplusplus); not part of the C ABI.
Examples
D:/SVN/private/stk/interop/c/include/stk_c.h.

Definition at line 625 of file stk_c_sync.cpp.

626{
627 STK_ASSERT(pipe != nullptr);
628
629 return &pipe->handle;
630}

References stk_pipe_t::handle, and STK_ASSERT.

◆ stk_pipe_get_space()

size_t stk_pipe_get_space ( const stk_pipe_t * pipe)

Get the number of free slots currently available.

Parameters
[in]pipePipe handle.
Returns
Point-in-time snapshot of the free-slot count.
Note
ISR-safe.
Examples
D:/SVN/private/stk/interop/c/include/stk_c.h.

Definition at line 597 of file stk_c_sync.cpp.

598{
599 STK_ASSERT(pipe != nullptr);
600
601 return pipe->handle.GetSpace();
602}
size_t GetSpace() const
Get the number of free slots currently available.

References stk::sync::Pipe::GetSpace(), stk_pipe_t::handle, and STK_ASSERT.

Here is the call graph for this function:

◆ stk_pipe_is_empty()

bool stk_pipe_is_empty ( const stk_pipe_t * pipe)

Check whether the pipe is currently empty.

Parameters
[in]pipePipe handle.
Returns
True if the pipe contains no elements.
Note
ISR-safe.
Examples
D:/SVN/private/stk/interop/c/include/stk_c.h.

Definition at line 604 of file stk_c_sync.cpp.

605{
606 STK_ASSERT(pipe != nullptr);
607
608 return pipe->handle.IsEmpty();
609}
bool IsEmpty() const
Check if the pipe is currently empty.

References stk_pipe_t::handle, stk::sync::Pipe::IsEmpty(), and STK_ASSERT.

Here is the call graph for this function:

◆ stk_pipe_is_full()

bool stk_pipe_is_full ( const stk_pipe_t * pipe)

Check whether the pipe is currently full.

Parameters
[in]pipePipe handle.
Returns
True if the pipe contains capacity elements.
Note
ISR-safe.
Examples
D:/SVN/private/stk/interop/c/include/stk_c.h.

Definition at line 611 of file stk_c_sync.cpp.

612{
613 STK_ASSERT(pipe != nullptr);
614
615 return pipe->handle.IsFull();
616}
bool IsFull() const
Check if the pipe is currently full.

References stk_pipe_t::handle, stk::sync::Pipe::IsFull(), and STK_ASSERT.

Here is the call graph for this function:

◆ stk_pipe_is_storage_valid()

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.

Parameters
[in]pipePipe handle.
Returns
True if the pipe is ready for use.
Note
ISR-safe.
Examples
D:/SVN/private/stk/interop/c/include/stk_c.h.

Definition at line 618 of file stk_c_sync.cpp.

619{
620 STK_ASSERT(pipe != nullptr);
621
622 return pipe->handle.IsStorageValid();
623}
bool IsStorageValid() const
Verify that the backing storage is valid and the pipe is ready for use.

References stk_pipe_t::handle, stk::sync::Pipe::IsStorageValid(), and STK_ASSERT.

Here is the call graph for this function:

◆ stk_pipe_read()

bool stk_pipe_read ( stk_pipe_t * pipe,
void * data,
stk_timeout_t timeout )

Read a single element from the pipe.

Copies element_size bytes from the oldest slot into the buffer pointed to by data. Blocks if the pipe is empty until data is produced or the timeout expires.

Parameters
[in]pipePipe handle.
[out]dataDestination buffer (must be >= element_size bytes).
[in]timeoutMaximum time to wait in OS ticks or STK_WAIT_INFINITE. Use STK_NO_WAIT for a non-blocking attempt.
Returns
True if an element was read, False on timeout.
Note
If OS tick rate is 1 kHz then 1 tick = 1 ms. Use stk_ticks_from_ms() to convert a millisecond value to ticks for best portability across different tick rates.
Warning
ISR-safe only with timeout = STK_NO_WAIT.
Examples
D:/SVN/private/stk/interop/c/include/stk_c.h.

Definition at line 507 of file stk_c_sync.cpp.

508{
509 STK_ASSERT(pipe != nullptr);
510 STK_ASSERT(data != nullptr);
511
512 return pipe->handle.Read(data, timeout);
513}
bool Read(void *data, Timeout timeout_ticks=WAIT_INFINITE)
Read a single element from the pipe.

References stk_pipe_t::handle, stk::sync::Pipe::Read(), and STK_ASSERT.

Here is the call graph for this function:

◆ stk_pipe_read_bulk()

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.

Attempts to retrieve count elements from the FIFO. Blocks until the full amount is read or the timeout expires.

Parameters
[in]pipePipe handle.
[out]dstPointer to the destination array (must hold at least count elements of element_size bytes each).
[in]countNumber of elements to read.
[in]timeoutMaximum time to wait in OS ticks or STK_WAIT_INFINITE. Use STK_NO_WAIT for a non-blocking attempt.
Returns
Number of elements actually read. Equal to count unless a timeout occurred.
Note
If OS tick rate is 1 kHz then 1 tick = 1 ms. Use stk_ticks_from_ms() to convert a millisecond value to ticks for best portability across different tick rates.
Warning
ISR-safe only with timeout = STK_NO_WAIT.
Examples
D:/SVN/private/stk/interop/c/include/stk_c.h.

Definition at line 537 of file stk_c_sync.cpp.

538{
539 STK_ASSERT(pipe != nullptr);
540
541 return pipe->handle.ReadBulk(dst, count, timeout);
542}
size_t ReadBulk(void *dst, size_t count, Timeout timeout_ticks=WAIT_INFINITE)
Read multiple elements from the pipe.

References stk_pipe_t::handle, stk::sync::Pipe::ReadBulk(), and STK_ASSERT.

Here is the call graph for this function:

◆ stk_pipe_read_bulk_triggered()

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.

Blocks until at least trigger elements are simultaneously available in the pipe, or the timeout expires. Once the threshold is reached the call dequeues min(max_count, available) elements in a single atomic pass.

Parameters
[in]pipePipe handle.
[out]dstDestination buffer; must hold at least max_count elements of element_size bytes.
[in]triggerMinimum number of elements that must be available before any data is dequeued. Clamped to [1, max_count] internally.
[in]max_countMaximum number of elements to return in total.
[in]timeoutMaximum time to wait in OS ticks or STK_WAIT_INFINITE. Use STK_NO_WAIT for a non-blocking attempt.
Returns
Number of elements actually read (0 if timeout fired before trigger was reached).
Note
If OS tick rate is 1 kHz then 1 tick = 1 ms. Use stk_ticks_from_ms() to convert a millisecond value to ticks for best portability across different tick rates.
Warning
ISR-safe only with timeout = STK_NO_WAIT.
Examples
D:/SVN/private/stk/interop/c/include/stk_c.h.

Definition at line 551 of file stk_c_sync.cpp.

556{
557 STK_ASSERT(pipe != nullptr);
558
559 return pipe->handle.ReadBulkTriggered(dst, trigger, max_count, timeout);
560}
size_t ReadBulkTriggered(void *dst, size_t trigger, size_t max_count, Timeout timeout_ticks=WAIT_INFINITE)
Read at least trigger elements, then drain up to max_count without blocking.

References stk_pipe_t::handle, stk::sync::Pipe::ReadBulkTriggered(), and STK_ASSERT.

Here is the call graph for this function:

◆ stk_pipe_reset()

void stk_pipe_reset ( stk_pipe_t * pipe)

Discard all elements and reset the pipe to the empty state.

Any tasks blocked in Write() are woken so they can re-evaluate.

Parameters
[in]pipePipe handle.
Warning
Elements that were in the pipe are silently discarded.
ISR-safe.
Examples
D:/SVN/private/stk/interop/c/include/stk_c.h.

Definition at line 569 of file stk_c_sync.cpp.

570{
571 STK_ASSERT(pipe != nullptr);
572
573 pipe->handle.Reset();
574}
void Reset()
Discard all elements and reset the pipe to the empty state.

References stk_pipe_t::handle, stk::sync::Pipe::Reset(), and STK_ASSERT.

Here is the call graph for this function:

◆ stk_pipe_tryread()

bool stk_pipe_tryread ( stk_pipe_t * pipe,
void * data )

Attempt to read a single element from the pipe without blocking.

Parameters
[in]pipePipe handle.
[out]dataDestination buffer (must be >= element_size bytes).
Returns
True if an element was read, False if the pipe was empty.
Warning
ISR-safe.
Examples
D:/SVN/private/stk/interop/c/include/stk_c.h.

Definition at line 515 of file stk_c_sync.cpp.

516{
517 STK_ASSERT(pipe != nullptr);
518 STK_ASSERT(data != nullptr);
519
520 return pipe->handle.TryRead(data);
521}
bool TryRead(void *data)
Attempt to read a single element from the pipe without blocking.

References stk_pipe_t::handle, STK_ASSERT, and stk::sync::Pipe::TryRead().

Here is the call graph for this function:

◆ stk_pipe_tryread_bulk()

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.

Reads as many elements as are currently available without blocking.

Parameters
[in]pipePipe handle.
[out]dstPointer to the destination array.
[in]countNumber of elements to read.
Returns
Number of elements actually read.
Warning
ISR-safe.
Examples
D:/SVN/private/stk/interop/c/include/stk_c.h.

Definition at line 544 of file stk_c_sync.cpp.

545{
546 STK_ASSERT(pipe != nullptr);
547
548 return pipe->handle.TryReadBulk(dst, count);
549}
size_t TryReadBulk(void *dst, size_t count)
Attempt to read multiple elements from the pipe without blocking.

References stk_pipe_t::handle, STK_ASSERT, and stk::sync::Pipe::TryReadBulk().

Here is the call graph for this function:

◆ stk_pipe_tryread_bulk_triggered()

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.

Returns immediately with however many elements are available, up to max_count. The trigger threshold is not enforced.

Parameters
[in]pipePipe handle.
[out]dstDestination buffer.
[in]max_countMaximum number of elements to read.
Returns
Number of elements actually read.
Warning
ISR-safe.
Examples
D:/SVN/private/stk/interop/c/include/stk_c.h.

Definition at line 562 of file stk_c_sync.cpp.

563{
564 STK_ASSERT(pipe != nullptr);
565
566 return pipe->handle.TryReadBulkTriggered(dst, max_count);
567}
size_t TryReadBulkTriggered(void *dst, size_t max_count)
Non-blocking variant of ReadBulkTriggered.

References stk_pipe_t::handle, STK_ASSERT, and stk::sync::Pipe::TryReadBulkTriggered().

Here is the call graph for this function:

◆ stk_pipe_trywrite()

bool stk_pipe_trywrite ( stk_pipe_t * pipe,
const void * data )

Attempt to write a single element to the pipe without blocking.

Parameters
[in]pipePipe handle.
[in]dataPointer to the element payload.
Returns
True if written, False if the pipe was full.
Warning
ISR-safe.
Examples
D:/SVN/private/stk/interop/c/include/stk_c.h.

Definition at line 499 of file stk_c_sync.cpp.

500{
501 STK_ASSERT(pipe != nullptr);
502 STK_ASSERT(data != nullptr);
503
504 return pipe->handle.TryWrite(data);
505}
bool TryWrite(const void *data)
Attempt to write a single element to the pipe without blocking.

References stk_pipe_t::handle, STK_ASSERT, and stk::sync::Pipe::TryWrite().

Here is the call graph for this function:

◆ stk_pipe_trywrite_bulk()

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.

Copies as many elements as possible. Elements that do not fit are discarded.

Parameters
[in]pipePipe handle.
[in]srcPointer to the source array.
[in]countNumber of elements to write.
Returns
Number of elements actually written.
Warning
ISR-safe.
Examples
D:/SVN/private/stk/interop/c/include/stk_c.h.

Definition at line 530 of file stk_c_sync.cpp.

531{
532 STK_ASSERT(pipe != nullptr);
533
534 return pipe->handle.TryWriteBulk(src, count);
535}
size_t TryWriteBulk(const void *src, size_t count)
Attempt to write multiple elements to the pipe without blocking.

References stk_pipe_t::handle, STK_ASSERT, and stk::sync::Pipe::TryWriteBulk().

Here is the call graph for this function:

◆ stk_pipe_write()

bool stk_pipe_write ( stk_pipe_t * pipe,
const void * data,
stk_timeout_t timeout )

Write a single element to the pipe.

Copies element_size bytes from data into the next available slot. Blocks if the pipe is full until space becomes available or the timeout expires.

Parameters
[in]pipePipe handle.
[in]dataPointer to the element payload (must be >= element_size bytes).
[in]timeoutMaximum time to wait in OS ticks or STK_WAIT_INFINITE. Use STK_NO_WAIT for a non-blocking attempt.
Returns
True if the element was written, False on timeout.
Note
If OS tick rate is 1 kHz then 1 tick = 1 ms. Use stk_ticks_from_ms() to convert a millisecond value to ticks for best portability across different tick rates.
Warning
ISR-safe only with timeout = STK_NO_WAIT.
Examples
D:/SVN/private/stk/interop/c/include/stk_c.h.

Definition at line 491 of file stk_c_sync.cpp.

492{
493 STK_ASSERT(pipe != nullptr);
494 STK_ASSERT(data != nullptr);
495
496 return pipe->handle.Write(data, timeout);
497}
bool Write(const void *data, Timeout timeout_ticks=WAIT_INFINITE)
Write a single element to the pipe.

References stk_pipe_t::handle, STK_ASSERT, and stk::sync::Pipe::Write().

Here is the call graph for this function:

◆ stk_pipe_write_bulk()

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.

Copies a block of count elements. Blocks until the full amount is written or the timeout expires.

Parameters
[in]pipePipe handle.
[in]srcPointer to the source array (must hold at least count elements of element_size bytes each).
[in]countNumber of elements to write.
[in]timeoutMaximum time to wait in OS ticks or STK_WAIT_INFINITE. Use STK_NO_WAIT for a non-blocking attempt.
Returns
Number of elements actually written. Equal to count unless a timeout occurred.
Note
If OS tick rate is 1 kHz then 1 tick = 1 ms. Use stk_ticks_from_ms() to convert a millisecond value to ticks for best portability across different tick rates.
Warning
ISR-safe only with timeout = STK_NO_WAIT.
Examples
D:/SVN/private/stk/interop/c/include/stk_c.h.

Definition at line 523 of file stk_c_sync.cpp.

524{
525 STK_ASSERT(pipe != nullptr);
526
527 return pipe->handle.WriteBulk(src, count, timeout);
528}
size_t WriteBulk(const void *src, size_t count, Timeout timeout_ticks=WAIT_INFINITE)
Write multiple elements to the pipe.

References stk_pipe_t::handle, STK_ASSERT, and stk::sync::Pipe::WriteBulk().

Here is the call graph for this function:

◆ stk_rwmutex_create()

stk_rwmutex_t * stk_rwmutex_create ( stk_rwmutex_mem_t *const membuf)

Create an RWMutex (using provided memory).

Parameters
[in]membufPointer to static memory container.
Returns
RWMutex handle.
Examples
D:/SVN/private/stk/interop/c/include/stk_c.h.

Definition at line 831 of file stk_c_sync.cpp.

832{
833 STK_ASSERT(membuf != nullptr);
834
835 stk_rwmutex_t *result = nullptr;
836 if (membuf != nullptr)
837 {
838 result = ConstructIn<stk_rwmutex_t>(*membuf);
839 }
840
841 return result;
842}

References stk::ConstructIn(), and STK_ASSERT.

Here is the call graph for this function:

◆ stk_rwmutex_destroy()

void stk_rwmutex_destroy ( stk_rwmutex_t * rw)

Destroy an RWMutex.

Parameters
[in]rwRWMutex handle.
Examples
D:/SVN/private/stk/interop/c/include/stk_c.h.

Definition at line 844 of file stk_c_sync.cpp.

845{
846 if (rw != nullptr)
847 {
848 rw->~stk_rwmutex_t();
849 }
850}

◆ stk_rwmutex_get_instance()

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.

Parameters
[in]rwRWMutex handle obtained via stk_rwmutex_create().
Returns
Pointer to the wrapped stk::sync::RWMutex instance. Never NULL for a valid handle.
Note
C++ callers only (guarded by __cplusplus); not part of the C ABI.
Examples
D:/SVN/private/stk/interop/c/include/stk_c.h.

Definition at line 908 of file stk_c_sync.cpp.

909{
910 STK_ASSERT(rw != nullptr);
911
912 return &rw->handle;
913}
sync::RWMutex handle

References stk_rwmutex_t::handle, and STK_ASSERT.

◆ stk_rwmutex_lock()

void stk_rwmutex_lock ( stk_rwmutex_t * rw)

Acquire the lock for exclusive writing. Blocks until available.

Blocks until all active readers have released their locks and no other writer is active.

Parameters
[in]rwRWMutex handle.
Examples
D:/SVN/private/stk/interop/c/include/stk_c.h.

Definition at line 880 of file stk_c_sync.cpp.

881{
882 STK_ASSERT(rw != nullptr);
883
884 rw->handle.Lock();
885}
void Lock() override
Acquire the lock for exclusive writing (IMutex interface).

References stk_rwmutex_t::handle, stk::sync::RWMutex::Lock(), and STK_ASSERT.

Here is the call graph for this function:

◆ stk_rwmutex_read_lock()

void stk_rwmutex_read_lock ( stk_rwmutex_t * rw)

Acquire the lock for shared reading. Blocks until available.

Blocks if a writer is currently active or writers are waiting (Writer Preference Policy).

Parameters
[in]rwRWMutex handle.
Examples
D:/SVN/private/stk/interop/c/include/stk_c.h.

Definition at line 852 of file stk_c_sync.cpp.

853{
854 STK_ASSERT(rw != nullptr);
855
856 rw->handle.ReadLock();
857}
void ReadLock()
Acquire the lock for shared reading.

References stk_rwmutex_t::handle, stk::sync::RWMutex::ReadLock(), and STK_ASSERT.

Here is the call graph for this function:

◆ stk_rwmutex_read_unlock()

void stk_rwmutex_read_unlock ( stk_rwmutex_t * rw)

Release the shared reader lock.

If this is the last active reader, waiting writers are notified.

Parameters
[in]rwRWMutex handle.
Examples
D:/SVN/private/stk/interop/c/include/stk_c.h.

Definition at line 873 of file stk_c_sync.cpp.

874{
875 STK_ASSERT(rw != nullptr);
876
877 rw->handle.ReadUnlock();
878}
void ReadUnlock()
Release the shared reader lock.

References stk_rwmutex_t::handle, stk::sync::RWMutex::ReadUnlock(), and STK_ASSERT.

Here is the call graph for this function:

◆ stk_rwmutex_timed_lock()

bool stk_rwmutex_timed_lock ( stk_rwmutex_t * rw,
stk_timeout_t timeout )

Try to acquire the write lock with a timeout.

Parameters
[in]rwRWMutex handle.
[in]timeoutMaximum time to wait in OS ticks or STK_WAIT_INFINITE. Use STK_NO_WAIT for non-blocking.
Returns
True if acquired, False on timeout.
Note
If OS tick rate is 1 kHz then 1 tick = 1 ms. Use stk_ticks_from_ms() to convert a millisecond value to ticks for best portability across different tick rates.
Examples
D:/SVN/private/stk/interop/c/include/stk_c.h.

Definition at line 894 of file stk_c_sync.cpp.

895{
896 STK_ASSERT(rw != nullptr);
897
898 return rw->handle.TimedLock(timeout);
899}
bool TimedLock(Timeout timeout_ticks)
Acquire the lock for exclusive writing with a timeout.

References stk_rwmutex_t::handle, STK_ASSERT, and stk::sync::RWMutex::TimedLock().

Here is the call graph for this function:

◆ stk_rwmutex_timed_read_lock()

bool stk_rwmutex_timed_read_lock ( stk_rwmutex_t * rw,
stk_timeout_t timeout )

Try to acquire the read lock with a timeout.

Parameters
[in]rwRWMutex handle.
[in]timeoutMaximum time to wait in OS ticks or STK_WAIT_INFINITE. Use STK_NO_WAIT for non-blocking.
Returns
True if acquired, False on timeout.
Note
If OS tick rate is 1 kHz then 1 tick = 1 ms. Use stk_ticks_from_ms() to convert a millisecond value to ticks for best portability across different tick rates.
Examples
D:/SVN/private/stk/interop/c/include/stk_c.h.

Definition at line 866 of file stk_c_sync.cpp.

867{
868 STK_ASSERT(rw != nullptr);
869
870 return rw->handle.TimedReadLock(timeout);
871}
bool TimedReadLock(Timeout timeout_ticks)
Acquire the lock for shared reading with a timeout.

References stk_rwmutex_t::handle, STK_ASSERT, and stk::sync::RWMutex::TimedReadLock().

Here is the call graph for this function:

◆ stk_rwmutex_try_read_lock()

bool stk_rwmutex_try_read_lock ( stk_rwmutex_t * rw)

Try to acquire the read lock without blocking.

Parameters
[in]rwRWMutex handle.
Returns
True if the read lock was acquired, False if a writer is active or waiting.
Examples
D:/SVN/private/stk/interop/c/include/stk_c.h.

Definition at line 859 of file stk_c_sync.cpp.

860{
861 STK_ASSERT(rw != nullptr);
862
863 return rw->handle.TryReadLock();
864}
bool TryReadLock()
Attempt to acquire the lock for shared reading without blocking.

References stk_rwmutex_t::handle, STK_ASSERT, and stk::sync::RWMutex::TryReadLock().

Here is the call graph for this function:

◆ stk_rwmutex_trylock()

bool stk_rwmutex_trylock ( stk_rwmutex_t * rw)

Try to acquire the write lock without blocking.

Parameters
[in]rwRWMutex handle.
Returns
True if the exclusive lock was acquired, False otherwise.
Examples
D:/SVN/private/stk/interop/c/include/stk_c.h.

Definition at line 887 of file stk_c_sync.cpp.

888{
889 STK_ASSERT(rw != nullptr);
890
891 return rw->handle.TryLock();
892}
bool TryLock()
Attempt to acquire the lock for exclusive writing without blocking.

References stk_rwmutex_t::handle, STK_ASSERT, and stk::sync::RWMutex::TryLock().

Here is the call graph for this function:

◆ stk_rwmutex_unlock()

void stk_rwmutex_unlock ( stk_rwmutex_t * rw)

Release the exclusive writer lock.

Prioritizes waking waiting writers. If none are waiting, all waiting readers are woken (Writer Preference Policy).

Parameters
[in]rwRWMutex handle.
Examples
D:/SVN/private/stk/interop/c/include/stk_c.h.

Definition at line 901 of file stk_c_sync.cpp.

902{
903 STK_ASSERT(rw != nullptr);
904
905 rw->handle.Unlock();
906}
void Unlock() override
Release the exclusive writer lock (IMutex interface).

References stk_rwmutex_t::handle, STK_ASSERT, and stk::sync::RWMutex::Unlock().

Here is the call graph for this function:

◆ stk_sem_create()

stk_sem_t * stk_sem_create ( stk_sem_mem_t *const membuf,
uint32_t initial_count,
uint32_t max_count )

Create a Semaphore (using provided memory).

Parameters
[in]membufPointer to static memory container.
[in]initial_countStarting value of the resource counter.
[in]max_countMaximum value the counter is allowed to reach. Pass 0 to use the default maximum (65534). Must be >= initial_count.
Returns
Semaphore handle.
Examples
D:/SVN/private/stk/interop/c/include/stk_c.h.

Definition at line 308 of file stk_c_sync.cpp.

311{
312 STK_ASSERT(membuf != nullptr);
313
314 const uint32_t effective_max = ((max_count == 0U) ? Semaphore::COUNT_MAX : max_count);
315
316 stk_sem_t *result = nullptr;
317 if (membuf != nullptr)
318 {
319 result = ConstructIn<stk_sem_t>(*membuf, initial_count, effective_max);
320 }
321
322 return result;
323}
static const uint16_t COUNT_MAX
Max count value supported.

References stk::ConstructIn(), stk::sync::Semaphore::COUNT_MAX, and STK_ASSERT.

Here is the call graph for this function:

◆ stk_sem_destroy()

void stk_sem_destroy ( stk_sem_t * sem)

Destroy a Semaphore.

Parameters
[in]semSemaphore handle.
Examples
D:/SVN/private/stk/interop/c/include/stk_c.h.

Definition at line 325 of file stk_c_sync.cpp.

326{
327 if (sem != nullptr)
328 {
329 sem->~stk_sem_t();
330 }
331}

◆ stk_sem_get_count()

uint16_t stk_sem_get_count ( const stk_sem_t * sem)

Get the current counter value.

Parameters
[in]semSemaphore handle.
Returns
Advisory snapshot of the counter. May be stale by the time the caller acts on it.
Note
ISR-safe on targets where a 16-bit aligned read is atomic.
Examples
D:/SVN/private/stk/interop/c/include/stk_c.h.

Definition at line 361 of file stk_c_sync.cpp.

362{
363 STK_ASSERT(sem != nullptr);
364
365 return sem->handle.GetCount();
366}
uint16_t GetCount() const
Get current counter value.
Semaphore handle

References stk::sync::Semaphore::GetCount(), stk_sem_t::handle, and STK_ASSERT.

Here is the call graph for this function:

◆ stk_sem_get_instance()

stk::sync::Semaphore * stk_sem_get_instance ( stk_sem_t * sem)

Get the underlying C++ stk::sync::Semaphore object wrapped by a stk_sem_t handle.

Parameters
[in]semSemaphore handle obtained via stk_sem_create().
Returns
Pointer to the wrapped stk::sync::Semaphore instance. Never NULL for a valid handle.
Note
C++ callers only (guarded by __cplusplus); not part of the C ABI.
Examples
D:/SVN/private/stk/interop/c/include/stk_c.h.

Definition at line 368 of file stk_c_sync.cpp.

369{
370 STK_ASSERT(sem != nullptr);
371
372 return &sem->handle;
373}

References stk_sem_t::handle, and STK_ASSERT.

◆ stk_sem_signal()

void stk_sem_signal ( stk_sem_t * sem)

Signal/Release a semaphore resource.

Parameters
[in]semSemaphore handle.
Warning
API contract: the counter must not already be at max_count with no task waiting. Violating this triggers an assertion in a debug build. Use stk_sem_trysignal() instead if a signal that would exceed max_count should be tolerated (e.g. a redundant signal) rather than treated as a caller error.
Examples
D:/SVN/private/stk/interop/c/include/stk_c.h.

Definition at line 347 of file stk_c_sync.cpp.

348{
349 STK_ASSERT(sem != nullptr);
350
351 sem->handle.Signal();
352}
void Signal()
Post a signal (increment counter).

References stk_sem_t::handle, stk::sync::Semaphore::Signal(), and STK_ASSERT.

Here is the call graph for this function:

◆ stk_sem_trysignal()

bool stk_sem_trysignal ( stk_sem_t * sem)

Try to signal/release a semaphore resource without exceeding max_count.

Identical to stk_sem_signal(), except that if the counter is already at max_count and no task is waiting, this returns false instead of asserting. The check and the increment (or hand-off to a waiter) happen atomically, so this is safe to call from multiple concurrent signalers without racing each other the way a separate stk_sem_get_count() check followed by stk_sem_signal() would.

Parameters
[in]semSemaphore handle.
Returns
True if signaled (incremented, or handed directly to a waiter), False if the counter was already at max_count and nobody was waiting.
Warning
ISR-safe.
Examples
D:/SVN/private/stk/interop/c/include/stk_c.h.

Definition at line 354 of file stk_c_sync.cpp.

355{
356 STK_ASSERT(sem != nullptr);
357
358 return sem->handle.TrySignal();
359}
bool TrySignal()
Try to post a signal without exceeding max_count.

References stk_sem_t::handle, STK_ASSERT, and stk::sync::Semaphore::TrySignal().

Here is the call graph for this function:

◆ stk_sem_trywait()

bool stk_sem_trywait ( stk_sem_t * sem)

Poll the semaphore without blocking.

Acquires a resource token if one is immediately available; returns false instantly if the counter is zero.

Parameters
[in]semSemaphore handle.
Returns
True if a token was acquired, False if count was zero.
Warning
ISR-safe.
Examples
D:/SVN/private/stk/interop/c/include/stk_c.h.

Definition at line 340 of file stk_c_sync.cpp.

341{
342 STK_ASSERT(sem != nullptr);
343
344 return sem->handle.TryWait();
345}
bool TryWait()
Poll the semaphore without blocking (decrement counter if available).

References stk_sem_t::handle, STK_ASSERT, and stk::sync::Semaphore::TryWait().

Here is the call graph for this function:

◆ stk_sem_wait()

bool stk_sem_wait ( stk_sem_t * sem,
stk_timeout_t timeout )

Wait for a semaphore resource.

Parameters
[in]semSemaphore handle.
[in]timeoutMaximum time to wait in OS ticks or STK_WAIT_INFINITE.
Returns
True if resource acquired, False on timeout.
Note
If OS tick rate is 1 kHz then 1 tick = 1 ms. Use stk_ticks_from_ms() to convert a millisecond value to ticks for best portability across different tick rates.
Examples
D:/SVN/private/stk/interop/c/include/stk_c.h.

Definition at line 333 of file stk_c_sync.cpp.

334{
335 STK_ASSERT(sem != nullptr);
336
337 return sem->handle.Wait(timeout);
338}
bool Wait(Timeout timeout_ticks=WAIT_INFINITE)
Wait for a signal (decrement counter).

References stk_sem_t::handle, STK_ASSERT, and stk::sync::Semaphore::Wait().

Here is the call graph for this function:

◆ stk_sleep()

void stk_sleep ( stk_timeout_t ticks)

Put current task to sleep (non-HRT kernels only).

Parameters
[in]ticksTicks to sleep.
Note
Unlike stk_delay_ms(), this function does not spin and allows the kernel to idle the CPU. When KERNEL_TICKLESS is active and all tasks are sleeping, the SysTick is suppressed and the CPU enters a low-power WFI state until the nearest wake-up deadline.
Unsupported in KERNEL_HRT mode; in HRT mode tasks sleep automatically according to their periodicity and workload, use stk_yield instead.
See also
stk_sleep_ms, stk_sleep_until, stk_ticks
Examples
D:/SVN/private/stk/interop/c/include/stk_c.h.

Definition at line 645 of file stk_c.cpp.

645{ stk::Sleep(ticks); }
static void Sleep(Timeout tick_count)
Put calling process into a sleep state.
Definition stk_helper.h:479

References stk::Sleep().

Here is the call graph for this function:

◆ stk_sleep_cancel()

void stk_sleep_cancel ( stk_tid_t tid)

Cancel the sleep of a task, waking it immediately.

Parameters
[in]tidIdentifier of the task to wake (obtained from stk_tid() or stk_task_get_id()).
Note
No-op if the target task is not currently sleeping.
ISR-safe.
See also
stk_sleep, stk_sleep_ms, stk_sleep_until
Examples
D:/SVN/private/stk/interop/c/include/stk_c.h.

Definition at line 649 of file stk_c.cpp.

649{ stk::SleepCancel(tid); }
static void SleepCancel(TId task_id)
Cancel sleep of the task.
Definition stk_helper.h:514

References stk::SleepCancel().

Here is the call graph for this function:

◆ stk_sleep_ms()

void stk_sleep_ms ( stk_timeout_t ms)

Put current task to sleep (non-HRT kernels only).

Parameters
[in]msMilliseconds to sleep.
Note
Unlike stk_delay_ms(), this function does not spin and allows the kernel to idle the CPU. When KERNEL_TICKLESS is active and all tasks are sleeping, the SysTick is suppressed and the CPU enters a low-power WFI state until the nearest wake-up deadline.
Unsupported in KERNEL_HRT mode; in HRT mode tasks sleep automatically according to their periodicity and workload, use stk_yield instead.
See also
stk_sleep, stk_sleep_until, stk_ticks
Examples
D:/SVN/private/stk/interop/c/include/stk_c.h.

Definition at line 647 of file stk_c.cpp.

647{ stk::SleepMs(ms); }
static void SleepMs(Timeout ms)
Put calling process into a sleep state.
Definition stk_helper.h:492

References stk::SleepMs().

Here is the call graph for this function:

◆ stk_sleep_until()

bool stk_sleep_until ( stk_tick_t ts)

Put current task to sleep (non-HRT kernels only).

Parameters
[in]tsAbsolute time (timestamp), a deadline for a sleep period.
Returns
True if sleep succeeded, false otherwise.
Note
Unlike stk_delay_ms(), this function does not spin and allows the kernel to idle the CPU. When KERNEL_TICKLESS is active and all tasks are sleeping, the SysTick is suppressed and the CPU enters a low-power WFI state until the nearest wake-up deadline.
Unsupported in KERNEL_HRT mode; in HRT mode tasks sleep automatically according to their periodicity and workload, use stk_yield instead.
See also
stk_sleep, stk_sleep_ms, stk_ticks
Examples
D:/SVN/private/stk/interop/c/include/stk_c.h.

Definition at line 648 of file stk_c.cpp.

648{ return stk::SleepUntil(ts); }
static bool SleepUntil(Ticks timestamp)
Put calling process into a sleep state until the specified timestamp.
Definition stk_helper.h:504

References stk::SleepUntil().

Here is the call graph for this function:

◆ stk_spinlock_create()

stk_spinlock_t * stk_spinlock_create ( stk_spinlock_mem_t *const membuf)

Create a recursive SpinLock.

Parameters
[in]membufPointer to static memory container.
Returns
SpinLock handle.
Examples
D:/SVN/private/stk/interop/c/include/stk_c.h.

Definition at line 98 of file stk_c_sync.cpp.

99{
100 STK_ASSERT(membuf != nullptr);
101
102 stk_spinlock_t *result = nullptr;
103 if (membuf != nullptr)
104 {
105 result = ConstructIn<stk_spinlock_t>(*membuf);
106 }
107
108 return result;
109}

References stk::ConstructIn(), and STK_ASSERT.

Here is the call graph for this function:

◆ stk_spinlock_destroy()

void stk_spinlock_destroy ( stk_spinlock_t * slock)

Destroy the SpinLock.

Examples
D:/SVN/private/stk/interop/c/include/stk_c.h.

Definition at line 111 of file stk_c_sync.cpp.

112{
113 if (slock != nullptr)
114 {
115 slock->~stk_spinlock_t();
116 }
117}

◆ stk_spinlock_get_instance()

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.

Parameters
[in]slockSpinLock handle obtained via stk_spinlock_create().
Returns
Pointer to the wrapped stk::sync::SpinLock instance. Never NULL for a valid handle.
Note
C++ callers only (guarded by __cplusplus); not part of the C ABI.
Examples
D:/SVN/private/stk/interop/c/include/stk_c.h.

Definition at line 137 of file stk_c_sync.cpp.

138{
139 STK_ASSERT(slock != nullptr);
140
141 return &slock->handle;
142}
sync::SpinLock handle

References stk_spinlock_t::handle, and STK_ASSERT.

◆ stk_spinlock_lock()

void stk_spinlock_lock ( stk_spinlock_t * slock)

Acquire the SpinLock (recursive).

Examples
D:/SVN/private/stk/interop/c/include/stk_c.h.

Definition at line 119 of file stk_c_sync.cpp.

120{
121 STK_ASSERT(slock != nullptr);
122 slock->handle.Lock();
123}
void Lock()
Acquire the lock.

References stk_spinlock_t::handle, stk::sync::SpinLock::Lock(), and STK_ASSERT.

Here is the call graph for this function:

◆ stk_spinlock_trylock()

bool stk_spinlock_trylock ( stk_spinlock_t * slock)

Attempt to acquire the SpinLock immediately.

Returns
True if locked successfully, False otherwise.
Examples
D:/SVN/private/stk/interop/c/include/stk_c.h.

Definition at line 125 of file stk_c_sync.cpp.

126{
127 STK_ASSERT(slock != nullptr);
128 return slock->handle.TryLock();
129}
bool TryLock()
Attempt to acquire the lock without blocking.

References stk_spinlock_t::handle, STK_ASSERT, and stk::sync::SpinLock::TryLock().

Here is the call graph for this function:

◆ stk_spinlock_unlock()

void stk_spinlock_unlock ( stk_spinlock_t * slock)

Release the SpinLock.

Examples
D:/SVN/private/stk/interop/c/include/stk_c.h.

Definition at line 131 of file stk_c_sync.cpp.

132{
133 STK_ASSERT(slock != nullptr);
134 slock->handle.Unlock();
135}
void Unlock()
Release the lock or decrement the recursion counter.

References stk_spinlock_t::handle, STK_ASSERT, and stk::sync::SpinLock::Unlock().

Here is the call graph for this function:

◆ stk_sys_timer_count()

stk_cycle_t stk_sys_timer_count ( void )

Get raw system timer counter value.

Returns
64-bit hardware counter value. Useful for sub-tick timing measurements.
Note
ISR-safe.
Examples
D:/SVN/private/stk/interop/c/include/stk_c.h.

Definition at line 639 of file stk_c.cpp.

639{ return stk::GetSysTimerCount(); }
static Cycles GetSysTimerCount()
Get system timer count value.
Definition stk_helper.h:459

References stk::GetSysTimerCount().

Here is the call graph for this function:

◆ stk_sys_timer_frequency()

uint32_t stk_sys_timer_frequency ( void )

Get system timer frequency in Hz.

Returns
Timer frequency (Hz). Divide stk_sys_timer_count() differences by this value to obtain elapsed time in seconds.
Note
ISR-safe.
Examples
D:/SVN/private/stk/interop/c/include/stk_c.h.

Definition at line 640 of file stk_c.cpp.

640{ return stk::GetSysTimerFrequency(); }
static uint32_t GetSysTimerFrequency()
Get system timer frequency.
Definition stk_helper.h:468

References stk::GetSysTimerFrequency().

Here is the call graph for this function:

◆ stk_task_create_privileged()

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.

Parameters
[in]entryTask entry function.
[in]argArgument passed to entry function.
[in]stackPointer to stack buffer (array of stk_word_t).
[in]stack_sizeNumber of elements (words) in the stack buffer.
Returns
Task handle (static storage in static kernels, heap in dynamic).
Examples
D:/SVN/private/stk/interop/c/include/stk_c.h.

Definition at line 555 of file stk_c.cpp.

559{
560 STK_ASSERT(entry != nullptr);
561 STK_ASSERT(stack != nullptr);
562 STK_ASSERT(stack_size != 0);
563
564 return AllocateTask(entry, arg, stack, stack_size, ACCESS_PRIVILEGED);
565}
static stk_task_t * AllocateTask(stk_task_entry_t entry, void *arg, stk_word_t *stack, uint32_t stack_size, EAccessMode amode)
Definition stk_c.cpp:262
@ ACCESS_PRIVILEGED
Privileged access mode (access to hardware is fully unrestricted).
Definition stk_common.h:38

References stk::ACCESS_PRIVILEGED, AllocateTask(), and STK_ASSERT.

Here is the call graph for this function:

◆ stk_task_create_user()

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.

Parameters
[in]entryTask entry function.
[in]argArgument passed to entry function.
[in]stackPointer to stack buffer (array of stk_word_t).
[in]stack_sizeNumber of elements (words) in the stack buffer.
Returns
Task handle.
Examples
D:/SVN/private/stk/interop/c/include/stk_c.h.

Definition at line 567 of file stk_c.cpp.

571{
572 STK_ASSERT(entry != nullptr);
573 STK_ASSERT(stack != nullptr);
574 STK_ASSERT(stack_size != 0);
575
576 return AllocateTask(entry, arg, stack, stack_size, ACCESS_USER);
577}
@ ACCESS_USER
Unprivileged access mode (access to some hardware is restricted, see CPU manual for details)....
Definition stk_common.h:37

References stk::ACCESS_USER, AllocateTask(), and STK_ASSERT.

Referenced by stk::pthread::EnsureReaper().

Here is the call graph for this function:
Here is the caller graph for this function:

◆ stk_task_destroy()

void stk_task_destroy ( stk_task_t * tsk)

Destroy dynamically created task object.

Parameters
[in]tskTask handle.
Note
Only valid for tasks created with dynamic creation functions. Task must no longer be scheduled (must have exited or been removed).
Examples
D:/SVN/private/stk/interop/c/include/stk_c.h.

Definition at line 623 of file stk_c.cpp.

624{
625 STK_ASSERT(tsk != nullptr);
626
627 FreeTask(tsk);
628}
static void FreeTask(const stk_task_t *tsk)
Definition stk_c.cpp:288

References FreeTask(), and STK_ASSERT.

Here is the call graph for this function:

◆ stk_task_get_id()

stk_tid_t stk_task_get_id ( const stk_task_t * tsk)

Get the unique identifier of a task.

Parameters
[in]tskTask handle.
Returns
Task identifier (stk_tid_t). Equivalent to the value stk_tid() returns when called from within that task.
Note
ISR-safe.
See also
stk_tid
Examples
D:/SVN/private/stk/interop/c/include/stk_c.h.

Definition at line 609 of file stk_c.cpp.

610{
611 STK_ASSERT(tsk != nullptr);
612
613 return stk::GetTidFromUserTask(&tsk->handle);
614}
static constexpr TId GetTidFromUserTask(const ITask *task) noexcept
Get task identifier from ITask instance.
Definition stk_arch.h:716

References stk::GetTidFromUserTask(), stk_task_t::handle, and STK_ASSERT.

Here is the call graph for this function:

◆ stk_task_get_instance()

stk::ITask * stk_task_get_instance ( stk_task_t * tsk)

Get the underlying C++ stk::ITask object wrapped by a stk_task_t handle.

Gateway for mixed C/C++ code: lets C++ callers linked against the C API reach the real polymorphic task object (e.g. to pass it to a C++-only API) without duplicating task bookkeeping.

Parameters
[in]tskTask handle obtained via stk_task_create_privileged() or stk_task_create_user().
Returns
Pointer to the wrapped stk::ITask instance. Never NULL for a valid handle.
Note
C++ callers only (guarded by __cplusplus); not part of the C ABI.
Warning
The returned pointer is only valid for the lifetime of tsk.
Examples
D:/SVN/private/stk/interop/c/include/stk_c.h.

Definition at line 616 of file stk_c.cpp.

617{
618 STK_ASSERT(tsk != nullptr);
619
620 return &tsk->handle;
621}

References stk_task_t::handle, and STK_ASSERT.

◆ stk_task_get_name()

const char * stk_task_get_name ( const stk_task_t * tsk)

Get human-readable task name previously set with stk_task_set_name().

Parameters
[in]tskTask handle.
Returns
Null-terminated name string, or NULL if not set.
Note
ISR-safe (reads a stored pointer, no kernel call).
Examples
D:/SVN/private/stk/interop/c/include/stk_c.h.

Definition at line 602 of file stk_c.cpp.

603{
604 STK_ASSERT(tsk != nullptr);
605
606 return tsk->handle.GetTraceName();
607}
const char * GetTraceName() const override
Get task trace name set by application.
Definition stk_c.cpp:89

References TaskWrapper::GetTraceName(), stk_task_t::handle, and STK_ASSERT.

Here is the call graph for this function:

◆ stk_task_set_name()

void stk_task_set_name ( stk_task_t * tsk,
const char * tname )

Assign human-readable task name (for tracing/debugging).

Parameters
[in]tskTask handle.
[in]tnameNull-terminated string (may be NULL).
Examples
D:/SVN/private/stk/interop/c/include/stk_c.h.

Definition at line 595 of file stk_c.cpp.

596{
597 STK_ASSERT(tsk != nullptr);
598
599 tsk->handle.SetName(tname);
600}
void SetName(const char *tname)
Definition stk_c.cpp:107

References stk_task_t::handle, TaskWrapper::SetName(), and STK_ASSERT.

Referenced by stk::pthread::EnsureReaper().

Here is the call graph for this function:
Here is the caller graph for this function:

◆ stk_task_set_priority()

void stk_task_set_priority ( stk_task_t * tsk,
uint8_t priority )

Set task priority (used only by Fixed Priority scheduler).

Parameters
[in]tskTask handle.
[in]priorityPriority level [0 = lowest … 31 = highest].
Note
Must be called before adding task to kernel.
Examples
D:/SVN/private/stk/interop/c/include/stk_c.h.

Definition at line 586 of file stk_c.cpp.

587{
588 STK_ASSERT(priority <= 31U);
589
590 const stk_weight_t weight = static_cast<stk_weight_t>(priority);
591
592 stk_task_set_weight(tsk, weight);
593}
void stk_task_set_weight(stk_task_t *tsk, stk_weight_t weight)
Set task weight (used only by Smooth Weighted Round Robin).
Definition stk_c.cpp:579
int32_t stk_weight_t
Task weight value.
Definition stk_c.h:127

References STK_ASSERT, and stk_task_set_weight().

Here is the call graph for this function:

◆ stk_task_set_weight()

void stk_task_set_weight ( stk_task_t * tsk,
stk_weight_t weight )

Set task weight (used only by Smooth Weighted Round Robin).

Parameters
[in]tskTask handle.
[in]weightPositive weight value (recommended 1–16777215).
Note
Must be called before adding task to kernel.
See also
SwitchStrategySmoothWeightedRoundRobin.
Examples
D:/SVN/private/stk/interop/c/include/stk_c.h.

Definition at line 579 of file stk_c.cpp.

580{
581 STK_ASSERT(tsk != nullptr);
582
583 tsk->handle.SetWeight(weight);
584}
void SetWeight(Weight weight)
Definition stk_c.cpp:106

References stk_task_t::handle, TaskWrapper::SetWeight(), and STK_ASSERT.

Referenced by stk_task_set_priority().

Here is the call graph for this function:
Here is the caller graph for this function:

◆ stk_tick_resolution()

uint32_t stk_tick_resolution ( void )

Returns how many microseconds correspond to one kernel tick.

Returns
Tick resolution in microseconds.
Examples
D:/SVN/private/stk/interop/c/include/stk_c.h.

Definition at line 635 of file stk_c.cpp.

635{ return stk::GetTickResolution(); }
static uint32_t GetTickResolution()
Get number of microseconds in one tick.
Definition stk_helper.h:368

References stk::GetTickResolution().

Referenced by stk_ms_from_ticks().

Here is the call graph for this function:
Here is the caller graph for this function:

◆ stk_ticks()

stk_tick_t stk_ticks ( void )

Returns number of ticks elapsed since kernel start.

Returns
Tick count (monotonically increasing).
Examples
D:/SVN/private/stk/interop/c/include/stk_c.h.

Definition at line 634 of file stk_c.cpp.

634{ return stk::GetTicks(); }
static Ticks GetTicks()
Get number of ticks elapsed since kernel start.
Definition stk_helper.h:434

References stk::GetTicks().

Here is the call graph for this function:

◆ stk_ticks_from_ms()

stk_tick_t stk_ticks_from_ms ( stk_time_t msec)

Get ticks from milliseconds using current kernel tick resolution.

Parameters
[in]msecMilliseconds to convert.
Returns
Ticks.
Note
Equivalent to stk::GetTicksFromMsec(msec). Requires the kernel to be initialized before calling (stk_tick_resolution() must return a valid non-zero value).
Examples
D:/SVN/private/stk/interop/c/include/stk_c.h.

Definition at line 637 of file stk_c.cpp.

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.
Definition stk_c.h:680

References stk::GetTickResolution(), and stk_ticks_from_ms_r().

Here is the call graph for this function:

◆ stk_ticks_from_ms_clamped_to_timeout()

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).

Parameters
[in]msMilliseconds to convert.
Returns
Equivalent tick count, clamped to STK_WAIT_INFINITE if it would otherwise overflow.
Note
Equivalent to stk::GetTicksFromMsClampedToTimeout(ms). Prefer this over stk_ticks_from_ms() when the result is passed directly as a timeout argument (e.g. to stk_mutex_timed_lock()), so a large millisecond value can never wrap into an unintended (or negative) timeout.
If tick rate is 1 kHz then 1 tick = 1 ms.
ISR-unsafe (internally calls stk_tick_resolution() which accesses the kernel service).
See also
stk_ticks_from_ms, STK_WAIT_INFINITE
Examples
D:/SVN/private/stk/interop/c/include/stk_c.h.

Definition at line 638 of file stk_c.cpp.

638{ return static_cast<stk_timeout_t>(stk::GetTicksFromMsClampedToTimeout(static_cast<stk::Timeout>(ms))); }
static Timeout GetTicksFromMsClampedToTimeout(Timeout ms)
Convert milliseconds to ticks and clamp the result to a Timeout type.
Definition stk_helper.h:419

References stk::GetTicksFromMsClampedToTimeout().

Here is the call graph for this function:

◆ stk_ticks_from_ms_r()

stk_tick_t stk_ticks_from_ms_r ( stk_time_t msec,
uint32_t resolution )
inlinestatic

Get ticks from milliseconds using an explicit tick resolution.

Parameters
[in]msecMilliseconds to convert.
[in]resolutionMicroseconds per tick (see stk_tick_resolution()).
Returns
Ticks.
Note
Equivalent to stk::GetTicksFromMsec(msec, resolution). Use this overload when the resolution is already cached to avoid a repeated call to stk_tick_resolution().
Examples
D:/SVN/private/stk/interop/c/include/stk_c.h.

Definition at line 680 of file stk_c.h.

681{
682 stk_time_t result = 0LL;
683
684 if (resolution != 0U)
685 {
686 const stk_time_t total_scaled = msec * 1000LL;
687 result = total_scaled / STK_STATIC_CAST(stk_time_t, resolution);
688 }
689
690 return STK_STATIC_CAST(stk_tick_t, result);
691}

References STK_STATIC_CAST.

Referenced by stk_ticks_from_ms().

Here is the caller graph for this function:

◆ stk_tid()

stk_tid_t stk_tid ( void )

Returns current task/thread ID (the value set by stk_task_set_id).

Returns
Task identifier (0 if not set).
Examples
D:/SVN/private/stk/interop/c/include/stk_c.h.

Definition at line 633 of file stk_c.cpp.

633{ return stk::GetTid(); }
static TId GetTid()
Get task/thread Id of the calling task.
Definition stk_helper.h:358

References stk::GetTid().

Here is the call graph for this function:

◆ stk_time_now_ms()

stk_time_t stk_time_now_ms ( void )

Returns current time in milliseconds since kernel start.

Returns
Time in milliseconds.
Examples
D:/SVN/private/stk/interop/c/include/stk_c.h.

Definition at line 636 of file stk_c.cpp.

636{ return stk::GetTimeNowMs(); }
static Time GetTimeNowMs()
Get current time in milliseconds since kernel start.
Definition stk_helper.h:445

References stk::GetTimeNowMs().

Here is the call graph for this function:

◆ stk_tls_get()

void * stk_tls_get ( void )

Get thread-local pointer (platform-specific slot).

Returns
Pointer previously stored with stk_tls_set() (NULL if never set).
Examples
D:/SVN/private/stk/interop/c/include/stk_c.h.

◆ stk_tls_set()

void stk_tls_set ( void * ptr)

Set thread-local pointer.

Parameters
[in]ptrPointer value to store for the current task/thread.
Examples
D:/SVN/private/stk/interop/c/include/stk_c.h.

◆ stk_yield()

void stk_yield ( void )

Voluntarily give up CPU to another ready task (cooperative yield).

Examples
D:/SVN/private/stk/interop/c/include/stk_c.h.

Definition at line 650 of file stk_c.cpp.

650{ stk::Yield(); }
static void Yield()
Notify scheduler to switch to the next runnable task.
Definition stk_helper.h:536

References stk::Yield().

Here is the call graph for this function: