10#ifndef STK_SYNC_MUTEX_H_
11#define STK_SYNC_MUTEX_H_
136 __stk_full_memfence();
181 __stk_full_memfence();
189 __stk_full_memfence();
#define STK_KERNEL_PANIC(id)
Called when the kernel detects an unrecoverable internal fault.
#define STK_ASSERT(e)
Runtime assertion. Halts execution if the expression e evaluates to false.
Implementation of synchronization primitive: stk::sync::ScopedCriticalSection.
Namespace of STK package.
const Timeout WAIT_INFINITE
Timeout value: block indefinitely until the synchronization object is signaled.
int32_t Timeout
Timeout time (ticks).
const Timeout NO_WAIT
Timeout value: return immediately if the synchronization object is not yet signaled (non-blocking pol...
TId GetTid()
Get task/thread Id of the calling task.
const TId TID_NONE
Reserved task/thread id representing zero/none thread id.
@ KERNEL_PANIC_ASSERT
Internal assertion failed (maps from STK_ASSERT).
bool IsInsideISR()
Check whether the CPU is currently executing inside a hardware interrupt service routine (ISR).
Synchronization primitives for task coordination and resource protection.
virtual TId GetTid() const =0
Get thread Id of this task.
virtual bool IsTimeout() const =0
Check if task woke up due to a timeout.
virtual void Wake(bool timeout)=0
Wake task.
IWaitObject::ListHeadType m_wait_list
tasks blocked on this object
ISyncObject()
Constructor.
Interface for mutex synchronization primitive.
Interface for the kernel services exposed to the user processes during run-time when Kernel started s...
virtual TId GetTid() const =0
Get thread Id of the currently running task.
static IKernelService * GetInstance()
Get CPU-local instance of the kernel service.
virtual IWaitObject * Wait(ISyncObject *sobj, IMutex *mutex, Timeout timeout)=0
Put calling process into a waiting state until synchronization object is signaled or timeout occurs.
RAII-style low-level synchronization primitive for atomic code execution. Used as building brick for ...
TId m_owner_tid
thread id of the current owner
void Unlock()
Release lock.
bool TryLock()
Acquire the lock.
uint16_t m_recursion_count
recursion depth
STK_NONCOPYABLE_CLASS(Mutex)
bool TimedLock(Timeout timeout)
Acquire lock.
static const uint16_t RECURSION_MAX
maximum nesting depth