10#ifndef STK_STRATEGY_SWRROBIN_H_
11#define STK_STRATEGY_SWRROBIN_H_
145 int32_t max_weight = INT32_MIN;
153 if (candidate_weight > max_weight)
155 max_weight = candidate_weight;
159 while ((itr = (*itr->
GetNext())) != start);
Contains interface definitions of the library.
#define STK_ASSERT(e)
Runtime assertion. Halts execution if the expression e evaluates to false.
Namespace of STK package.
SwitchStrategySmoothWeightedRoundRobin SwitchStrategySWRR
Shorthand alias for SwitchStrategySmoothWeightedRoundRobin.
Scheduling-strategy-facing interface for a kernel task slot.
virtual int32_t GetCurrentWeight() const =0
Get the current dynamic weight value of this task.
DLHeadType ListHeadType
List head type for IKernelTask elements.
virtual bool IsSleeping() const =0
Check whether the task is currently sleeping.
virtual void SetCurrentWeight(int32_t weight)=0
Set the current dynamic weight value used by the scheduling strategy.
virtual int32_t GetWeight() const =0
Get static base weight assigned to the task.
Interface for a task switching strategy implementation.
DLHeadType * GetHead() const
Get the list head this entry currently belongs to.
DLEntryType * GetNext() const
Get the next entry in the list.
Smooth Weighted Round-Robin (SWRR) task-switching strategy: distributes CPU time proportionally to pe...
STK_NONCOPYABLE_CLASS(SwitchStrategySmoothWeightedRoundRobin)
bool OnTaskDeadlineMissed(IKernelTask *)
Not supported, asserts unconditionally.
size_t GetSize() const
Get the total number of tasks managed by this strategy.
SwitchStrategySmoothWeightedRoundRobin()
Construct an empty strategy with no tasks and a zero total weight.
IKernelTask * GetFirst() const
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 * GetNext()
Select and return the next task to run, applying one step of the SWRR algorithm.
int32_t m_total_weight
Sum of static weights (GetWeight()) of all tasks currently in m_tasks. Sleeping tasks are excluded....
void OnTaskSleep(IKernelTask *task)
Notification that a task has entered the sleeping state.
~SwitchStrategySmoothWeightedRoundRobin()
Destructor.
void OnTaskWake(IKernelTask *task)
Notification that a task has become runnable again.
EConfig
Compile-time capability flags reported to the kernel.
@ SLEEP_EVENT_API
This strategy requires OnTaskSleep() / OnTaskWake() events to keep m_total_weight accurate as tasks m...
@ DEADLINE_MISSED_API
This strategy does not use OnTaskDeadlineMissed() events.
@ WEIGHT_API
This strategy uses per-task static and dynamic weights; the kernel must expose the Weight API on each...
void RemoveActive(IKernelTask *task)
Remove task from m_tasks and update the total weight.
void RemoveTask(IKernelTask *task)
Remove task from whichever list it currently occupies.
void AddTask(IKernelTask *task)
Add task to the runnable set.
IKernelTask::ListHeadType m_tasks
Runnable tasks eligible for scheduling.
IKernelTask::ListHeadType m_sleep
Sleeping (blocked) tasks not eligible for scheduling.