37 CHECK_TEXT(
false,
"expecting assertion when empty");
56 CHECK_EQUAL(0, strategy->
GetSize());
59 CHECK_EQUAL(0, strategy->
GetNext());
75 CHECK_TEXT(
false,
"expecting assertion - OnTaskDeadlineMissed not supported");
101 CHECK_EQUAL_TEXT(&task1, first->
GetUserTask(),
"expecting first task1");
104 CHECK_EQUAL_TEXT(&task1, next->
GetUserTask(),
"expecting next task1");
107 CHECK_EQUAL_TEXT(&task2, next->
GetUserTask(),
"expecting next task2");
110 CHECK_EQUAL_TEXT(&task3, next->
GetUserTask(),
"expecting next task3");
113 CHECK_EQUAL_TEXT(&task1, next->
GetUserTask(),
"expecting next task1 again (endless looping)");
116 CHECK_EQUAL_TEXT(&task2, next->
GetUserTask(),
"expecting next task2 again (endless looping)");
121 CHECK_EQUAL_TEXT(&task3, next->
GetUserTask(),
"expecting next task3 again (endless looping)");
124 CHECK_EQUAL_TEXT(&task1, next->
GetUserTask(),
"expecting next task1 again (endless looping)");
145 for (int32_t i = 0; i < 5; i++)
148 CHECK_EQUAL_TEXT(&task1, next->
GetUserTask(),
"Single task must always be selected");
156 CHECK_EQUAL_TEXT(&task1, next->
GetUserTask(),
"Next task should be task1");
158 CHECK_EQUAL_TEXT(&task2, next->
GetUserTask(),
"Next task should be task2");
160 CHECK_EQUAL_TEXT(&task1, next->
GetUserTask(),
"Next task should wrap to task1");
168 CHECK_EQUAL_TEXT(&task2, next->
GetUserTask(),
"Next task should be task2");
170 CHECK_EQUAL_TEXT(&task3, next->
GetUserTask(),
"Next task should be task3");
172 CHECK_EQUAL_TEXT(&task1, next->
GetUserTask(),
"Next task should wrap to task1");
180 CHECK_EQUAL_TEXT(&task3, next->
GetUserTask(),
"Next task should be task3 after removal");
182 CHECK_EQUAL_TEXT(&task1, next->
GetUserTask(),
"Next task should be task1 after removal");
184 CHECK_EQUAL_TEXT(&task3, next->
GetUserTask(),
"Next task should wrap to task3");
215 CHECK_EQUAL_TEXT(active->
SP, (
size_t)
task1->GetStack(),
"sleep: expecting low-priority task1");
221 CHECK_EQUAL_TEXT(active->
SP, (
size_t)
task2->GetStack(),
"sleep: expecting high-priority task2");
247 CHECK_EQUAL_TEXT(active->
SP, (
size_t)task2.GetStack(),
"expecting high-priority task2 on start");
250 CHECK_EQUAL_TEXT(active->
SP, (
size_t)task2.GetStack(),
"expecting task2");
262 CHECK_EQUAL_TEXT(active->
SP, (
size_t)task2.GetStack(),
"expecting high-priority task2 again after it slept");
266 CHECK_EQUAL_TEXT(active->
SP, (
size_t)task2.GetStack(),
"expecting high-priority task2 again");
void(* g_RelaxCpuHandler)()
__stk_relax_cpu handler.
Namespace of STK package.
void Sleep(uint32_t ticks)
Put calling process into a sleep state.
SwitchStrategyFixedPriority< 32 > SwitchStrategyFP32
Shorthand alias for SwitchStrategyFixedPriority<32>: 32 priority levels (0..31), using a single 32-bi...
Namespace of the test inventory.
static struct stk::test::PrioritySleepRelaxCpuContext g_PrioritySleepRelaxCpuContext
TestContext g_TestContext
Global instance of the TestContext.
static void PrioritySleepRelaxCpu()
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 Start()
Start the scheduler. This call does not return until all tasks have exited (KERNEL_DYNAMIC mode) or i...
void RemoveTask(ITask *user_task)
Remove a previously added task from the kernel before Start().
IPlatform * GetPlatform()
Get platform driver instance owned by this kernel.
void AddTask(ITask *user_task)
Register task for a soft real-time (SRT) scheduling.
Word SP
Stack Pointer (SP) register (note: must be the first entry in this struct).
Interface for a user task.
Scheduling-strategy-facing interface for a kernel task slot.
virtual ITask * GetUserTask()=0
Get user task.
Interface for a task switching strategy implementation.
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...
Fixed-priority preemptive scheduling strategy with round-robin arbitration within each priority level...
IKernelTask * GetFirst() const
Get the first task in the managed set (used by the kernel for initial scheduling).
PlatformTestMock * platform
PrioritySleepRelaxCpuContext()
Throwable class for catching assertions from STK_ASSERT_HANDLER().
void ProcessTick()
Process one tick.
Task mock for SwitchStrategySmoothWeightedRoundRobin and similar algorithms.