35 void TimedMutex_Callback(Thread* pclOwner_,
void* pvData_)
40 auto* pclMutex =
static_cast<Mutex*
>(pvData_);
43 pclOwner_->SetExpired(
true);
46 pclMutex->WakeMe(pclOwner_);
112 auto clTimer =
Timer {};
113 auto bUseTimer =
false;
146 if (0u != u32WaitTimeMS_) {
149 clTimer.Start(
false, u32WaitTimeMS_, TimedMutex_Callback,
this);
157 if (m_uMaxPri <= g_pclCurrent->GetPriority()) {
161 while (
nullptr != pclTemp) {
166 pclTemp = pclTemp->GetNext();
193 return Claim_i(u32WaitTimeMS_);
201 auto bSchedule =
false;
Thread * m_pclOwner
Pointer to the thread that owns the mutex (when claimed)
PORT_PRIO_TYPE m_uMaxPri
Maximum priority of thread in queue, used for priority inheritence.
void UnBlock(Thread *pclThread_)
UnBlock Unblock a thread that is already blocked on this object, returning it to the "ready" state by...
uint8_t WakeNext()
WakeNext.
#define PANIC_ACTIVE_MUTEX_DESCOPED
void Release()
Release Release the mutex. When the mutex is released, another object can enter the mutex-protected r...
void BlockPriority(Thread *pclThread_)
BlockPriority Same as Block(), but ensures that threads are added to the block-list in priority-order...
void Claim()
Claim Claim the mutex. When the mutex is claimed, no other thread can claim a region protected by the...
uint8_t m_u8Recurse
The recursive lock-count when a mutex is claimed multiple times by the same owner.
void InheritPriority(PORT_PRIO_TYPE uXPriority_)
InheritPriority Allow the thread to run at a different priority level (temporarily) for the purpose o...
Mark3::Thread * g_pclCurrent
PORT_PRIO_TYPE GetCurPriority(void)
GetCurPriority Return the priority of the current thread.
bool Claim_i(uint32_t u32WaitTimeMS_)
Claim_i Abstracts out timed/non-timed mutex claim operations.
Single include file given to users of the Mark3 Kernel API.
The Thread Class. This object providing the fundamental thread control data structures and functions ...
void SetExpired(bool bExpired_)
SetExpired Set the status of the current blocking call on the thread.
bool IsInitialized(void)
IsInitialized.
static void Yield(void)
Yield Yield the thread - this forces the system to call the scheduler and determine what thread shoul...
T * GetTail()
GetTail Get the tail node of the linked list.
Thread * HighestWaiter()
HighestWaiter Return a pointer to the highest-priority thread in the thread-list. ...
void Init(bool bRecursive_=true)
Init Initialize a mutex object for use - must call this function before using the object...
bool GetExpired()
GetExpired Return the status of the most-recent blocking call on the thread.
void WakeMe(Thread *pclOwner_)
WakeMe Wake a thread blocked on the mutex. This is an internal function used for implementing timed m...
The Timer Class. This class provides kernel-managed timers, used to provide high-precision delays...
T * GetHead()
GetHead Get the head node in the linked list.
bool m_bRecursive
Whether or not the lock is recursive.
void SetInitialized(void)
SetInitialized.
PORT_PRIO_TYPE GetPriority(void)
GetPriority Return the priority of the current thread.
static Thread * GetCurrentThread()
GetCurrentThread Return the pointer to the currently-running thread.
bool m_bReady
State of the mutex - true = ready, false = claimed.
void SetPriority(PORT_PRIO_TYPE uXPriority_)
SetPriority. Set the priority of the Thread (running or otherwise) to a different level...
static void Panic(uint16_t u16Cause_)
Panic Cause the kernel to enter its panic state.
static bool SetScheduler(bool bEnable_)
SetScheduler Set the active state of the scheduler. When the scheduler is disabled, the next thread is never set; the currently running thread will run forever until the scheduler is enabled again. Care must be taken to ensure that we don't end up trying to block while the scheduler is disabled, otherwise the system ends up in an unusable state.