![]() |
SuperTinyKernel™ RTOS 1.06.0
Lightweight, high-performance, deterministic, bare-metal C++ RTOS for resource-constrained embedded systems. MIT Open Source License.
|
Utility class providing static methods for Worst-Case Response Time (WCRT) schedulability analysis of a monotonic HRT task set. More...
#include <stk_strategy_monotonic.h>
Classes | |
| class | TaskTiming |
| Execution deadline and scheduling period for a single periodic HRT task, used as input to CalculateWCRT() and GetTaskCpuLoad(). More... | |
| class | TaskCpuLoad |
| CPU utilisation values for a single task, in whole percent. More... | |
| class | TaskInfo |
| Analysis results for a single task: CPU load and computed WCRT. More... | |
| class | SchedulabilityCheckResult |
| Result of a WCRT schedulability test: overall verdict plus per-task details. More... | |
Static Public Member Functions | |
| template<uint32_t _TaskCount> | |
| 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 determine schedulability. | |
| static void | GetTaskCpuLoad (const TaskTiming *tasks, const uint32_t count, TaskInfo *info) |
| Compute per-task and cumulative CPU utilization, in whole percent. | |
Static Private Member Functions | |
| static __stk_forceinline int32_t | idiv_ceil (uint32_t x, uint32_t y) |
Utility class providing static methods for Worst-Case Response Time (WCRT) schedulability analysis of a monotonic HRT task set.
Determines whether a set of periodic tasks can meet all their deadlines under Rate-Monotonic or Deadline-Monotonic scheduling, assuming fully preemptive execution and no resource-sharing blocking.
static. This class is not instantiated, call its methods directly as SchedulabilityCheck::IsSchedulableWCRT<N>(strategy). Definition at line 281 of file stk_strategy_monotonic.h.
|
inlinestatic |
Compute the Worst-Case Response Time (WCRT) for each task in a fixed-priority periodic task set and determine schedulability.
Evaluates schedulability using standard iterative WCRT recurrence. Assumptions:
Within this function, local variable Cx holds tasks[t].duration (WCET C) and Tx holds tasks[t].period (period T), matching standard WCRT notation directly.
For each task t the recurrence is initialised as W(0) = Cx and iterated:
where the sum runs over all higher-priority tasks j (index < t). Cj = tasks[j].duration and Tj = tasks[j].period. Iteration continues until convergence (W(n+1) == W(n)) or W(n+1) > Tx (deadline miss confirmed). A goto is used for the iteration step to avoid re-initialising loop variables inside the outer for block.
The highest-priority task (index 0) has no higher-priority interference; its WCRT is set directly to its own WCET (tasks[0].duration) without iteration.
| [in] | tasks | Array of TaskTiming in descending priority order (index 0 = highest). |
| [in] | count | Number of tasks in tasks. |
| [out] | info | Array of TaskInfo of size count. info[i].wcrt receives the computed WCRT for task i on return. |
true if every task's WCRT <= its period (Tx); false if any task misses. Definition at line 428 of file stk_strategy_monotonic.h.
References stk::SchedulabilityCheck::TaskTiming::duration, idiv_ceil(), stk::SchedulabilityCheck::TaskTiming::period, and stk::SchedulabilityCheck::TaskInfo::wcrt.
Referenced by IsSchedulableWCRT().
|
inlinestatic |
Compute per-task and cumulative CPU utilization, in whole percent.
| [in] | tasks | Array of TaskTiming in descending priority order (index 0 = highest). |
| [in] | count | Number of tasks in tasks. |
| [out] | info | Array of TaskInfo of size count. info[i].cpu_load is populated on return. |
Definition at line 469 of file stk_strategy_monotonic.h.
References stk::SchedulabilityCheck::TaskInfo::cpu_load, stk::SchedulabilityCheck::TaskCpuLoad::task, and stk::SchedulabilityCheck::TaskCpuLoad::total.
Referenced by IsSchedulableWCRT().
|
inlinestaticprivate |
Integer ceiling division: returns ceil(x / y) = x/y + (xy > 0 ? 1 : 0). Equivalent to (int32_t)ceil((float)x / y) but exact and branch-free for integers. Reference: http://stackoverflow.com/questions/2745074/fast-ceiling-of-an-integer-division-in-c-c
Definition at line 487 of file stk_strategy_monotonic.h.
References __stk_forceinline.
Referenced by CalculateWCRT().
|
inlinestatic |
Perform WCRT schedulability analysis on the task set registered with strategy.
| _TaskCount | Number of tasks to analyse. Must equal the number of tasks currently registered with strategy (asserted at runtime: idx == _TaskCount). |
| [in] | strategy | Pointer to the monotonic scheduling strategy whose task list is analysed. Must not be nullptr and must have at least one task registered. |
m_tasks list in priority order (index 0 = highest priority). For each task, period is populated from GetHrtPeriodicity() and duration from GetHrtDeadline() before invoking GetTaskCpuLoad() and CalculateWCRT(). Definition at line 361 of file stk_strategy_monotonic.h.
References CalculateWCRT(), stk::SchedulabilityCheck::TaskTiming::duration, stk::ITaskSwitchStrategy::GetFirst(), stk::util::DListHead< T, _ClosedLoop >::GetFirst(), stk::util::DListEntry< T, _ClosedLoop >::GetHead(), stk::IKernelTask::GetHrtDeadline(), stk::IKernelTask::GetHrtPeriodicity(), stk::util::DListEntry< T, _ClosedLoop >::GetNext(), stk::util::DListHead< T, _ClosedLoop >::GetSize(), GetTaskCpuLoad(), stk::SchedulabilityCheck::SchedulabilityCheckResult< _TaskCount >::info, stk::SchedulabilityCheck::TaskTiming::period, stk::SchedulabilityCheck::SchedulabilityCheckResult< _TaskCount >::schedulable, and STK_ASSERT.
Referenced by stk_kernel_is_schedulable().