10#ifndef STK_STRATEGY_MONOTONIC_H_
11#define STK_STRATEGY_MONOTONIC_H_
70template <EMonotonicSwitchStrategyType TStrategyType>
128 bool higher_priority =
false;
129 switch (TStrategyType)
209 while (itr != start);
334 template <u
int32_t TTaskCount>
361 template <u
int32_t TTaskCount>
382 if (idx < TTaskCount)
391 while (itr != start);
436 bool schedulable =
true;
442 for (uint32_t t = 1U; t < count; ++t)
444 const uint32_t Cx = tasks[t].
duration;
445 const uint32_t Tx = tasks[t].
period;
449 bool converged =
false;
454 for (uint32_t i = 0U; i < t; ++i)
459 if ((w != w0) && (w <= Tx))
494 for (uint32_t i = 0U; i < count; ++i)
496 uint16_t task_load = 0U;
499 if (tasks[i].period != 0U)
501 task_load =
static_cast<uint16_t
>(tasks[i].
duration * 100U / tasks[i].
period);
517 static inline uint32_t
idiv_ceil(uint32_t x, uint32_t y)
519 uint32_t result = 0U;
557template <sched::EMonotonicSwitchStrategyType TStrategyType>
Contains interface definitions of the library.
#define STK_ASSERT(e)
Runtime assertion. Halts execution if the expression e evaluates to false.
#define STK_VIRT_DTOR
Expands to nothing if STK_STRICT_COMPLIANCY=0 (non-virtual destructors, smaller objects),...
Namespace of STK package.
sched::SwitchStrategyEDF SwitchStrategyEDF __stk_attr_deprecated_type("Use stk::sched::SwitchStrategyEDF")
Task-switching strategies (stk::sched::SwitchStrategy*) and their helpers (priority bitmaps,...
SwitchStrategyMonotonic< MSS_TYPE_DEADLINE > SwitchStrategyDM
Shorthand alias for SwitchStrategyMonotonic<MSS_TYPE_DEADLINE>: Deadline-Monotonic scheduling (shorte...
SwitchStrategyMonotonic< MSS_TYPE_RATE > SwitchStrategyRM
Shorthand alias for SwitchStrategyMonotonic<MSS_TYPE_RATE>: Rate-Monotonic scheduling (shorter schedu...
EMonotonicSwitchStrategyType
Policy selector for SwitchStrategyMonotonic: determines the timing attribute used to assign fixed pri...
@ MSS_TYPE_RATE
Rate-Monotonic (RM): shorter scheduling period -> higher priority. Priority is derived from GetHrtPer...
@ MSS_TYPE_DEADLINE
Deadline-Monotonic (DM): shorter execution deadline -> higher priority. Priority is derived from GetH...
Scheduling-strategy-facing interface for a kernel task slot.
virtual Timeout GetHrtDeadline() const =0
Get HRT task deadline (max allowed task execution time).
DLHeadType ListHeadType
List head type for IKernelTask elements.
virtual bool IsSleeping() const =0
Check whether the task is currently sleeping.
virtual Timeout GetHrtPeriodicity() const =0
Get HRT task execution periodicity.
Interface for a task switching strategy implementation.
size_t GetSize() const
Get the number of entries currently in the list.
DLEntryType * GetFirst()
Get the first (front) entry without removing it.
DLHeadType * GetHead()
Get the list head this entry currently belongs to.
DLEntryType * GetPrev()
Get the previous entry in the list.
DLEntryType * GetNext()
Get the next entry in the list.
Monotonic scheduling strategy: Rate-Monotonic (RM) or Deadline-Monotonic (DM), selected at compile ti...
size_t GetSize() const override
Get the total number of tasks managed by this strategy.
STK_NONCOPYABLE_CLASS(SwitchStrategyMonotonic)
IKernelTask * GetNext() override
Select and return the highest-priority non-sleeping task.
void OnTaskWake(IKernelTask *) override
Not supported, asserts unconditionally.
void RemoveTask(IKernelTask *task) override
Remove a task from the list.
STK_VIRT_DTOR ~SwitchStrategyMonotonic()=default
Destructor.
IKernelTask * GetFirst() override
Get the first task in the managed set (reference task for the kernel, used when it starts and when al...
SwitchStrategyMonotonic()
Construct an empty strategy with no tasks.
EConfig
Compile-time capability flags reported to the kernel.
@ PRIORITY_INHERITANCE_API
void OnTaskSleep(IKernelTask *) override
Not supported, asserts unconditionally.
void AddTask(IKernelTask *task) override
Add a task to the priority-sorted runnable list.
IKernelTask::ListHeadType m_tasks
Utility class providing static methods for Worst-Case Response Time (WCRT) schedulability analysis of...
static uint32_t idiv_ceil(uint32_t x, uint32_t y)
Compute the ceiling of an integer division: ceil(x / y).
static bool CalculateWCRT(const TaskTiming tasks[], const uint32_t count, TaskInfo info[])
Compute the Worst-Case Response Time (WCRT) for each task in a fixed-priority periodic task set and d...
static void GetTaskCpuLoad(const TaskTiming tasks[], const uint32_t count, TaskInfo info[])
Compute per-task and cumulative CPU utilization, in whole percent.
static SchedulabilityCheckResult< TTaskCount > IsSchedulableWCRT(const ITaskSwitchStrategy *strategy)
Perform WCRT schedulability analysis on the task set registered with strategy.
Execution deadline and scheduling period for a single periodic HRT task, used as input to CalculateWC...
uint32_t period
Scheduling period T of the task (ticks), from GetHrtPeriodicity(). Used as the interference divisor T...
uint32_t duration
Worst-Case Execution Time C of the task (ticks), from GetHrtDeadline(). Used as the base cost and int...
CPU utilisation values for a single task, in whole percent.
uint16_t total
Cumulative CPU load of this task plus all higher-priority tasks, in percent (running sum from index 0...
uint16_t task
CPU load contributed by this task alone, in percent: floor(C / T * 100) = floor(duration * 100 / peri...
Analysis results for a single task: CPU load and computed WCRT.
uint32_t wcrt
Worst-Case Response Time in ticks. Task is schedulable if wcrt <= period (T).
TaskCpuLoad cpu_load
Per-task and cumulative CPU utilisation (see TaskCpuLoad).
Result of a WCRT schedulability test: overall verdict plus per-task details.
TaskInfo info[TTaskCount]
Per-task analysis results, ordered highest priority first (index 0 = highest priority task).
bool schedulable
true if every task's WCRT <= its period (T); false if any task misses its deadline.