![]() |
SuperTinyKernel™ RTOS 1.06.0
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>
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 | |
| STK_NONCOPYABLE_CLASS (SpinLock) | |
| volatile bool m_lock | __stk_aligned (8) |
| 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.
g_CsuLock) after masking local interrupts, giving the combined interrupt-mask + cross-core guarantee described in CriticalSection. Definition at line 274 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 280 of file stk_arch.h.
|
inlineexplicit |
Construct a SpinLock (unlocked by default).
Definition at line 288 of file stk_arch.h.
References UNLOCKED.
Referenced by STK_NONCOPYABLE_CLASS().
|
protected |
Lock state (see EState). 8-byte aligned to occupy its own cache line word and avoid false sharing on SMP targets.
|
inline |
Sample current lock state.
true if the lock is currently held; false if it is free. Definition at line 325 of file stk_arch.h.
References LOCKED.
| void stk::hw::SpinLock::Lock | ( | ) |
Acquire SpinLock, blocking until it is available.
|
protected |
| 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 | ( | ) |