21 #if KERNEL_EVENT_FLAGS 38 void TimedEventFlag_Callback(Thread* pclOwner_,
void* pvData_)
43 auto* pclEventFlag =
static_cast<EventFlag*
>(pvData_);
45 pclOwner_->SetExpired(
true);
46 pclOwner_->SetEventFlagMask(0);
48 pclEventFlag->WakeMe(pclOwner_);
87 auto bThreadYield =
false;
90 auto clEventTimer =
Timer {};
91 auto bUseTimer =
false;
97 const auto cs = CriticalGuard{};
135 if (0u != u32TimeMS_) {
138 clEventTimer.Start(
false, u32TimeMS_, TimedEventFlag_Callback,
this);
162 if (bUseTimer && bThreadYield) {
173 return Wait_i(u16Mask_, eMode_, 0);
180 return Wait_i(u16Mask_, eMode_, u32TimeMS_);
188 auto bReschedule =
false;
190 const auto cs = CriticalGuard{};
205 if (
nullptr != pclCurrent) {
209 auto* pclPrev = (
Thread*){};
211 pclPrev = pclCurrent;
212 pclCurrent = pclCurrent->
GetNext();
216 auto eThreadMode = pclPrev->GetEventFlagMode();
223 pclPrev->SetEventFlagMask(m_u16SetMask & u16ThreadMask);
229 u16NewMask &= ~(u16ThreadMask & u16Mask_);
236 if ((u16ThreadMask & m_u16SetMask) == u16ThreadMask) {
238 pclPrev->SetEventFlagMask(u16ThreadMask);
244 u16NewMask &= ~(u16ThreadMask & u16Mask_);
256 auto bIsTail =
false;
258 pclPrev = pclCurrent;
259 pclCurrent = pclCurrent->
GetNext();
281 m_u16SetMask = u16NewMask;
290 const auto cs = CriticalGuard{};
291 m_u16SetMask &= ~u16Mask_;
301 const auto cs = CriticalGuard{};
306 #endif // #if KERNEL_EVENT_FLAGS uint16_t m_u16SetMask
Event flags currently set in this object.
Block until all bits in the specified bitmask are set.
void UnBlock(Thread *pclThread_)
UnBlock Unblock a thread that is already blocked on this object, returning it to the "ready" state by...
uint16_t GetMask()
GetMask Returns the state of the 16-bit bitmask within this object.
void BlockPriority(Thread *pclThread_)
BlockPriority Same as Block(), but ensures that threads are added to the block-list in priority-order...
void Set(uint16_t u16Mask_)
Set Set additional flags in this object (logical OR). This API can potentially result in threads bloc...
Block until any bits in the specified bitmask are cleared.
void Clear(uint16_t u16Mask_)
ClearFlags - Clear a specific set of flags within this object, specific by bitmask.
uint16_t GetEventFlagMask()
GetEventFlagMask returns the thread's current event-flag mask, which is used in conjunction with the ...
Mark3::Thread * g_pclCurrent
PORT_PRIO_TYPE GetCurPriority(void)
GetCurPriority Return the priority of the current thread.
uint16_t Wait_i(uint16_t u16Mask_, EventFlagOperation eMode_, uint32_t u32TimeMS_)
Wait_i Interal abstraction used to manage both timed and untimed wait operations. ...
Single include file given to users of the Mark3 Kernel API.
void SetExpired(bool bExpired_)
SetExpired Set the status of the current blocking call on the thread.
void SetEventFlagMask(uint16_t u16Mask_)
SetEventFlagMask Sets the active event flag bitfield mask.
Block until all bits in the specified bitmask are cleared.
uint16_t Wait(uint16_t u16Mask_, EventFlagOperation eMode_)
Wait Block a thread on the specific flags in this event flag group.
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.
void SetEventFlagMode(EventFlagOperation eMode_)
SetEventFlagMode Sets the active event flag operation mode.
void Init()
Init Initializes the EventFlag object prior to use.
Thread * HighestWaiter()
HighestWaiter Return a pointer to the highest-priority thread in the thread-list. ...
T * GetHead()
GetHead Get the head node in the linked list.
void WakeMe(Thread *pclChosenOne_)
WakeMe Wake the given thread, currently blocking on this object.
void SetInitialized(void)
SetInitialized.
static Thread * GetCurrentThread()
GetCurrentThread Return the pointer to the currently-running thread.
#define PANIC_ACTIVE_EVENTFLAG_DESCOPED
Block until any bits in the specified bitmask are set.
static void Panic(uint16_t u16Cause_)
Panic Cause the kernel to enter its panic state.