10#ifndef STK_STRATEGY_FPRIORITY_H_
11#define STK_STRATEGY_FPRIORITY_H_
57template <u
int8_t MAX_PRIORITIES>
124 const bool is_tail = (
m_prev[prio] ==
m_tasks[prio].GetLast());
176 next = (*
m_prev[prio]->GetNext());
199 first_task = (*
m_sleep.GetFirst());
204 first_task = (*
m_tasks[prio].GetFirst());
217 size_t total =
m_sleep.GetSize();
218 for (
Priority i = 0U; i < MAX_PRIORITIES; ++i)
356 return static_cast<Priority>(weight);
379 #if defined(__GNUC__)
382 for (int8_t i = 31; i >= 0; --i)
384 if (bitmap & (1U << i))
Contains interface definitions of the library.
#define __stk_forceinline
Forces compiler to always inline the decorated function, regardless of optimisation level.
#define STK_ASSERT(e)
Runtime assertion. Halts execution if the expression e evaluates to false.
#define STK_STATIC_ASSERT_DESC(X, DESC)
Compile-time assertion with a custom error description. Produces a compilation error if X is false.
#define STK_VIRT_DTOR
Makes destructors virtual and compliant to strict rules if STK_STRICT_COMPLIANCY=0.
Namespace of STK package.
SwitchStrategyFixedPriority< 32 > SwitchStrategyFP32
Shorthand alias for SwitchStrategyFixedPriority<32>: 32 priority levels (0..31), using a single 32-bi...
int32_t Weight
Weight value (aka priority).
Scheduling-strategy-facing interface for a kernel task slot.
virtual Weight GetWeight() const =0
Get static base weight assigned to the task.
DLHeadType ListHeadType
List head type for IKernelTask elements.
virtual bool IsSleeping() const =0
Check whether the task is currently sleeping.
Interface for a task switching strategy implementation.
DLEntryType * GetNext()
Get the next entry in the list.
DLHeadType * GetHead()
Get the list head this entry currently belongs to.
DLEntryType * GetPrev()
Get the previous entry in the list.
Fixed-priority preemptive scheduling strategy with round-robin arbitration within each priority level...
static __stk_forceinline Priority GetTaskPriorityFromWeight(int32_t weight)
Get priority from the task.
SwitchStrategyFixedPriority()
Construct an empty strategy with all priority levels empty, a clear bitmap, and null cursors.
void AddActive(IKernelTask *task)
Append a task to its priority level's runnable list and update the bitmap.
STK_VIRT_DTOR ~SwitchStrategyFixedPriority()=default
Destructor.
IKernelTask * GetFirst() override
Get the first task in the managed set (used by the kernel for initial scheduling).
void OnTaskSleep(IKernelTask *task) override
Notification that a task has entered the sleeping state.
IKernelTask * m_prev[MAX_PRIORITIES]
static __stk_forceinline Priority GetTaskPriority(IKernelTask *task)
Get priority from the task.
IKernelTask * GetNext() override
Select and return the next task to run.
STK_NONCOPYABLE_CLASS(SwitchStrategyFixedPriority)
void AddTask(IKernelTask *task) override
Add task to the runnable set at its fixed priority level.
void RemoveTask(IKernelTask *task) override
Remove task from whichever list it currently occupies.
EPriority
Symbolic priority level constants for common use cases.
void OnTaskWeightChange(IKernelTask *task, Weight old_weight) override
Move a runnable task to a new priority level after its weight changed.
void RemoveActive(IKernelTask *task, const Priority prio)
Remove a task from its priority level's runnable list and update the bitmap/cursor.
static __stk_forceinline Priority GetHighestReadyPriority(uint32_t bitmap)
Find the index of the highest set bit in bitmap.
void OnTaskWake(IKernelTask *task) override
Notification that a task has become runnable again.
EConfig
Compile-time capability flags reported to the kernel.
@ PRIORITY_INHERITANCE_API
IKernelTask::ListHeadType m_tasks[MAX_PRIORITIES]
IKernelTask::ListHeadType m_sleep
size_t GetSize() const override
Get the total number of tasks managed by this strategy.