|
oveRTOS C API
Embedded RTOS framework — build system, configuration, and portable C API
|
Mutex, counting semaphore, binary event, recursive mutex, and condition variable APIs. More...
Functions | |
| int | ove_mutex_init (ove_mutex_t *mtx, ove_mutex_storage_t *storage) |
| Initialise a non-recursive mutex using caller-supplied static storage. | |
| void | ove_mutex_deinit (ove_mutex_t mtx) |
| Release resources held by a mutex initialised with ove_mutex_init(). | |
| int | ove_sem_init (ove_sem_t *sem, ove_sem_storage_t *storage, unsigned int initial, unsigned int max) |
| Initialise a counting semaphore using caller-supplied static storage. | |
| void | ove_sem_deinit (ove_sem_t sem) |
| Release resources held by a semaphore initialised with ove_sem_init(). | |
| int | ove_event_init (ove_event_t *evt, ove_event_storage_t *storage) |
| Initialise a binary event object using caller-supplied static storage. | |
| void | ove_event_deinit (ove_event_t evt) |
| Release resources held by an event initialised with ove_event_init(). | |
| int | ove_recursive_mutex_init (ove_mutex_t *mtx, ove_mutex_storage_t *storage) |
| Initialise a recursive mutex using caller-supplied static storage. | |
| int | ove_condvar_init (ove_condvar_t *cv, ove_condvar_storage_t *storage) |
| Initialise a condition variable using caller-supplied static storage. | |
| void | ove_condvar_deinit (ove_condvar_t cv) |
| Release resources held by a condition variable initialised with ove_condvar_init(). | |
| int | ove_mutex_lock (ove_mutex_t mtx, uint32_t timeout_ms) |
| Acquire a non-recursive mutex, blocking until it is available or the timeout expires. | |
| void | ove_mutex_unlock (ove_mutex_t mtx) |
| Release a non-recursive mutex previously acquired by ove_mutex_lock(). | |
| int | ove_sem_take (ove_sem_t sem, uint32_t timeout_ms) |
| Decrement (take) a semaphore, blocking until a count is available or the timeout expires. | |
| void | ove_sem_give (ove_sem_t sem) |
| Increment (give) a semaphore, potentially unblocking a waiting thread. | |
| int | ove_event_wait (ove_event_t evt, uint32_t timeout_ms) |
| Wait for a binary event to be signalled. | |
| void | ove_event_signal (ove_event_t evt) |
| Signal a binary event, unblocking one waiting thread. | |
| void | ove_event_signal_from_isr (ove_event_t evt) |
| Signal a binary event from an interrupt service routine. | |
| int | ove_recursive_mutex_lock (ove_mutex_t mtx, uint32_t timeout_ms) |
| Acquire a recursive mutex, blocking until it is available or the timeout expires. | |
| void | ove_recursive_mutex_unlock (ove_mutex_t mtx) |
| Release one level of a recursive mutex lock. | |
| int | ove_condvar_wait (ove_condvar_t cv, ove_mutex_t mtx, uint32_t timeout_ms) |
| Atomically release a mutex and wait on a condition variable. | |
| void | ove_condvar_signal (ove_condvar_t cv) |
| Wake one thread waiting on a condition variable. | |
| void | ove_condvar_broadcast (ove_condvar_t cv) |
| Wake all threads waiting on a condition variable. | |
Mutex, counting semaphore, binary event, recursive mutex, and condition variable APIs.
CONFIG_OVE_SYNC to be defined. When CONFIG_OVE_SYNC is not set, every function is replaced by a static inline stub that returns OVE_ERR_NOT_SUPPORTED.Two allocation strategies are available for each primitive:
_create() / _destroy() — unified API that works in both heap and zero-heap mode. In zero-heap mode these are macros that generate per-call-site static storage._init() / _deinit() — explicit storage control with caller-supplied buffers. Use when creating objects in loops, arrays, or structs. | int ove_mutex_init | ( | ove_mutex_t * | mtx, |
| ove_mutex_storage_t * | storage | ||
| ) |
Initialise a non-recursive mutex using caller-supplied static storage.
CONFIG_OVE_SYNC.| [out] | mtx | Receives the opaque mutex handle on success. |
| [in] | storage | Pointer to statically allocated backend storage. Must remain valid for the lifetime of the mutex. |
| void ove_mutex_deinit | ( | ove_mutex_t | mtx | ) |
Release resources held by a mutex initialised with ove_mutex_init().
The static storage supplied at init time is not freed.
CONFIG_OVE_SYNC.| [in] | mtx | Handle returned by ove_mutex_init(). |
| int ove_sem_init | ( | ove_sem_t * | sem, |
| ove_sem_storage_t * | storage, | ||
| unsigned int | initial, | ||
| unsigned int | max | ||
| ) |
Initialise a counting semaphore using caller-supplied static storage.
CONFIG_OVE_SYNC.| [out] | sem | Receives the opaque semaphore handle on success. |
| [in] | storage | Pointer to statically allocated backend storage. Must remain valid for the lifetime of the semaphore. |
| [in] | initial | Initial count value. |
| [in] | max | Maximum count value. |
| void ove_sem_deinit | ( | ove_sem_t | sem | ) |
Release resources held by a semaphore initialised with ove_sem_init().
CONFIG_OVE_SYNC.| [in] | sem | Handle returned by ove_sem_init(). |
| int ove_event_init | ( | ove_event_t * | evt, |
| ove_event_storage_t * | storage | ||
| ) |
Initialise a binary event object using caller-supplied static storage.
A binary event starts in the unsignalled state. One waiter is unblocked per ove_event_signal() call.
CONFIG_OVE_SYNC.| [out] | evt | Receives the opaque event handle on success. |
| [in] | storage | Pointer to statically allocated backend storage. Must remain valid for the lifetime of the event. |
| void ove_event_deinit | ( | ove_event_t | evt | ) |
Release resources held by an event initialised with ove_event_init().
CONFIG_OVE_SYNC.| [in] | evt | Handle returned by ove_event_init(). |
| int ove_recursive_mutex_init | ( | ove_mutex_t * | mtx, |
| ove_mutex_storage_t * | storage | ||
| ) |
Initialise a recursive mutex using caller-supplied static storage.
A recursive mutex may be locked multiple times by the same thread without deadlocking. Each successful lock must be paired with an unlock.
CONFIG_OVE_SYNC.| [out] | mtx | Receives the opaque mutex handle on success. |
| [in] | storage | Pointer to statically allocated backend storage. Must remain valid for the lifetime of the mutex. |
| int ove_condvar_init | ( | ove_condvar_t * | cv, |
| ove_condvar_storage_t * | storage | ||
| ) |
Initialise a condition variable using caller-supplied static storage.
CONFIG_OVE_SYNC.| [out] | cv | Receives the opaque condition variable handle on success. |
| [in] | storage | Pointer to statically allocated backend storage. Must remain valid for the lifetime of the condvar. |
| void ove_condvar_deinit | ( | ove_condvar_t | cv | ) |
Release resources held by a condition variable initialised with ove_condvar_init().
CONFIG_OVE_SYNC.| [in] | cv | Handle returned by ove_condvar_init(). |
| int ove_mutex_lock | ( | ove_mutex_t | mtx, |
| uint32_t | timeout_ms | ||
| ) |
Acquire a non-recursive mutex, blocking until it is available or the timeout expires.
CONFIG_OVE_SYNC.| [in] | mtx | Mutex handle obtained from ove_mutex_init() or ove_mutex_create(). |
| [in] | timeout_ms | Maximum time to wait in milliseconds. Pass OVE_WAIT_FOREVER to block indefinitely. |
OVE_ERR_TIMEOUT if the deadline was reached, or another negative error code on failure.| void ove_mutex_unlock | ( | ove_mutex_t | mtx | ) |
Release a non-recursive mutex previously acquired by ove_mutex_lock().
CONFIG_OVE_SYNC.| [in] | mtx | Mutex handle to release. |
| int ove_sem_take | ( | ove_sem_t | sem, |
| uint32_t | timeout_ms | ||
| ) |
Decrement (take) a semaphore, blocking until a count is available or the timeout expires.
CONFIG_OVE_SYNC.| [in] | sem | Semaphore handle obtained from ove_sem_init() or ove_sem_create(). |
| [in] | timeout_ms | Maximum time to wait in milliseconds. Pass OVE_WAIT_FOREVER to block indefinitely. |
OVE_ERR_TIMEOUT if the deadline was reached, or another negative error code on failure.| void ove_sem_give | ( | ove_sem_t | sem | ) |
Increment (give) a semaphore, potentially unblocking a waiting thread.
CONFIG_OVE_SYNC.| [in] | sem | Semaphore handle to increment. |
| int ove_event_wait | ( | ove_event_t | evt, |
| uint32_t | timeout_ms | ||
| ) |
Wait for a binary event to be signalled.
Blocks the calling thread until ove_event_signal() or ove_event_signal_from_isr() is called on evt, or until the timeout expires. The event is automatically reset (consumed) after a successful wait.
CONFIG_OVE_SYNC.| [in] | evt | Event handle obtained from ove_event_init() or ove_event_create(). |
| [in] | timeout_ms | Maximum time to wait in milliseconds. Pass OVE_WAIT_FOREVER to block indefinitely. |
OVE_ERR_TIMEOUT if the deadline was reached, or another negative error code on failure.| void ove_event_signal | ( | ove_event_t | evt | ) |
Signal a binary event, unblocking one waiting thread.
Safe to call from any thread context. Must not be called from an ISR — use ove_event_signal_from_isr() instead.
CONFIG_OVE_SYNC.| [in] | evt | Event handle to signal. |
| void ove_event_signal_from_isr | ( | ove_event_t | evt | ) |
Signal a binary event from an interrupt service routine.
ISR-safe variant of ove_event_signal(). May trigger a context switch to a higher-priority thread after the ISR exits.
CONFIG_OVE_SYNC.| [in] | evt | Event handle to signal. |
| int ove_recursive_mutex_lock | ( | ove_mutex_t | mtx, |
| uint32_t | timeout_ms | ||
| ) |
Acquire a recursive mutex, blocking until it is available or the timeout expires.
The same thread may call this function multiple times without deadlocking. Each successful lock must be balanced by a call to ove_recursive_mutex_unlock().
CONFIG_OVE_SYNC.| [in] | mtx | Recursive mutex handle obtained from ove_recursive_mutex_init() or ove_recursive_mutex_create(). |
| [in] | timeout_ms | Maximum time to wait in milliseconds. Pass OVE_WAIT_FOREVER to block indefinitely. |
OVE_ERR_TIMEOUT if the deadline was reached, or another negative error code on failure.| void ove_recursive_mutex_unlock | ( | ove_mutex_t | mtx | ) |
Release one level of a recursive mutex lock.
Decrements the recursive lock count. The mutex is fully released and made available to other threads only when the count reaches zero.
CONFIG_OVE_SYNC.| [in] | mtx | Recursive mutex handle to unlock. |
| int ove_condvar_wait | ( | ove_condvar_t | cv, |
| ove_mutex_t | mtx, | ||
| uint32_t | timeout_ms | ||
| ) |
Atomically release a mutex and wait on a condition variable.
The mutex mtx must be held by the calling thread before this call. It is released atomically as the thread begins waiting. When the function returns (either due to a signal or timeout), mtx is re-acquired before returning to the caller.
CONFIG_OVE_SYNC.| [in] | cv | Condition variable handle obtained from ove_condvar_init() or ove_condvar_create(). |
| [in] | mtx | Mutex that guards the condition. Must be locked by the calling thread. |
| [in] | timeout_ms | Maximum time to wait in milliseconds. Pass OVE_WAIT_FOREVER to block indefinitely. |
OVE_ERR_TIMEOUT if the deadline was reached, or another negative error code on failure.| void ove_condvar_signal | ( | ove_condvar_t | cv | ) |
Wake one thread waiting on a condition variable.
If no threads are waiting, the signal is lost (not stored).
CONFIG_OVE_SYNC.| [in] | cv | Condition variable handle to signal. |
| void ove_condvar_broadcast | ( | ove_condvar_t | cv | ) |
Wake all threads waiting on a condition variable.
CONFIG_OVE_SYNC.| [in] | cv | Condition variable handle to broadcast on. |