79template <u
int8_t TMode, u
int32_t TSize,
class TStrategy,
class TPlatform>
198 if (TStrategy::WEIGHT_API)
205 int32_t
GetWeight()
const {
return (TStrategy::WEIGHT_API ?
m_user->GetWeight() : 1); }
265 sleep_ticks =
Min(sleep_ticks, task_sleep);
269 sleep_ticks =
Min(sleep_ticks, task_sleep);
274 sleep_ticks =
Min(sleep_ticks, task_sleep);
531 m_hrt[0].periodicity = periodicity_tc;
532 m_hrt[0].deadline = deadline_tc;
534 if (start_delay_tc > 0)
559 m_hrt[0].duration = 0;
560 m_hrt[0].done =
false;
574 m_user->OnDeadlineMissed(duration);
583 m_hrt[0].done =
true;
584 __stk_full_memfence();
606 if (TStrategy::SLEEP_EVENT_API)
613 __stk_full_memfence();
664 const Ticks deadline = now + ticks;
667 for (; now < deadline; now =
GetTicks())
770 m_platform =
static_cast<TPlatform *
>(platform);
811 #if !STK_TICKLESS_IDLE
813 "STK_TICKLESS_IDLE must be defined to 1 for KERNEL_TICKLESS");
956 task->ScheduleRemoval();
976 KernelTask *task =
nullptr;
989 if ((suspended = !task->IsSleeping()) ==
true)
1000 task->BusyWaitWhileSleeping();
1016 if (task->IsSleeping())
1032 for (uint32_t i = 0U; i < Min(max_size, static_cast<size_t>(
TASKS_MAX)); ++i)
1036 user_tasks[count++] = task->GetUserTask();
1058 #if STK_SEGGER_SYSVIEW
1059 SEGGER_SYSVIEW_Start();
1060 for (uint32_t i = 0U; i <
TASKS_MAX; ++i)
1064 SendTaskTraceInfo(task);
1148 #if STK_NEED_TASK_ID
1162 #if STK_NEED_TASK_ID
1177 KernelTask *new_task =
nullptr;
1178 for (uint32_t i = 0U; i <
TASKS_MAX; ++i)
1190 if (new_task ==
nullptr)
1193 #if defined(NDEBUG) && !defined(_STK_ASSERT_REDIRECT)
1212 #if STK_SEGGER_SYSVIEW
1214 SEGGER_SYSVIEW_OnTaskCreate(task->GetUserStack()->tid);
1216 SendTaskTraceInfo(task);
1247 task->HrtInit(periodicity_tc, deadline_tc, start_delay_tc);
1263 typename KernelTask::AddTaskRequest req = { .user_task = user_task };
1264 caller->m_srt[0].add_task_req = &req;
1270 if (caller->m_srt[0].add_task_req !=
nullptr)
1273 STK_ASSERT(caller->m_srt[0].add_task_req ==
nullptr);
1282 for (uint32_t i = 0U; i <
TASKS_MAX; ++i)
1285 if (task->GetUserTask() == user_task)
1298 for (uint32_t i = 0U; i <
TASKS_MAX; ++i)
1301 if (task->GetUserStack() == stack)
1319 for (uint32_t i = 0U; i <
TASKS_MAX; ++i)
1327 if (task->IsMemoryOfSP(SP))
1342 #if STK_SEGGER_SYSVIEW
1343 SEGGER_SYSVIEW_OnTaskTerminate(task->GetUserStack()->tid);
1347 task->GetUserTask()->
OnExit();
1368 if (TStrategy::SLEEP_EVENT_API)
1370 for (uint32_t i = 0U; i <
TASKS_MAX; ++i)
1374 if (task->IsSleeping())
1378 task->m_state &= ~KernelTask::STATE_SLEEP_PENDING;
1391 KernelTask *next =
nullptr;
1401 active = next->GetUserStack();
1404 next->HrtOnSwitchedIn();
1420 #if STK_SEGGER_SYSVIEW
1421 SEGGER_SYSVIEW_OnTaskStartExec(
m_task_now->tid);
1463 #if !STK_TICKLESS_IDLE
1472 #if STK_TICKLESS_IDLE
1499 task->HrtOnWorkCompleted();
1502 task->ScheduleSleep(ticks);
1506 task->BusyWaitWhileSleeping();
1523 task->ScheduleSleep(ticks);
1527 task->BusyWaitWhileSleeping();
1538 task->ScheduleRemoval();
1560 task->m_wait_obj->SetupWait(sync_obj, timeout);
1563 if (sync_obj->
GetHead() ==
nullptr)
1573 task->BusyWaitWhileSleeping();
1578 return task->m_wait_obj;
1592 return task->GetTid();
1629 for (uint32_t i = 0U; i <
TASKS_MAX; ++i)
1633 if (task->IsSleeping())
1638 if (task->IsPendingRemoval())
1651 if (TStrategy::SLEEP_EVENT_API)
1655 task->m_state &= ~KernelTask::STATE_SLEEP_PENDING;
1663 task->m_time_sleep += elapsed_ticks;
1666 if (TStrategy::SLEEP_EVENT_API)
1669 if (task->m_time_sleep >= 0)
1679 task->m_hrt[0].duration += elapsed_ticks;
1682 if (task->HrtIsDeadlineMissed(task->m_hrt[0].duration))
1684 bool can_recover =
false;
1687 if (TStrategy::DEADLINE_MISSED_API)
1688 can_recover =
m_strategy.OnTaskDeadlineMissed(task);
1700 sleep_ticks = task->GetSleepTicks(sleep_ticks);
1715 while (itr !=
nullptr)
1721 if (!
static_cast<ISyncObject *
>(itr)->Tick(elapsed_ticks))
1745 for (uint32_t i = 0U; i <
TASKS_MAX; ++i)
1749 if (task->m_srt[0].add_task_req !=
nullptr)
1753 task->m_srt[0].add_task_req =
nullptr;
1754 __stk_full_memfence();
1768 KernelTask *itr =
nullptr;
1778 itr =
static_cast<KernelTask *
>(
m_strategy.GetNext());
1803#ifdef _STK_UNDER_TEST
1819 KernelTask *now =
m_task_now, *next =
nullptr;
1820 bool switch_context =
false;
1827 switch_context =
StateSwitch(now, next, idle, active);
1830 switch_context =
StateSleep(now, next, idle, active);
1833 switch_context =
StateWake(now, next, idle, active);
1836 switch_context =
StateExit(now, next, idle, active);
1839 return switch_context;
1847 return switch_context;
1866 idle = now->GetUserStack();
1867 active = next->GetUserStack();
1881 if (now->m_hrt[0].done)
1884 next->HrtOnSwitchedIn();
1888 #if STK_SEGGER_SYSVIEW
1890 SEGGER_SYSVIEW_OnTaskStartReady(next->GetUserStack()->tid);
1910 active = next->GetUserStack();
1918 #if STK_SEGGER_SYSVIEW
1919 SEGGER_SYSVIEW_OnTaskStartReady(next->GetUserStack()->tid);
1923 next->HrtOnSwitchedIn();
1942 idle = now->GetUserStack();
1947 #if STK_SEGGER_SYSVIEW
1953 if (!now->IsPendingRemoval())
2009#if STK_SEGGER_SYSVIEW
2014 void SendTaskTraceInfo(KernelTask *task)
2018 SEGGER_SYSVIEW_TASKINFO info =
2020 .TaskID = task->GetUserStack()->tid,
2021 .sName = task->GetUserTask()->GetTraceName(),
2023 .StackBase =
hw::PtrToWord(task->GetUserTask()->GetStack()),
2024 .StackSize = task->GetUserTask()->GetStackSizeBytes()
2026 SEGGER_SYSVIEW_SendTaskInfo(&info);
#define STK_KERNEL_PANIC(id)
Called when the kernel detects an unrecoverable internal fault.
#define STK_UNUSED(X)
Explicitly marks a variable as unused to suppress compiler warnings.
#define STK_STATIC_ASSERT_N(NAME, X)
Compile-time assertion with a user-defined name suffix.
#define __stk_forceinline
Forces compiler to always inline the decorated function, regardless of optimisation level.
#define STK_TICKLESS_IDLE
Enables tickless (dynamic-tick) low-power operation during idle periods.
#define STK_ASSERT(e)
Runtime assertion. Halts execution if the expression e evaluates to false.
#define __stk_attr_noinline
Prevents compiler from inlining the decorated function (function prefix).
#define STK_TICKLESS_TICKS_MAX
Maximum number of kernel ticks the hardware timer may be suppressed in one tickless idle interval whe...
#define STK_STATIC_ASSERT_DESC(X, DESC)
Compile-time assertion with a custom error description. Produces a compilation error if X is false.
#define STK_STACK_MEMORY_FILLER
Sentinel value written to the entire stack region at initialization (stack watermark pattern).
#define STK_ALLOCATE_COUNT(MODE, FLAG, ONTRUE, ONFALSE)
Selects a static array element count at compile time based on a mode flag.
Contains helper implementations which simplify user-side code.
Earliest Deadline First (EDF) task-switching strategy (stk::SwitchStrategyEDF).
Fixed-priority preemptive task-switching strategy with round-robin within each priority level (stk::S...
Rate-Monotonic (RM) and Deadline-Monotonic (DM) task-switching strategies (stk::SwitchStrategyMonoton...
Round-Robin task-switching strategy (stk::SwitchStrategyRoundRobin / stk::SwitchStrategyRR).
Smooth Weighted Round-Robin task-switching strategy (stk::SwitchStrategySmoothWeightedRoundRobin / st...
#define __stk_relax_cpu
Emits a CPU pipeline-relaxation hint for use inside hot busy-wait (spin) loops (in-code statement).
Namespace of STK package.
uintptr_t Word
Native processor word type.
@ TRACE_EVENT_SLEEP
Task entered sleep / blocked state.
@ TRACE_EVENT_SWITCH
Task context switch event (task became active).
int64_t Ticks
Ticks value.
int32_t Timeout
Timeout time (ticks).
static constexpr T Max(T a, T b)
Compile-time maximum of two values.
@ STACK_SLEEP_TRAP
Stack of the Sleep trap.
@ STACK_USER_TASK
Stack of the user task.
@ STACK_EXIT_TRAP
Stack of the Exit trap.
@ PERIODICITY_DEFAULT
Default periodicity (microseconds), 1 millisecond.
@ PERIODICITY_MAX
Maximum periodicity (microseconds), 99 milliseconds (note: this value is the highest working on a rea...
static constexpr Timeout WAIT_INFINITE
Timeout value: block indefinitely until the synchronization object is signaled.
@ SYS_TASK_ID_EXIT
Exit trap.
@ SYS_TASK_ID_SLEEP
Sleep trap.
static constexpr T Min(T a, T b)
Compile-time minimum of two values.
uint64_t Cycles
Cycles value.
@ ACCESS_PRIVILEGED
Privileged access mode (access to hardware is fully unrestricted).
@ KERNEL_TICKLESS
Tickless mode. To use this mode STK_TICKLESS_IDLE must be defined to 1 in stk_config....
@ KERNEL_SYNC
Synchronization support (see Event).
@ KERNEL_HRT
Hard Real-Time (HRT) behavior (tasks are scheduled periodically and have an execution deadline,...
@ KERNEL_STATIC
All tasks are static and can not exit.
@ KERNEL_DYNAMIC
Tasks can be added or removed and therefore exit when done.
@ KERNEL_PANIC_BAD_MODE
Kernel is in bad/unsupported mode for the current operation.
@ KERNEL_PANIC_BAD_STATE
Kernel entered unexpected (bad) state.
Memory-related primitives.
__stk_forceinline void WriteVolatile64(volatile T *addr, T value)
Atomically write a 64-bit volatile value.
__stk_forceinline Word PtrToWord(T *ptr) noexcept
Cast a pointer to a CPU register-width integer.
bool IsInsideISR()
Check whether the CPU is currently executing inside a hardware interrupt service routine (ISR).
__stk_forceinline T ReadVolatile64(volatile const T *addr)
Atomically read a 64-bit volatile value.
void ResumeTask(ITask *user_task)
Resume task.
volatile uint8_t m_request
void ScheduleTaskRemoval(ITask *user_task)
Schedule task removal from scheduling (exit).
static bool IsStaticMode()
bool UpdateFsmState(Stack *&idle, Stack *&active)
Update FSM state.
stk::SwitchStrategyFP32 m_strategy
KernelTask * AllocateNewTask(ITask *user_task)
Allocate new instance of KernelTask.
size_t EnumerateTasks(ITask **user_tasks, const size_t max_size)
Enumerate tasks.
void OnStart(Stack *&active)
Called by platform driver immediately after a scheduler start (first tick).
SyncObjectList m_sync_list[((((TMode) &(KERNEL_SYNC)) !=0U) ?(1) :(0))]
EFsmState
Finite-state machine (FSM) state. Encodes what the kernel is currently doing between two consecutive ...
KernelTask * FindTaskByStack(const Stack *stack)
Find kernel task by the bound Stack instance.
KernelTask TaskStorageType[TASKS_MAX]
KernelTask array type used as a storage for the KernelTask instances.
void SuspendTask(ITask *user_task, bool &suspended)
Suspend task.
SleepTrapStack m_sleep_trap[1]
static constexpr Timeout YIELD_TICKS
void OnTaskSwitch(Word caller_SP)
Called by Thread process (via IKernelService::SwitchToNext) to switch to a next task.
EFsmState GetNewFsmState(KernelTask *&next)
Get new FSM state.
void RequestAddTask(ITask *user_task)
Request to add new task.
void AddTask(ITask *user_task, Timeout periodicity_tc, Timeout deadline_tc, Timeout start_delay_tc)
Register a task for hard real-time (HRT) scheduling.
StackMemoryWrapper< STACK_SIZE_MIN > ExitTrapStackMemory
Stack memory wrapper type for the exit trap.
void Initialize(uint32_t resolution_us=PERIODICITY_DEFAULT)
Initialize kernel.
bool StateWake(KernelTask *now, KernelTask *next, Stack *&idle, Stack *&active)
Wakes up after sleeping.
bool OnTick(Stack *&idle, Stack *&active)
Process one scheduler tick. Called from the platform timer/tick ISR.
EState GetState() const
Get kernel state.
KernelTask * FindTaskBySP(Word SP)
Find kernel task for a Stack Pointer (SP).
void InitTraps()
Initialize stack of the traps.
void OnTaskSleepUntil(Word caller_SP, Ticks timestamp)
Called by Thread process (via IKernelService::SleepUntil) for exclusion of the calling process from s...
ISyncObject::ListHeadType SyncObjectList
Intrusive list of active ISyncObject instances registered with this kernel. Each sync object in this ...
ExitTrapStack m_exit_trap[((((TMode) &(KERNEL_DYNAMIC)) !=0U) ?(1) :(0))]
EFsmEvent
Finite-state machine (FSM) event. Computed by FetchNextEvent() each tick based on strategy output and...
IWaitObject * OnTaskWait(Word caller_SP, ISyncObject *sync_obj, IMutex *mutex, Timeout timeout)
Called from the Thread process when task needs to wait.
ITaskSwitchStrategy * GetSwitchStrategy()
Get task-switching strategy instance owned by this kernel.
KernelTask * FindTaskByUserTask(const ITask *user_task)
Find kernel task by the bound ITask instance.
static bool IsValidFsmState(EFsmState state)
Check if FSM state is valid.
TaskStorageType m_task_storage
void OnSuspend(bool suspended)
Called from the Thread process to suspend scheduling.
void RemoveTask(KernelTask *task)
Remove kernel task.
void Start()
Start the scheduler. This call does not return until all tasks have exited (KERNEL_DYNAMIC mode) or i...
void AddKernelTask(KernelTask *task)
Add kernel task to the scheduling strategy.
static bool IsDynamicMode()
void RemoveTask(ITask *user_task)
Remove a previously added task from the kernel before Start().
ERequest
Bitmask flags for pending inter-task requests that must be processed by the kernel on the next tick (...
bool StateExit(KernelTask *now, KernelTask *next, Stack *&idle, Stack *&active)
Exits from scheduling.
TId OnGetTid(Word caller_SP)
Called from the Thread process when for getting task/thread id of the process.
void AllocateAndAddNewTask(ITask *user_task)
Allocate new instance of KernelTask and add it into the scheduling process.
static constexpr uint32_t TASKS_MAX
stk::PlatformDefault m_platform
void HrtAllocateAndAddNewTask(ITask *user_task, Timeout periodicity_tc, Timeout deadline_tc, Timeout start_delay_tc)
Allocate new instance of KernelTask and add it into the HRT scheduling process.
Timeout UpdateTasks(const Timeout elapsed_ticks)
Update tasks (sleep, requests).
void ScheduleAddTask()
Signal the kernel to process a pending AddTask request on the next tick.
bool IsInitialized() const
Check whether Initialize() has been called and completed successfully.
IPlatform * GetPlatform()
Get platform driver instance owned by this kernel.
StackMemoryWrapper<(32U)> SleepTrapStackMemory
Stack memory wrapper type for the sleep trap.
bool StateSwitch(KernelTask *now, KernelTask *next, Stack *&idle, Stack *&active)
Switches contexts.
static bool IsTicklessMode()
void OnTaskExit(Stack *stack)
Called from the Thread process when task finished (its Run function exited by return).
Kernel()
Construct the kernel with all storage zero-initialized and the request flag set to ~0 (indicating uni...
void UpdateTaskRequest()
Update pending task requests.
bool StateSleep(KernelTask *now, KernelTask *next, Stack *&idle, Stack *&active)
Enters into a sleeping mode.
Timeout UpdateTaskState(const Timeout elapsed_ticks)
Update task state: process removals, advance sleep timers, and track HRT durations.
void OnStop()
Called by the platform driver after a scheduler stop (all tasks have exited).
void UpdateSyncObjects(const Timeout elapsed_ticks)
Update synchronization objects.
void OnTaskSleep(Word caller_SP, Timeout ticks)
Called by Thread process (via IKernelService::Sleep) for exclusion of the calling process from schedu...
bool IsStarted() const
Check whether scheduler is currently running.
const EFsmState m_fsm[FSM_STATE_MAX][FSM_EVENT_MAX]
void AddTask(ITask *user_task)
Register task for a soft real-time (SRT) scheduling.
EFsmEvent FetchNextEvent(KernelTask *&next)
Fetch next event for the FSM.
Internal per-slot kernel descriptor that wraps a user ITask instance.
KernelTask()
Construct a free (unbound) task slot. All fields set to zero/null.
void ScheduleSleep(Timeout ticks)
Put the task into a sleeping state for the specified number of ticks.
Timeout GetSleepTicks(Timeout sleep_ticks)
TId GetTid() const
Get task identifier.
int32_t m_rt_weight[((((TStrategy::WEIGHT_API) &(1)) !=0U) ?(1) :(0))]
Run-time weight for weighted-round-robin scheduling. Zero-size for unweighted strategies.
WaitObject m_wait_obj[((((TMode) &(KERNEL_SYNC)) !=0U) ?(1) :(0))]
Embedded wait object for synchronization. Zero-size (no memory) if KERNEL_SYNC is not set.
void SetCurrentWeight(int32_t weight)
Update the run-time scheduling weight (weighted strategies only).
bool HrtIsDeadlineMissed(Timeout duration) const
Check if deadline missed.
EStateFlags
Bitmask of transient state flags. Set by the task or the kernel and consumed (cleared) during UpdateT...
@ STATE_REMOVE_PENDING
Task returned from its Run function; slot will be freed on the next tick (KERNEL_DYNAMIC only).
@ STATE_SLEEP_PENDING
Task called Sleep/SleepUntil/Yield; strategy's OnTaskSleep() will be invoked on the next tick (sleep-...
@ STATE_NONE
No pending state flags.
void ScheduleRemoval()
Schedule the removal of the task from the kernel on next tick.
Timeout GetHrtRelativeDeadline() const
Get remaining HRT deadline (ticks left before the deadline expires).
Stack m_stack
Stack descriptor (SP register value + access mode + optional tid).
Stack * GetUserStack()
Get stack descriptor for this task slot.
void Bind(TPlatform *platform, ITask *user_task)
Bind this slot to a user task: set access mode, task ID, and initialize the stack.
void HrtHardFailDeadline(IPlatform *platform)
Hard-fail HRT task when it missed its deadline.
void HrtInit(Timeout periodicity_tc, Timeout deadline_tc, Timeout start_delay_tc)
Initialize task with HRT info.
volatile uint32_t m_state
Bitmask of EStateFlags. Written by task thread, read/cleared by kernel tick.
int32_t GetCurrentWeight() const
Get current (run-time) scheduling weight.
ITask * GetUserTask()
Get bound user task.
void BusyWaitWhileSleeping() const
Block further execution of the task's context while in sleeping state.
ITask * m_user
Bound user task, or NULL when slot is free.
bool IsBusy() const
Check whether this slot is bound to a user task.
void HrtOnWorkCompleted()
Called when task process called IKernelService::SwitchToNext to inform Kernel that work is completed.
void Wake()
Wake this task on the next scheduling tick.
HrtInfo m_hrt[((((TMode) &(KERNEL_HRT)) !=0U) ?(1) :(0))]
HRT metadata. Zero-size (no memory) in non-HRT mode.
Timeout GetHrtDeadline() const
Get absolute HRT deadline (ticks elapsed since task was activated).
SrtInfo m_srt[((((TMode) &(KERNEL_HRT)) !=0U) ?(0) :(1))]
SRT metadata. Zero-size (no memory) in KERNEL_HRT mode.
volatile Timeout m_time_sleep
Sleep countdown: negative while sleeping (absolute value = ticks remaining), zero when awake.
bool IsPendingRemoval() const
Check if task is pending removal.
void HrtOnSwitchedOut(IPlatform *)
Called when task is switched out from the scheduling process.
void Unbind()
Reset this slot to the free (unbound) state, clearing all scheduling metadata.
void HrtOnSwitchedIn()
Called when task is switched into the scheduling process.
bool IsMemoryOfSP(Word SP) const
Check if Stack Pointer (SP) belongs to this task.
int32_t GetWeight() const
Get static scheduling weight from the user task.
Timeout GetHrtPeriodicity() const
Get HRT scheduling periodicity.
bool IsSleeping() const
Check whether this task is currently sleeping (waiting for a tick or a wake event).
Payload for an in-flight AddTask() request issued by a running task.
ITask * user_task
User task to add. Must remain valid for the lifetime of its kernel slot.
Per-task soft real-time (SRT) metadata.
void Clear()
Clear all fields, ready for slot re-use.
AddTaskRequest * add_task_req
Per-task Hard Real-Time (HRT) scheduling metadata.
void Clear()
Clear all fields, ready for slot re-use or re-activation.
volatile bool done
Set to true when the task signals work completion (via Yield() or on exit). Triggers HrtOnSwitchedOut...
Timeout deadline
Maximum allowed active duration in ticks (relative to switch-in). Exceeding this triggers OnDeadlineM...
Timeout periodicity
Activation period in ticks: the task is re-activated every this many ticks.
Timeout duration
Ticks spent in the active (non-sleeping) state in the current period. Incremented by UpdateTaskState(...
Concrete implementation of IWaitObject, embedded in each KernelTask slot.
bool IsWaiting() const
Check if busy with waiting.
bool Tick(Timeout elapsed_ticks)
Advance the timeout countdown by one tick.
Timeout m_time_wait
Ticks remaining until timeout. Decremented each tick; WAIT_INFINITE means no timeout.
bool IsTimeout() const
Check whether the wait expired due to timeout.
void Wake(bool timeout)
Wake the waiting task (called by ISyncObject when it signals).
void SetupWait(ISyncObject *sync_obj, Timeout timeout)
Configure and arm this wait object for a new wait operation.
TId GetTid() const
Get the TId of the task that owns this wait object.
volatile bool m_timeout
true if the wait expired due to timeout rather than a Wake() signal.
ISyncObject * m_sync_obj
Sync object this wait is registered with, or NULL when not waiting.
KernelTask * m_task
Back-pointer to the owning KernelTask. Set once at construction; never changes.
Payload stored in the sync object's kernel-side list entry while a task is waiting.
ISyncObject * sync_obj
Sync object whose Tick() will be called each kernel tick.
KernelService()
Construct an uninitialized service instance (m_platform = null, m_ticks = 0).
IWaitObject * Wait(ISyncObject *sobj, IMutex *mutex, Timeout ticks)
Put calling process into a waiting state until synchronization object is signaled or timeout occurs.
volatile Ticks m_ticks
Global tick counter. Written via hw::WriteVolatile64() by IncrementTick() (ISR context); read via hw:...
~KernelService()
Destructor.
void SwitchToNext()
Notify scheduler to switch to the next task (yield).
Ticks GetTicks() const
Get number of ticks elapsed since kernel start.
Timeout Suspend()
Suspend scheduling.
void Sleep(Timeout ticks)
Put calling process into a sleep state.
Cycles GetSysTimerCount() const
Get system timer count value.
TPlatform * m_platform
Typed platform driver pointer, set at Initialize().
void SleepUntil(Ticks timestamp)
Put calling process into a sleep state until the specified timestamp.
TId GetTid() const
Get thread Id of the currently running task.
void Resume(Timeout elapsed_ticks)
Resume scheduling after a prior Suspend() call.
uint32_t GetTickResolution() const
Get number of microseconds in one tick.
uint32_t GetSysTimerFrequency() const
Get system timer frequency.
void Delay(Timeout ticks)
Delay calling process.
void IncrementTicks(Ticks advance)
Increment counter by value.
void Initialize(IPlatform *platform)
Initialize instance.
Storage bundle for the sleep trap: a Stack descriptor paired with its backing memory.
SleepTrapStackMemory::MemoryType Memory
Memory memory
Backing stack memory array. Size: STK_SLEEP_TRAP_STACK_SIZE elements of Word.
Stack stack
Stack descriptor (SP register value + access mode). Initialised by InitTraps() on every Start().
Storage bundle for the exit trap: a Stack descriptor paired with its backing memory.
Memory memory
Backing stack memory array. Size: STACK_SIZE_MIN elements of Word.
ExitTrapStackMemory::MemoryType Memory
Stack stack
Stack descriptor (SP register value + access mode). Initialised by InitTraps() on every Start().
RAII guard that enters the critical section on construction and exits it on destruction.
EAccessMode mode
Hardware access mode of the owning task (see EAccessMode).
virtual Word * GetStack() const =0
Get pointer to the stack memory.
DLEntryType ListEntryType
List entry type of ISyncObject elements.
virtual void AddWaitObject(IWaitObject *wobj)
Called by kernel when a new task starts waiting on this event.
DLHeadType ListHeadType
List head type for ISyncObject elements.
Interface for mutex synchronization primitive.
virtual void Unlock()=0
Unlock the mutex.
virtual void Lock()=0
Lock the mutex.
Interface for a user task.
virtual void OnExit()=0
Called by the kernel before removal from the scheduling (see stk::KERNEL_DYNAMIC).
virtual EAccessMode GetAccessMode() const =0
Get hardware access mode of the user task.
virtual TId GetId() const =0
Get task Id set by application.
Scheduling-strategy-facing interface for a kernel task slot.
Interface for a platform driver.
virtual void ProcessHardFault()=0
Cause a hard fault of the system.
Interface for a back-end event handler.
Interface for a task switching strategy implementation.
Interface for the implementation of the kernel of the scheduler. It supports Soft and Hard Real-Time ...
Interface for the kernel services exposed to the user processes during run-time when Kernel started s...
Adapts an externally-owned stack memory array to the IStackMemory interface.
StackMemoryDef< _StackSize >::Type MemoryType
DLHeadType * GetHead() const
Get the list head this entry currently belongs to.
DLEntryType * GetNext() const
Get the next entry in the list.