10#ifndef STK_STRATEGY_RM_H_
11#define STK_STRATEGY_RM_H_
68template <EMonotonicSwitchStrategyType TStrategyType>
124 bool higher_priority =
false;
125 switch (TStrategyType)
205 while (itr != start);
329 template <u
int32_t TTaskCount>
353 template <u
int32_t TTaskCount>
380 while (itr != start);
427 bool schedulable =
true;
430 for (uint32_t t = 1U; t < count; )
433 const uint32_t Cx = tasks[t].
duration;
434 const uint32_t Tx = tasks[t].
period;
440 for (uint32_t i = 0U; i < t; ++i)
445 if ((w != w0) && (w <= Tx))
452 schedulable &= (w <= Tx);
472 for (uint32_t i = 0U; i < count; ++i)
474 const uint16_t task_load =
static_cast<uint16_t
>(tasks[i].
duration * 100U / tasks[i].
period);
488 static inline uint32_t
idiv_ceil(uint32_t x, uint32_t y)
490 uint32_t result = 0U;
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
Makes destructors virtual and compliant to strict rules if STK_STRICT_COMPLIANCY=0.
Round-Robin task-switching strategy (stk::SwitchStrategyRoundRobin / stk::SwitchStrategyRR).
Namespace of STK package.
SwitchStrategyMonotonic< MSS_TYPE_RATE > SwitchStrategyRM
Shorthand alias for SwitchStrategyMonotonic<MSS_TYPE_RATE>: Rate-Monotonic scheduling (shorter schedu...
SwitchStrategyMonotonic< MSS_TYPE_DEADLINE > SwitchStrategyDM
Shorthand alias for SwitchStrategyMonotonic<MSS_TYPE_DEADLINE>: Deadline-Monotonic scheduling (shorte...
EMonotonicSwitchStrategyType
Policy selector for SwitchStrategyMonotonic: determines the timing attribute used to assign fixed pri...
@ MSS_TYPE_DEADLINE
Deadline-Monotonic (DM): shorter execution deadline -> higher priority. Priority is derived from GetH...
@ MSS_TYPE_RATE
Rate-Monotonic (RM): shorter scheduling period -> higher priority. Priority is derived from GetHrtPer...
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.
DLEntryType * GetNext()
Get the next entry in the list.
DLHeadType * GetHead()
Get the list head this entry currently belongs to.
DLEntryType * GetPrev()
Get the previous entry in the list.
Monotonic scheduling strategy: Rate-Monotonic (RM) or Deadline-Monotonic (DM), selected at compile ti...
EConfig
Compile-time capability flags reported to the kernel.
@ PRIORITY_INHERITANCE_API
void RemoveTask(IKernelTask *task) override
Remove a task from the list.
SwitchStrategyMonotonic()
Construct an empty strategy with no tasks.
void OnTaskWake(IKernelTask *) override
Not supported, asserts unconditionally.
IKernelTask::ListHeadType m_tasks
void OnTaskSleep(IKernelTask *) override
Not supported, asserts unconditionally.
STK_NONCOPYABLE_CLASS(SwitchStrategyMonotonic)
STK_VIRT_DTOR ~SwitchStrategyMonotonic()=default
Destructor.
size_t GetSize() const override
Get the total number of tasks managed by this strategy.
IKernelTask * GetNext() override
Select and return the highest-priority non-sleeping task.
void AddTask(IKernelTask *task) override
Add a task to the priority-sorted runnable list.
IKernelTask * GetFirst() override
Get the first task in the managed set (used by the kernel for initial scheduling).
Utility class providing static methods for Worst-Case Response Time (WCRT) schedulability analysis of...
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.
static uint32_t idiv_ceil(uint32_t x, uint32_t y)
Compute the ceiling of an integer division: ceil(x / y).
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 task
CPU load contributed by this task alone, in percent: floor(C / T * 100) = floor(duration * 100 / peri...
uint16_t total
Cumulative CPU load of this task plus all higher-priority tasks, in percent (running sum from index 0...
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.