![]() |
SuperTinyKernel™ RTOS 1.06.x
Lightweight, high-performance, deterministic, bare-metal C++ RTOS for resource-constrained embedded systems. MIT Open Source License.
|
#include <cstddef>#include "stk_config.h"#include "stk.h"#include "sync/stk_sync.h"#include "memory/stk_memory.h"#include "stk_c.h"Go to the source code of this file.
Classes | |
| struct | stk_mutex_t |
| struct | stk_spinlock_t |
| struct | stk_cv_t |
| struct | stk_event_t |
| struct | stk_sem_t |
| struct | stk_ef_t |
| struct | stk_pipe_t |
| struct | stk_msgq_t |
| struct | stk_rwmutex_t |
Functions | |
| stk_mutex_t * | stk_mutex_create (stk_mutex_mem_t *const membuf, uint32_t membuf_size) |
| 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_spinlock_t * | stk_spinlock_create (stk_spinlock_mem_t *const membuf, uint32_t membuf_size) |
| 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_cv_t * | stk_cv_create (stk_cv_mem_t *const membuf, uint32_t membuf_size) |
| 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. | |
| 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_event_t * | stk_event_create (stk_event_mem_t *const membuf, uint32_t membuf_size, 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_sem_t * | stk_sem_create (stk_sem_mem_t *const membuf, uint32_t membuf_size, 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. | |
| uint16_t | stk_sem_get_count (const stk_sem_t *sem) |
| Get the current counter value. | |
| stk_ef_t * | stk_ef_create (stk_ef_mem_t *const membuf, uint32_t membuf_size, 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_pipe_t * | stk_pipe_create (stk_pipe_mem_t *const membuf, uint32_t membuf_size, 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_msgq_t * | stk_msgq_create (stk_msgq_mem_t *const membuf, uint32_t membuf_size, 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. | |
| bool | stk_msgq_is_full (const stk_msgq_t *mq) |
| Check whether the queue is currently full. | |
| uint8_t * | stk_msgq_get_buffer (stk_msgq_t *mq) |
| Get a pointer to the raw message data buffer. | |
| 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_rwmutex_t * | stk_rwmutex_create (stk_rwmutex_mem_t *const membuf, uint32_t membuf_size) |
| 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. | |