![]() |
SuperTinyKernel™ RTOS 1.08.x
Lightweight, high-performance, deterministic, bare-metal C++ RTOS for resource-constrained embedded systems. MIT Open Source License.
|
Partial implementation of the user task. More...
#include <stk_helper.h>
Public Types | |
| enum | { STACK_SIZE = _StackSize } |
Public Member Functions | |
| const Word * | GetStack () const override |
| Get pointer to the stack memory. | |
| size_t | GetStackSize () const override |
| Get number of elements of the stack memory array. | |
| EAccessMode | GetAccessMode () const override |
| Get hardware access mode of the user task. | |
| virtual void | Run ()=0 |
| Entry point of the user task. | |
| virtual IStackMemory * | GetSecureStackMemory () |
| Get pointer to the stack memory. | |
| virtual const MpuRegionList * | GetMpuRegions () const |
| Get up to (STK_MPU_TASK_REGIONS - 1) application-defined MPU regions for this task. | |
| virtual void | OnDeadlineMissed (uint32_t duration) |
| Called by the scheduler if deadline of the task is missed when Kernel is operating in Hard Real-Time mode (see stk::KERNEL_HRT). | |
| virtual void | OnExit () |
| Called by the kernel before removal from the scheduling (see stk::KERNEL_DYNAMIC). | |
| virtual Weight | GetWeight () const |
| Get static base weight of the task. | |
| virtual const char * | GetTraceName () const |
| Get task trace name set by application. | |
| virtual size_t | GetStackSpace () const |
| Get available stack space. | |
Protected Member Functions | |
| Task (const Task &)=delete | |
| Task & | operator= (const Task &)=delete |
| Task () | |
| Initializes task instance and zero-initializes its internal stack memory. | |
| ~Task ()=default | |
| Destructor. | |
Private Attributes | |
| StackMemoryDef< _StackSize >::Type | m_stack |
| Stack memory region, STK_STACK_MEMORY_ALIGN-byte aligned. | |
Partial implementation of the user task.
Provides stack storage and default implementations of all optional ITask methods. Inherit from this class and implement Run() to make a schedulable task. Use ACCESS_USER for unprivileged tasks and ACCESS_PRIVILEGED for tasks requiring full hardware access.
Usage example:
_STK_CORTEX_M_TRUSTZONE_NON_SECURE), derives from tz::nsec::NsTask instead of ITask directly. Unlike ISyncObject, ITask does have an explicit deregistration call (IKernel::RemoveTask), but NsTask's destructor still acts as a safety net: if a dynamically-allocated task is destroyed without that call first, the Secure-side proxy pool slot is freed anyway, preventing permanent pool exhaustion. Definition at line 92 of file stk_helper.h.
| anonymous enum |
|
protecteddelete |
|
inlineprotected |
Initializes task instance and zero-initializes its internal stack memory.
The constructor is protected to ensure that the Task class can only be instantiated through a derived subclass. It handles the allocation (if applicable) and zero-initialization of the m_stack member based on the _StackSize template parameter.
Definition at line 116 of file stk_helper.h.
References m_stack.
|
protecteddefault |
|
inlineoverridevirtual |
Get hardware access mode of the user task.
Implements stk::ITask.
Definition at line 104 of file stk_helper.h.
|
inlinevirtualinherited |
Get up to (STK_MPU_TASK_REGIONS - 1) application-defined MPU regions for this task.
When STK_MPU_STACK_GUARD is enabled, each task owns STK_MPU_TASK_REGIONS (2 or 4, see STK_MPU_TASK_REGIONS) hardware MPU region slots. Slot 0 is always the automatic stack guard, computed by the driver from the task's own stack memory (see IStackMemory::GetStack/GetStackSize). This hook supplies the remaining STK_MPU_TASK_REGIONS-1 slots, letting an application additionally sandbox a task to e.g. a private data buffer, a specific peripheral block, or a shared IPC region - on top of its stack guard.
MpuRegionList containing up to (STK_MPU_TASK_REGIONS - 1) region descriptors, or nullptr if no extra task regions are configured. Array element i is applied at task-relative region index i +1 (i.e. the slots following the stack guard). STK_MPU_STACK_GUARD is enabled; a no-op on platforms/builds without MPU stack-guard support. MpuRegionList instance referenced by the returned pointer must remain valid (e.g. a static const instance); a stack-local temporary is invalid once this function returns. Definition at line 801 of file stk_common.h.
|
inlinevirtualinherited |
Get pointer to the stack memory.
Definition at line 756 of file stk_common.h.
|
inlineoverridevirtual |
Get pointer to the stack memory.
Implements stk::IStackMemory.
Definition at line 102 of file stk_helper.h.
References m_stack.
|
inlineoverridevirtual |
Get number of elements of the stack memory array.
Implements stk::IStackMemory.
Definition at line 103 of file stk_helper.h.
|
inlinevirtualinherited |
Get available stack space.
Definition at line 418 of file stk_common.h.
References stk::ArrayView< T >::GetSize(), GetStack(), GetStackSize(), and STK_STACK_MEMORY_FILLER.
Referenced by FrtosTask::GetStackHighWaterMark(), and osThreadGetStackSpace().
|
inlinevirtualinherited |
Get task trace name set by application.
NULL if unused. Reimplemented in FrtosTask, stk::time::TimerHost::TimerWorkerTask, StkThread, and TaskWrapper.
Definition at line 841 of file stk_common.h.
|
inlinevirtualinherited |
Get static base weight of the task.
Reimplemented in FrtosTask, stk::TaskW< _Weight, _StackSize, _AccessMode >, stk::time::TimerHost::TimerWorkerTask, StkThread, and TaskWrapper.
Definition at line 834 of file stk_common.h.
References stk::DEFAULT_WEIGHT.
Referenced by stk::ISyncObject::FindWeightHigherThan().
|
inlinevirtualinherited |
Called by the scheduler if deadline of the task is missed when Kernel is operating in Hard Real-Time mode (see stk::KERNEL_HRT).
| [in] | duration | Elapsed active time in ticks at the point the deadline was detected. Always greater than the task's configured deadline (ticks). |
Reimplemented in FrtosTask, stk::time::TimerHost::TimerWorkerTask, StkThread, and TaskWrapper.
Definition at line 817 of file stk_common.h.
References STK_UNUSED.
|
inlinevirtualinherited |
Called by the kernel before removal from the scheduling (see stk::KERNEL_DYNAMIC).
Reimplemented in FrtosTask, stk::time::TimerHost::TimerWorkerTask, StkThread, and TaskWrapper.
Definition at line 827 of file stk_common.h.
|
protecteddelete |
|
pure virtualinherited |
Entry point of the user task.
Kernel is configured as KERNEL_STATIC, the body must contain an infinite loop. Implemented in FrtosTask, stk::time::TimerHost::TimerWorkerTask, StkThread, and TaskWrapper.
|
private |
Stack memory region, STK_STACK_MEMORY_ALIGN-byte aligned.
Definition at line 125 of file stk_helper.h.
Referenced by GetStack(), and Task().