10#ifndef STK_STRATEGY_SWRROBIN_H_
11#define STK_STRATEGY_SWRROBIN_H_
178 int32_t max_weight = INT32_MIN;
187 if ((itr != skip) && (candidate_weight > max_weight))
189 max_weight = candidate_weight;
195 if (candidate_weight > max_weight)
197 max_weight = candidate_weight;
204 while (itr != start);
305 bool handled =
false;
Contains interface definitions of the library.
#define STK_UNUSED(X)
Explicitly marks a variable as unused to suppress compiler warnings.
#define STK_ASSERT(e)
Runtime assertion. Halts execution if the expression e evaluates to false.
#define __stk_constexpr_cpp17
constexpr definition for C++17 and above.
#define STK_VIRT_DTOR
Makes destructors virtual and compliant to strict rules if STK_STRICT_COMPLIANCY=0.
Namespace of STK package.
SwitchStrategySmoothWeightedRoundRobinT< true > SwitchStrategySmoothWeightedRoundRobinNoSleepYield
Smooth Weighted Round-Robin strategy where Yield() keeps the task runnable (NOSLEEP_YIELD_API = 1).
SwitchStrategySmoothWeightedRoundRobinT< false > SwitchStrategySmoothWeightedRoundRobin
Shorthand alias for SwitchStrategySmoothWeightedRoundRobinT<false>.
SwitchStrategySmoothWeightedRoundRobinT< true > SwitchStrategySWRR_NSY
Shorthand for SwitchStrategySmoothWeightedRoundRobinNoSleepYield.
SwitchStrategySmoothWeightedRoundRobinT< false > SwitchStrategySWRR
Shorthand alias for SwitchStrategySmoothWeightedRoundRobin.
static constexpr Weight NO_WEIGHT
Weight value: weight is not set.
Scheduling-strategy-facing interface for a kernel task slot.
virtual Weight GetCurrentWeight() const =0
Get the current dynamic weight value of this task.
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.
virtual void SetCurrentWeight(Weight weight)=0
Set the current dynamic weight value used by the scheduling strategy.
Interface for a task switching strategy implementation.
static constexpr size_t Value
DLEntryType * GetNext()
Get the next entry in the list.
DLHeadType * GetHead()
Get the list head this entry currently belongs to.
Smooth Weighted Round-Robin (SWRR) task-switching strategy: distributes CPU time proportionally to pe...
IKernelTask * m_yielded[STK_ALLOCATE_COUNT< NoSleepYield, 1U, 1U, 0U >::Value]
STK_NONCOPYABLE_CLASS(SwitchStrategySmoothWeightedRoundRobinT)
void AddTask(IKernelTask *task) override
Add task to the runnable set.
SwitchStrategySmoothWeightedRoundRobinT()
Construct an empty strategy with no tasks and a zero total weight.
EConfig
Compile-time capability flags reported to the kernel.
@ PRIORITY_INHERITANCE_API
void RemoveActive(IKernelTask *task)
Remove task from m_tasks and update the total weight.
IKernelTask::ListHeadType m_sleep
IKernelTask * GetNext() override
Select and return the next task to run, applying one step of the SWRR algorithm.
size_t GetSize() const override
Get the total number of tasks managed by this strategy.
void OnTaskWake(IKernelTask *task) override
Notification that a task has become runnable again.
void RemoveTask(IKernelTask *task) override
Remove task from whichever list it currently occupies.
bool OnTaskYield(IKernelTask *task) override
Notification that the running task called Yield() (non-HRT kernel modes only).
IKernelTask * GetFirst() override
Get first task in the managed set (used by the kernel for initial scheduling).
void AddActive(IKernelTask *task)
Append task to m_tasks and update the total weight.
IKernelTask::ListHeadType m_tasks
void OnTaskSleep(IKernelTask *task) override
Notification that a task has entered the sleeping state.
STK_VIRT_DTOR ~SwitchStrategySmoothWeightedRoundRobinT()=default
Destructor.