SuperTinyKernel™ RTOS 1.05.3
Lightweight, high-performance, deterministic, bare-metal C++ RTOS for resource-constrained embedded systems. MIT Open Source License.
Loading...
Searching...
No Matches
stk::sync Namespace Reference

Synchronization primitives for task coordination and resource protection. More...

Classes

class  ScopedCriticalSection
 RAII-style low-level synchronization primitive for atomic code execution. Used as building brick for other stk::sync classes, consider using hw::CriticalSection::ScopedLock implementation instead. More...
class  ConditionVariable
 Condition Variable primitive for signaling between tasks based on specific predicates. More...
class  Event
 Binary synchronization event (signaled / non-signaled) primitive. More...
class  EventFlags
 32-bit event flags group for multi-flag synchronization between tasks. More...
class  Mutex
 Recursive mutex primitive that allows the same thread to acquire the lock multiple times. More...
class  Pipe
 Thread-safe FIFO communication pipe for inter-task data passing. More...
class  RWMutex
 Reader-Writer Lock synchronization primitive for non-recursive shared and exclusive access. More...
class  Semaphore
 Counting semaphore primitive for resource management and signaling. More...
class  SpinLock
 Recursive spinlock. More...

Detailed Description

Synchronization primitives for task coordination and resource protection.

ISR SAFETY GUIDELINES:

Special care must be taken when calling synchronization methods from within an Interrupt Service Routine (ISR).

As a general rule, methods that can cause the caller to block or sleep are STRICTLY FORBIDDEN in ISRs.

Primitive ISR Safe Methods
Event Set(), Pulse(), Reset(), TryWait()
EventFlags Set(), Clear(), Get(), TryWait(), Wait(NO_WAIT)
Semaphore Signal(), TryWait()
SpinLock None
Mutex None
RWMutex None
ConditionVariable NotifyOne(), NotifyAll(), Wait(NO_WAIT)
Pipe Write(NO_WAIT), WriteBulk(NO_WAIT), TryWrite(), TryWriteBulk(), Read(NO_WAIT), ReadBulk(NO_WAIT), TryRead(), TryReadBulk()

NOTE:

  • SpinLock, Mutex, RWMutex: Ownership is tied to a Task ID (TId). Since ISRs lack a valid Task ID context, and these primitives use internal Mutex logic for state protection, their operations are never safe in ISRs.

WARNING:

  • Calling a blocking method from an ISR will lead to undefined behavior, memory corruption, or a deadlock. In debug build STK_ASSERT will break code execution if ineligible for ISR method is called.