10#ifndef STK_STRATEGY_RM_H_
11#define STK_STRATEGY_RM_H_
68template <EMonotonicSwitchStrategyType _Type>
124 bool higher_priority;
151 if ((itr = (*itr->
GetNext())) == start)
203 while ((itr = (*itr->
GetNext())) != start);
336 template <u
int32_t _TaskCount>
360 template <u
int32_t _TaskCount>
384 while ((itr = (*itr->
GetNext())) != start);
430 bool schedulable =
true;
433 for (uint32_t t = 1; t < count; )
443 for (uint32_t i = 0; i < t; ++i)
446 if ((w != w0) && (w <= Tx))
453 schedulable &= (w <= Tx);
473 for (uint32_t t = 0; t < count; ++t)
475 uint16_t task_load = (uint16_t)(tasks[t].duration * 100 / tasks[t].period);
489 return x / y + (x % y > 0);
Contains interface definitions of the library.
#define __stk_forceinline
Forces compiler to always inline the decorated function, regardless of optimisation level.
#define STK_ASSERT(e)
Runtime assertion. Halts execution if the expression e evaluates to false.
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.
virtual IKernelTask * GetFirst() const =0
Get first task.
size_t GetSize() const
Get the number of entries currently in the list.
DLEntryType * GetFirst() const
Get the first (front) entry without removing it.
DLEntryType * GetPrev() const
Get the previous entry in the list.
DLHeadType * GetHead() const
Get the list head this entry currently belongs to.
DLEntryType * GetNext() const
Get the next entry in the list.
Monotonic scheduling strategy: Rate-Monotonic (RM) or Deadline-Monotonic (DM), selected at compile ti...
IKernelTask::ListHeadType m_tasks
EConfig
Compile-time capability flags reported to the kernel.
size_t GetSize() const
Get the total number of tasks managed by this strategy.
SwitchStrategyMonotonic()
Construct an empty strategy with no tasks.
IKernelTask * GetNext()
Select and return the highest-priority non-sleeping task.
void OnTaskWake(IKernelTask *)
Not supported, asserts unconditionally.
IKernelTask * GetFirst() const
Get the first task in the managed set (used by the kernel for initial scheduling).
bool OnTaskDeadlineMissed(IKernelTask *)
Not supported, asserts unconditionally.
~SwitchStrategyMonotonic()
Destructor.
void RemoveTask(IKernelTask *task)
Remove a task from the list.
void OnTaskSleep(IKernelTask *)
Not supported, asserts unconditionally.
STK_NONCOPYABLE_CLASS(SwitchStrategyMonotonic)
void AddTask(IKernelTask *task)
Add a task to the priority-sorted runnable list.
Utility class providing static methods for Worst-Case Response Time (WCRT) schedulability analysis of...
static void GetTaskCpuLoad(const TaskTiming *tasks, const uint32_t count, TaskInfo *info)
Compute per-task and cumulative CPU utilization, in whole percent.
static SchedulabilityCheckResult< _TaskCount > IsSchedulableWCRT(const ITaskSwitchStrategy *strategy)
Perform WCRT schedulability analysis on the task set registered with strategy.
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 __stk_forceinline int32_t idiv_ceil(uint32_t x, uint32_t 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[_TaskCount]
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.