10#ifndef STK_STRATEGY_FPRIORITY_H_
11#define STK_STRATEGY_FPRIORITY_H_
57template <u
int8_t MAX_PRIORITIES>
90 "MAX_PRIORITIES exceeds 32-bit bitmap width");
196 size_t total =
m_sleep.GetSize();
197 for (
Priority i = 0U; i < MAX_PRIORITIES; i += 1U)
329 #if defined(__GNUC__)
330 return static_cast<Priority>(31U - __builtin_clz(bitmap));
332 for (int8_t i = 31; i >= 0; --i)
334 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.
Namespace of STK package.
SwitchStrategyFixedPriority< 32 > SwitchStrategyFP32
Shorthand alias for SwitchStrategyFixedPriority<32>: 32 priority levels (0..31), using a single 32-bi...
Scheduling-strategy-facing interface for a kernel task slot.
DLHeadType ListHeadType
List head type for IKernelTask elements.
virtual bool IsSleeping() const =0
Check whether the task is currently sleeping.
virtual int32_t GetWeight() const =0
Get static base weight assigned to the task.
Interface for a task switching strategy implementation.
DLEntryType * GetPrev() const
Get the previous entry in the list.
DLHeadType * GetHead() const
Get the list head this entry currently belongs to.
DLEntryType * GetNext() const
Get the next entry in the list.
Fixed-priority preemptive scheduling strategy with round-robin arbitration within each priority level...
void AddTask(IKernelTask *task)
Add task to the runnable set at its fixed priority level.
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.
IKernelTask * GetFirst() const
Get the first task in the managed set (used by the kernel for initial scheduling).
~SwitchStrategyFixedPriority()
Destructor.
IKernelTask * m_prev[MAX_PRIORITIES]
static __stk_forceinline Priority GetTaskPriority(IKernelTask *task)
Get priority from the task..
STK_NONCOPYABLE_CLASS(SwitchStrategyFixedPriority)
bool OnTaskDeadlineMissed(IKernelTask *)
Not supported, asserts unconditionally.
void RemoveTask(IKernelTask *task)
Remove task from whichever list it currently occupies.
EPriority
Symbolic priority level constants for common use cases.
void OnTaskSleep(IKernelTask *task)
Notification that a task has entered the sleeping state.
void RemoveActive(IKernelTask *task)
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.
size_t GetSize() const
Get the total number of tasks managed by this strategy.
IKernelTask * GetNext()
Select and return the next task to run.
void OnTaskWake(IKernelTask *task)
Notification that a task has become runnable again.
EConfig
Compile-time capability flags reported to the kernel.
IKernelTask::ListHeadType m_tasks[MAX_PRIORITIES]
IKernelTask::ListHeadType m_sleep