![]() |
SuperTinyKernel™ RTOS 1.08.x
Lightweight, high-performance, deterministic, bare-metal C++ RTOS for resource-constrained embedded systems. MIT Open Source License.
|
Interface for a task switching strategy implementation. More...
#include <stk_common.h>
Public Member Functions | |
| virtual void | AddTask (IKernelTask *task)=0 |
| Add task. | |
| virtual void | RemoveTask (IKernelTask *task)=0 |
| Remove task. | |
| virtual IKernelTask * | GetFirst ()=0 |
| Get first task. | |
| virtual IKernelTask * | GetNext ()=0 |
| Advance the internal iterator and return the next runnable task. | |
| virtual size_t | GetSize () const =0 |
| Get number of tasks currently managed by this strategy. | |
| virtual void | OnTaskSleep (IKernelTask *task)=0 |
| Notification that a task has entered sleep/blocked state. | |
| virtual void | OnTaskWake (IKernelTask *task)=0 |
| Notification that a task is becoming runnable again. | |
| virtual bool | OnTaskDeadlineMissed (IKernelTask *task) |
| Notification that a task has exceeded its HRT deadline; returns whether the strategy can recover without a hard fault. | |
| virtual void | OnTaskWeightChange (IKernelTask *task, Weight old_weight) |
| Notification that a runnable task's scheduling weight has changed. | |
Protected Member Functions | |
| ~ITaskSwitchStrategy ()=default | |
| Destructor. | |
Interface for a task switching strategy implementation.
Implementation must declare the following compile-time constants for reporting its capabilities to the kernel (place inside EConfig enum):
Example:
Definition at line 1306 of file stk_common.h.
|
protecteddefault |
Destructor.
|
pure virtual |
Add task.
| [in] | task | Pointer to the task to add. |
Implemented in stk::SwitchStrategyEDF, stk::SwitchStrategyFixedPriority< MAX_PRIORITIES >, stk::SwitchStrategyFixedPriority< 32 >, stk::SwitchStrategyMonotonic< TStrategyType >, stk::SwitchStrategyMonotonic< MSS_TYPE_DEADLINE >, stk::SwitchStrategyMonotonic< MSS_TYPE_RATE >, stk::SwitchStrategyRoundRobin, and stk::SwitchStrategySmoothWeightedRoundRobin.
|
pure virtual |
Get first task.
NULL if no tasks have been added. Implemented in stk::SwitchStrategyEDF, stk::SwitchStrategyFixedPriority< MAX_PRIORITIES >, stk::SwitchStrategyFixedPriority< 32 >, stk::SwitchStrategyMonotonic< TStrategyType >, stk::SwitchStrategyMonotonic< MSS_TYPE_DEADLINE >, stk::SwitchStrategyMonotonic< MSS_TYPE_RATE >, stk::SwitchStrategyRoundRobin, and stk::SwitchStrategySmoothWeightedRoundRobin.
|
pure virtual |
Advance the internal iterator and return the next runnable task.
NULL if no runnable tasks are available (in which case the kernel transitions to FSM_STATE_SLEEPING). Implemented in stk::SwitchStrategyEDF, stk::SwitchStrategyFixedPriority< MAX_PRIORITIES >, stk::SwitchStrategyFixedPriority< 32 >, stk::SwitchStrategyMonotonic< TStrategyType >, stk::SwitchStrategyMonotonic< MSS_TYPE_DEADLINE >, stk::SwitchStrategyMonotonic< MSS_TYPE_RATE >, stk::SwitchStrategyRoundRobin, and stk::SwitchStrategySmoothWeightedRoundRobin.
|
pure virtual |
Get number of tasks currently managed by this strategy.
Implemented in stk::SwitchStrategyEDF, stk::SwitchStrategyFixedPriority< MAX_PRIORITIES >, stk::SwitchStrategyFixedPriority< 32 >, stk::SwitchStrategyMonotonic< TStrategyType >, stk::SwitchStrategyMonotonic< MSS_TYPE_DEADLINE >, stk::SwitchStrategyMonotonic< MSS_TYPE_RATE >, stk::SwitchStrategyRoundRobin, and stk::SwitchStrategySmoothWeightedRoundRobin.
|
inlinevirtual |
Notification that a task has exceeded its HRT deadline; returns whether the strategy can recover without a hard fault.
| [in] | task | The task whose deadline was missed. Must not be nullptr. |
true — the strategy has absorbed the overrun (e.g. by escalating its scheduling mode): the kernel must not call HrtHardFailDeadline() for this tick. false — the strategy cannot recover: the kernel must call HrtHardFailDeadline() as normal. DEADLINE_MISSED_API == 1 in the concrete strategy's EConfig. Strategies that set DEADLINE_MISSED_API = 0 do not need to implement this method; the kernel will not call it and will proceed directly to HrtHardFailDeadline(). true carries no implicit side-effects on task sleep state or duration counters — normal tick-driven scheduling remains responsible for those. This call only communicates "do not hard-fault this tick." false (unrecoverable), which is the correct default for strategies that do not implement overrun recovery. Definition at line 1371 of file stk_common.h.
References STK_UNUSED.
|
pure virtual |
Notification that a task has entered sleep/blocked state.
| [in] | task | Pointer to the sleeping task, |
Implemented in stk::SwitchStrategyEDF, stk::SwitchStrategyFixedPriority< MAX_PRIORITIES >, stk::SwitchStrategyFixedPriority< 32 >, stk::SwitchStrategyMonotonic< TStrategyType >, stk::SwitchStrategyMonotonic< MSS_TYPE_DEADLINE >, stk::SwitchStrategyMonotonic< MSS_TYPE_RATE >, stk::SwitchStrategyRoundRobin, and stk::SwitchStrategySmoothWeightedRoundRobin.
|
pure virtual |
Notification that a task is becoming runnable again.
| [in] | task | Pointer to the waking task |
Implemented in stk::SwitchStrategyEDF, stk::SwitchStrategyFixedPriority< MAX_PRIORITIES >, stk::SwitchStrategyFixedPriority< 32 >, stk::SwitchStrategyMonotonic< TStrategyType >, stk::SwitchStrategyMonotonic< MSS_TYPE_DEADLINE >, stk::SwitchStrategyMonotonic< MSS_TYPE_RATE >, stk::SwitchStrategyRoundRobin, and stk::SwitchStrategySmoothWeightedRoundRobin.
|
inlinevirtual |
Notification that a runnable task's scheduling weight has changed.
| [in] | task | The task whose weight was just updated via SetWeight(). |
| [in] | old_weight | The previous weight of this task (required to remove it from the priority list belonging to that weight). |
Reimplemented in stk::SwitchStrategyFixedPriority< MAX_PRIORITIES >, and stk::SwitchStrategyFixedPriority< 32 >.
Definition at line 1389 of file stk_common.h.
References STK_UNUSED.
|
pure virtual |
Remove task.
| [in] | task | Pointer to the task to remove. |
Implemented in stk::SwitchStrategyEDF, stk::SwitchStrategyFixedPriority< MAX_PRIORITIES >, stk::SwitchStrategyFixedPriority< 32 >, stk::SwitchStrategyMonotonic< TStrategyType >, stk::SwitchStrategyMonotonic< MSS_TYPE_DEADLINE >, stk::SwitchStrategyMonotonic< MSS_TYPE_RATE >, stk::SwitchStrategyRoundRobin, and stk::SwitchStrategySmoothWeightedRoundRobin.