![]() |
SuperTinyKernel™ RTOS 1.08.x
Lightweight, high-performance, deterministic, bare-metal C++ RTOS for resource-constrained embedded systems. MIT Open Source License.
|
Atomic busy-wait lock used as the global cross-core synchronisation primitive inside CriticalSection. More...
#include <stk_arch.h>
Classes | |
| class | ScopedLock |
| RAII guard that the spin lock is locked on construction and unlocked it on destruction. More... | |
Public Types | |
| enum | EState { UNLOCKED = 0 , LOCKED } |
| Internal lock state values. More... | |
Public Member Functions | |
| SpinLock () | |
| Construct a SpinLock (unlocked by default). | |
| void | Lock () |
| Acquire SpinLock, blocking until it is available. | |
| void | Unlock () |
| Release SpinLock, allowing another thread or core to acquire it. | |
| bool | TryLock () |
| Attempt to acquire SpinLock in a single non-blocking attempt. | |
| bool | IsLocked () const |
| Sample current lock state. | |
Protected Member Functions | |
| SpinLock (const SpinLock &)=delete | |
| SpinLock & | operator= (const SpinLock &)=delete |
Protected Attributes | |
| volatile bool | m_lock |
| Lock state (see EState). 8-byte aligned to occupy its own cache line word and avoid false sharing on SMP targets. | |
Atomic busy-wait lock used as the global cross-core synchronisation primitive inside CriticalSection.
s_StkCortexmCsuLock on the ARM Cortex-M back-end) after masking local interrupts, giving the combined interrupt-mask + cross-core guarantee described in CriticalSection. STK_SPINLOCK_TIMEOUT_US (default 5 seconds) of wall-clock spin time, computed at runtime from the core clock speed, and raises STK_KERNEL_PANIC(KERNEL_PANIC_SPINLOCK_DEADLOCK) - in all build configurations, not just debug builds. Definition at line 569 of file stk_arch.h.
Internal lock state values.
| Enumerator | |
|---|---|
| UNLOCKED | Lock is free and available for acquisition. |
| LOCKED | Lock is held by a thread or core. |
Definition at line 575 of file stk_arch.h.
|
inlineexplicit |
Construct a SpinLock (unlocked by default).
Definition at line 617 of file stk_arch.h.
References m_lock, and UNLOCKED.
Referenced by operator=(), and stk::hw::SpinLock::ScopedLock::ScopedLock().
|
protecteddelete |
|
inline |
Sample current lock state.
true if the lock is currently held; false if it is free. Definition at line 654 of file stk_arch.h.
| void stk::hw::SpinLock::Lock | ( | ) |
Acquire SpinLock, blocking until it is available.
Referenced by stk::hw::SpinLock::ScopedLock::ScopedLock().
| bool stk::hw::SpinLock::TryLock | ( | ) |
Attempt to acquire SpinLock in a single non-blocking attempt.
true if the lock was acquired; false if it was already held by another thread/core. | void stk::hw::SpinLock::Unlock | ( | ) |
|
protected |
Lock state (see EState). 8-byte aligned to occupy its own cache line word and avoid false sharing on SMP targets.
Definition at line 662 of file stk_arch.h.
Referenced by IsLocked(), operator=(), and SpinLock().