28TEST(KernelService, GetMsecToTicks)
104TEST(KernelService, InitStackFailure)
116 CHECK_TEXT(
false,
"AddTask() did not fail");
139 CHECK_EQUAL(tid, (
size_t)&task);
191 for (int32_t i = 0; i < 1000; ++i)
198TEST(KernelService, GetTimeNowMsWith10UsecTick)
212 for (int32_t i = 0; i < 1000; ++i)
249 CHECK_EQUAL(active->
SP, (
size_t)
task1->GetStack());
255 CHECK_EQUAL(active->
SP, (
size_t)
task2->GetStack());
261 CHECK_EQUAL(active->
SP, (
size_t)
task1->GetStack());
267 CHECK_EQUAL(active->
SP, (
size_t)
task2->GetStack());
281TEST(KernelService, SwitchToNext)
294 CHECK_EQUAL(active->
SP, (
size_t)task1.
GetStack());
298 CHECK_EQUAL(active->
SP, (
size_t)task2.GetStack());
311 CHECK_EQUAL(active->
SP, (
size_t)task2.GetStack());
320 CHECK_EQUAL(active->
SP, (
size_t)task2.GetStack());
323TEST(KernelService, SwitchToNextInactiveTask)
336 CHECK_EQUAL(active->
SP, (
size_t)task1.
GetStack());
340 CHECK_EQUAL(active->
SP, (
size_t)task2.GetStack());
379 CHECK_EQUAL_TEXT(active->
SP, (
size_t)
task1->GetStack(),
"sleep: expecting task1");
385 CHECK_EQUAL_TEXT(active->
SP, (
size_t)
task2->GetStack(),
"sleep: expecting task2");
398template <
class _SwitchStrategy>
412 CHECK_EQUAL_TEXT(active->
SP, (
size_t)task1.
GetStack(),
"expecting task1");
416 CHECK_EQUAL_TEXT(active->
SP, (
size_t)task2.GetStack(),
"expecting task2");
435 CHECK_EQUAL_TEXT(active->
SP, (
size_t)task2.GetStack(),
"expecting task2 after sleep");
439 CHECK_EQUAL_TEXT(active->
SP, (
size_t)task1.
GetStack(),
"expecting task1 after next tick");
457TEST(KernelService, SleepUntilRR)
462TEST(KernelService, SleepUntilSWRR)
467TEST(KernelService, SleepUntilFP31)
485 CHECK_EQUAL_TEXT(active->
SP, (
size_t)task1.
GetStack(),
"expecting task1");
489 CHECK_EQUAL_TEXT(active->
SP, (
size_t)task2.GetStack(),
"expecting task2");
501 CHECK_EQUAL_TEXT(active->
SP, (
size_t)task2.GetStack(),
"expecting task2 after sleep");
505 CHECK_EQUAL_TEXT(active->
SP, (
size_t)task1.
GetStack(),
"expecting task1 after next tick");
508TEST(KernelService, SleepUntilMissDeadline)
521 CHECK_EQUAL_TEXT(active->
SP, (
size_t)task1.
GetStack(),
"expecting task1");
525 CHECK_EQUAL_TEXT(active->
SP, (
size_t)task2.GetStack(),
"expecting task2");
541 CHECK_EQUAL_TEXT(active->
SP, (
size_t)task2.GetStack(),
"expecting task2 after sleep");
566 CHECK_EQUAL(idle->
SP, (
size_t)
task1->GetStack());
578 CHECK_EQUAL(active->SP, (
size_t)
task1->GetStack());
592TEST(KernelService, SleepAllAndWake)
627 CHECK_EQUAL(2,
platform->m_ticks_count);
640TEST(KernelService, SleepAndWakeTickless)
682TEST(KernelServiceIsrSafety, Common)
697 CHECK_TEXT(
false,
"Sleep is not allowed inside ISR");
709 CHECK_TEXT(
false,
"SleepUntil is not allowed inside ISR");
721 CHECK_TEXT(
false,
"Delay is not allowed inside ISR");
733 CHECK_TEXT(
false,
"Yield is not allowed inside ISR");
745 CHECK_TEXT(
false,
"GetTid is not allowed inside ISR");
void(* g_RelaxCpuHandler)()
__stk_relax_cpu handler.
Namespace of STK package.
static int64_t GetTimeNowMs()
Get current time in milliseconds since kernel start.
void Sleep(uint32_t ticks)
Put calling process into a sleep state.
static void DelayMs(uint32_t ms)
Delay calling process by busy-waiting until the deadline expires.
int64_t GetMsFromTicks(int64_t ticks, int32_t resolution)
Convert ticks to milliseconds.
Ticks GetTicks()
Get number of ticks elapsed since kernel start.
int64_t Ticks
Ticks value.
@ STACK_SLEEP_TRAP
Stack of the Sleep trap.
void Yield()
Notify scheduler to switch to the next runnable task.
void Delay(uint32_t ticks)
Delay calling process by busy-waiting until the deadline expires.
void SleepUntil(Ticks timestamp)
Put calling process into a sleep state until the specified timestamp.
@ PERIODICITY_DEFAULT
Default periodicity (microseconds), 1 millisecond.
TId GetTid()
Get task/thread Id of the calling task.
int32_t GetTickResolution()
Get number of microseconds in one tick.
static void SleepMs(uint32_t ms)
Put calling process into a sleep state.
Namespace of the test inventory.
TestContext g_TestContext
Global instance of the TestContext.
static void SleepAndWakeTicklessRelaxCpu()
static struct stk::test::SwitchToNextRelaxCpuContext g_SwitchToNextRelaxCpuContext
static void SwitchToNextRelaxCpu()
IKernelService * g_KernelService
static void SleepAllAndWakeRelaxCpu()
static void SleepRelaxCpu()
static struct stk::test::SleepAndWakeTicklessRelaxCpuContext g_SleepAndWakeTicklessRelaxCpuContext
bool g_InsideISR
ISR state.
static void DelayRelaxCpu()
static struct stk::test::DelayContext g_DelayContext
static struct stk::test::SleepAllAndWakeRelaxCpuContext g_SleepAllAndWakeRelaxCpuContext
static struct stk::test::SleepRelaxCpuContext g_SleepRelaxCpuContext
static void TestTaskSleep(bool until)
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.
void Start()
Start the scheduler. This call does not return until all tasks have exited (KERNEL_DYNAMIC mode) or i...
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 platform driver.
Word * GetStack() const
Get pointer to the stack memory.
TaskMock< ACCESS_USER > * task2
PlatformTestMock * platform
SwitchToNextRelaxCpuContext()
TaskMock< ACCESS_USER > * task1
TaskMock< ACCESS_USER > * task1
TaskMock< ACCESS_USER > * task2
PlatformTestMock * platform
PlatformTestMock * platform
TaskMock< ACCESS_USER > * task1
SleepAllAndWakeRelaxCpuContext()
SleepAndWakeTicklessRelaxCpuContext()
PlatformTestMock * platform
Throwable class for catching assertions from STK_ASSERT_HANDLER().
void EventTaskSwitch(size_t caller_SP)
void ProcessTick()
Process one tick.
uint32_t m_context_switch_nr
uint32_t m_switch_to_next_nr
int32_t GetTickResolution() const
Get number of microseconds in one tick.