37 CHECK_TEXT(
false,
"expecting assertion when empty");
59 CHECK_TEXT(
false,
"expecting assertion - OnTaskSleep not supported");
71 CHECK_TEXT(
false,
"expecting assertion - OnTaskWake not supported");
99 CHECK_TEXT(
false,
"expecting assertion - OnTaskDeadlineMissed not supported");
123 CHECK_EQUAL(0, strategy->
GetSize());
129 CHECK_TEXT(
false,
"expecting assertion when empty");
138template <
class _SwitchStrategy>
147 kernel.
AddTask(&task1, 300, 300, 0);
148 kernel.
AddTask(&task3, 100, 100, 0);
149 kernel.
AddTask(&task2, 200, 200, 0);
153 CHECK_EQUAL_TEXT(&task3, next->
GetUserTask(),
"task3 must be selected as highest priority");
157 CHECK_EQUAL_TEXT(&task3, next->
GetUserTask(),
"Highest priority task must repeat (no round-robin)");
163 CHECK_EQUAL_TEXT(&task2, next->
GetUserTask(),
"task2 becomes highest priority after task3 removal");
169 CHECK_EQUAL_TEXT(&task1, next->
GetUserTask(),
"task1 remains as only task");
182template <
class _SwitchStrategy>
193 kernel.
AddTask(&task1, 300, 300, 0);
198 for (int32_t i = 0; i < 5; i++)
201 CHECK_EQUAL_TEXT(&task1, next->
GetUserTask(),
"Single task must always be selected");
206 kernel.
AddTask(&task2, 200, 200, 0);
209 CHECK_EQUAL_TEXT(&task2, next->
GetUserTask(),
"Higher priority task2 should preempt task1");
212 CHECK_EQUAL_TEXT(&task2, next->
GetUserTask(),
"Highest priority task always runs");
216 kernel.
AddTask(&task3, 100, 100, 0);
219 CHECK_EQUAL_TEXT(&task3, next->
GetUserTask(),
"Highest priority task3 should run first");
222 CHECK_EQUAL_TEXT(&task3, next->
GetUserTask(),
"Highest priority task always runs");
229 CHECK_EQUAL_TEXT(&task2, next->
GetUserTask(),
"task2 becomes highest priority after task3 removal");
232 CHECK_EQUAL_TEXT(&task2, next->
GetUserTask(),
"task2 remains highest priority");
237 CHECK_EQUAL_TEXT(&task1, next->
GetUserTask(),
"task1 remains as only task");
259 kernel.
AddTask(&task1, 50, 50, 0);
260 kernel.
AddTask(&task2, 60, 30, 0);
264 CHECK_EQUAL(100, result.info[0].cpu_load.total);
265 CHECK_EQUAL(150, result.info[1].cpu_load.total);
267 CHECK_FALSE_TEXT(result,
"Task set should be unschedulable according to WCRT");
281 kernel.
AddTask(&task1, 40, 20, 0);
282 kernel.
AddTask(&task2, 100, 30, 0);
283 kernel.
AddTask(&task3, 200, 10, 0);
286 CHECK_TEXT(result,
"Task set should be schedulable according to WCRT");
288 CHECK_EQUAL(50, result.info[0].cpu_load.total);
289 CHECK_EQUAL(80, result.info[1].cpu_load.total);
290 CHECK_EQUAL(85, result.info[2].cpu_load.total);
Namespace of STK package.
SwitchStrategyMonotonic< MSS_TYPE_RATE > SwitchStrategyRM
Shorthand alias for SwitchStrategyMonotonic<MSS_TYPE_RATE>: Rate-Monotonic scheduling (shorter schedu...
Namespace of the test inventory.
static void TestPriorityNext()
TestContext g_TestContext
Global instance of the TestContext.
static void TestAlgorithm()
Concrete implementation of IKernel.
void Initialize(uint32_t resolution_us=PERIODICITY_DEFAULT)
Prepare kernel for use: reset state, configure the platform, and register the service singleton.
ITaskSwitchStrategy * GetSwitchStrategy()
Get task-switching strategy instance owned by this kernel.
void RemoveTask(ITask *user_task)
Remove a previously added task from the kernel before Start().
void AddTask(ITask *user_task)
Register task for a soft real-time (SRT) scheduling.
Scheduling-strategy-facing interface for a kernel task slot.
virtual ITask * GetUserTask()=0
Get user task.
Interface for a task switching strategy implementation.
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 size_t GetSize() const =0
Get number of tasks currently managed by this strategy.
virtual IKernelTask * GetNext()=0
Advance the internal iterator and return the next runnable task.
virtual IKernelTask * GetFirst() const =0
Get first task.
virtual bool OnTaskDeadlineMissed(IKernelTask *task)=0
Notification that a task has exceeded its HRT deadline; returns whether the strategy can recover with...
Monotonic scheduling strategy: Rate-Monotonic (RM) or Deadline-Monotonic (DM), selected at compile ti...
IKernelTask * GetFirst() const
Get the first task in the managed set (used by the kernel for initial scheduling).
static SchedulabilityCheckResult< _TaskCount > IsSchedulableWCRT(const ITaskSwitchStrategy *strategy)
Perform WCRT schedulability analysis on the task set registered with strategy.
Throwable class for catching assertions from STK_ASSERT_HANDLER().