SuperTinyKernel™ RTOS 1.06.x
Lightweight, high-performance, deterministic, bare-metal C++ RTOS for resource-constrained embedded systems. MIT Open Source License.
Loading...
Searching...
No Matches
FrtosTask Struct Reference
Inheritance diagram for FrtosTask:
Collaboration diagram for FrtosTask:

Classes

struct  NotifySlot

Public Types

enum class  State : uint8_t {
  Ready ,
  Suspended ,
  Deleted
}

Public Member Functions

 FrtosTask ()
virtual ~FrtosTask ()
void Run () override
 Entry point of the user task.
void OnExit () override
 Called by the kernel before removal from the scheduling (see stk::KERNEL_DYNAMIC).
const stk::WordGetStack () const override
 Get pointer to the stack memory.
size_t GetStackSize () const override
 Get number of elements of the stack memory array.
stk::EAccessMode GetAccessMode () const override
 Get hardware access mode of the user task.
int32_t GetWeight () const override
 Get static base weight of the task.
const char * GetTraceName () const override
 Get task trace name set by application.
void OnDeadlineMissed (uint32_t) override
 Called by the scheduler if deadline of the task is missed when Kernel is operating in Hard Real-Time mode (see stk::KERNEL_HRT).
size_t GetStackHighWaterMark () const
virtual IStackMemory * GetSecureStackMemory ()
 Get pointer to the stack memory.
TId GetId () const
 Get task Id set by application.
virtual size_t GetStackSpace () const
 Get available stack space.

Public Attributes

TaskFunction_t m_func
void * m_argument
const char * m_name
volatile int32_t m_weight
stk::Wordm_stack
size_t m_stack_size
bool m_stack_owned
bool m_cb_owned
volatile State m_state
uint32_t m_task_number
void * m_tls [4U]
NotifySlot m_notify [1U]

Static Public Attributes

static uint32_t s_task_counter = 0U

Detailed Description

Definition at line 397 of file freertos_stk.cpp.

Member Enumeration Documentation

◆ State

enum class FrtosTask::State : uint8_t
strong
Enumerator
Ready 
Suspended 
Deleted 

Definition at line 399 of file freertos_stk.cpp.

400 {
401 Ready, // in the ready/running queue
402 Suspended, // explicitly suspended via vTaskSuspend()
403 Deleted, // marked for removal, kernel slot being freed
404 };

Constructor & Destructor Documentation

◆ FrtosTask()

FrtosTask::FrtosTask ( )
inlineexplicit

< Per-task TLS pointer slots.

Definition at line 406 of file freertos_stk.cpp.

407 : m_func(nullptr), m_argument(nullptr), m_name(nullptr),
409 m_stack(nullptr), m_stack_size(0U),
410 m_stack_owned(false), m_cb_owned(true),
413 {
414 for (size_t i = 0U; i < configNUM_THREAD_LOCAL_STORAGE_POINTERS; ++i)
415 m_tls[i] = nullptr;
416 }
static int32_t FrtosPrioToStkWeight(UBaseType_t p)
#define configNUM_THREAD_LOCAL_STORAGE_POINTERS
Definition FreeRTOS.h:164
#define tskIDLE_PRIORITY
Definition FreeRTOS.h:2208
const char * m_name
TaskFunction_t m_func
uint32_t m_task_number
volatile int32_t m_weight
stk::Word * m_stack
volatile State m_state
size_t m_stack_size
void * m_tls[4U]
static uint32_t s_task_counter
void * m_argument

References configNUM_THREAD_LOCAL_STORAGE_POINTERS, FrtosPrioToStkWeight(), m_argument, m_cb_owned, m_func, m_name, m_stack, m_stack_owned, m_stack_size, m_state, m_task_number, m_tls, m_weight, s_task_counter, and tskIDLE_PRIORITY.

Here is the call graph for this function:

◆ ~FrtosTask()

virtual FrtosTask::~FrtosTask ( )
inlinevirtual

Definition at line 418 of file freertos_stk.cpp.

419 {
420 if (m_stack_owned && (m_stack != nullptr))
421 {
423 m_stack = nullptr;
424 }
425 }
static void ObjFreeArray(void *ptr)

References m_stack, m_stack_owned, and ObjFreeArray().

Here is the call graph for this function:

Member Function Documentation

◆ GetAccessMode()

stk::EAccessMode FrtosTask::GetAccessMode ( ) const
inlineoverridevirtual

Get hardware access mode of the user task.

Implements stk::ITask.

Definition at line 441 of file freertos_stk.cpp.

441{ return stk::ACCESS_PRIVILEGED; }
@ ACCESS_PRIVILEGED
Privileged access mode (access to hardware is fully unrestricted).
Definition stk_common.h:44

References stk::ACCESS_PRIVILEGED.

◆ GetId()

TId stk::ITask::GetId ( ) const
inlineinherited

Get task Id set by application.

Implementation of ITask::GetId, see ITask. Placed here as it depends on GetTidFromUserTask.

Returns
Application-defined task identifier. Return 0 if unused.
Note
Used for debugging and tracing only. The kernel does not interpret this value.

Definition at line 228 of file stk_helper.h.

229{
230 return GetTidFromUserTask(this);
231}
static constexpr TId GetTidFromUserTask(const ITask *task) noexcept
Get task identifier from ITask instance.
Definition stk_arch.h:526

References stk::GetTidFromUserTask().

Referenced by stk::Kernel< TMode, TSize, TStrategy, TPlatform >::KernelTask::Bind(), and stk_task_get_id().

Here is the call graph for this function:
Here is the caller graph for this function:

◆ GetSecureStackMemory()

virtual IStackMemory * stk::ITask::GetSecureStackMemory ( )
inlinevirtualinherited

Get pointer to the stack memory.

Note
Optional. ARM TrustZone only.
Returns
Pointer to the Secure stack memory.

Definition at line 692 of file stk_common.h.

692{ return nullptr; }

◆ GetStack()

const stk::Word * FrtosTask::GetStack ( ) const
inlineoverridevirtual

Get pointer to the stack memory.

Implements stk::IStackMemory.

Definition at line 439 of file freertos_stk.cpp.

439{ return m_stack; }

References m_stack.

◆ GetStackHighWaterMark()

size_t FrtosTask::GetStackHighWaterMark ( ) const
inline

Definition at line 450 of file freertos_stk.cpp.

450{ return GetStackSpace(); }
virtual size_t GetStackSpace() const
Get available stack space.
Definition stk_common.h:336

References stk::IStackMemory::GetStackSpace().

Referenced by uxTaskGetStackHighWaterMark(), uxTaskGetStackHighWaterMark2(), uxTaskGetSystemState(), and vTaskList().

Here is the call graph for this function:
Here is the caller graph for this function:

◆ GetStackSize()

size_t FrtosTask::GetStackSize ( ) const
inlineoverridevirtual

Get number of elements of the stack memory array.

Implements stk::IStackMemory.

Definition at line 440 of file freertos_stk.cpp.

440{ return m_stack_size; }

References m_stack_size.

◆ GetStackSpace()

virtual size_t stk::IStackMemory::GetStackSpace ( ) const
inlinevirtualinherited

Get available stack space.

Returns
Number of elements of the stack memory array remaining on the stack (computed via the watermark pattern). Returns 0 if the stack has been fully used or the watermark STK_STACK_MEMORY_FILLER was overwritten.
Warning
Stack type: Bottom to Top (index[0]).

Definition at line 336 of file stk_common.h.

337 {
338 const ArrayView<const Word> stack(GetStack(), GetStackSize());
339 const size_t total_size = stack.GetSize();
340 size_t space = 0U;
341
342 for (size_t i = 0U; i < total_size; ++i)
343 {
344 if (stack[i] == STK_STACK_MEMORY_FILLER)
345 {
346 space = i + 1U;
347 }
348 else
349 {
350 break; // terminate loop as soon as watermark ends
351 }
352 }
353
354 return space;
355 }
#define STK_STACK_MEMORY_FILLER
Sentinel value written to the entire stack region at initialization (stack watermark pattern).
Definition stk_defs.h:456
virtual size_t GetStackSize() const =0
Get number of elements of the stack memory array.
virtual const Word * GetStack() const =0
Get pointer to the stack memory.

References stk::ArrayView< T >::GetSize(), GetStack(), GetStackSize(), and STK_STACK_MEMORY_FILLER.

Referenced by FrtosTask::GetStackHighWaterMark(), and osThreadGetStackSpace().

Here is the call graph for this function:
Here is the caller graph for this function:

◆ GetTraceName()

const char * FrtosTask::GetTraceName ( ) const
inlineoverridevirtual

Get task trace name set by application.

Returns
Null-terminated name string, or NULL if unused.
Note
Used for debugging and tracing only (e.g. SEGGER SystemView). Kernel does not interpret this value.

Reimplemented from stk::ITask.

Definition at line 443 of file freertos_stk.cpp.

443{ return m_name; }

References m_name.

◆ GetWeight()

int32_t FrtosTask::GetWeight ( ) const
inlineoverridevirtual

Get static base weight of the task.

Returns
Static weight value of the task (must be non-zero, positive 24-bit number).
See also
SwitchStrategyFixedPriority, SwitchStrategySmoothWeightedRoundRobin, IKernelTask::GetWeight, IKernelService::InheritWeight, IKernelService::RestoreWeight

Reimplemented from stk::ITask.

Definition at line 442 of file freertos_stk.cpp.

442{ return m_weight; }

References m_weight.

◆ OnDeadlineMissed()

void FrtosTask::OnDeadlineMissed ( uint32_t duration)
inlineoverridevirtual

Called by the scheduler if deadline of the task is missed when Kernel is operating in Hard Real-Time mode (see stk::KERNEL_HRT).

Parameters
[in]durationElapsed active time in ticks at the point the deadline was detected. Always greater than the task's configured deadline (ticks).
Note
Optional handler. Use it for fault logging.
After this call returns, IPlatform::ProcessHardFault() is invoked and the system enters a safe state. This function should not attempt to recover scheduling.

Reimplemented from stk::ITask.

Definition at line 445 of file freertos_stk.cpp.

445{}

◆ OnExit()

void FrtosTask::OnExit ( )
inlineoverridevirtual

Called by the kernel before removal from the scheduling (see stk::KERNEL_DYNAMIC).

Note
The task's stack is no longer in use but the ITask object itself is still valid.
The default no-op implementation is sufficient for detached tasks. Override to implement join semantics (signal a waiting joiner).
Called in kernel/tick context - keep it short. ISR-safe primitives only (e.g. stk::sync::Semaphore::Signal(), stk::sync::EventFlags::Set()).
KERNEL_DYNAMIC only. Never called in KERNEL_STATIC mode.

Reimplemented from stk::ITask.

Definition at line 434 of file freertos_stk.cpp.

References Deleted, and m_state.

◆ Run()

void FrtosTask::Run ( )
inlineoverridevirtual

Entry point of the user task.

Note
Called by the Kernel when the task is scheduled for execution. Implement this method with the task's main logic.
Warning
If Kernel is configured as KERNEL_STATIC, the body must contain an infinite loop.
void Run( override)
{
while (true)
{
// task logic here
}
}
void Run() override
Entry point of the user task.

Implements stk::ITask.

Definition at line 428 of file freertos_stk.cpp.

429 {
431 // KERNEL_DYNAMIC: returning removes the task automatically.
432 }

References m_argument, and m_func.

Member Data Documentation

◆ m_argument

void* FrtosTask::m_argument

Definition at line 454 of file freertos_stk.cpp.

Referenced by FrtosTask(), Run(), xTaskCreate(), and xTaskCreateStatic().

◆ m_cb_owned

bool FrtosTask::m_cb_owned

Definition at line 460 of file freertos_stk.cpp.

Referenced by FrtosTask(), and xTaskCreateStatic().

◆ m_func

TaskFunction_t FrtosTask::m_func

Definition at line 453 of file freertos_stk.cpp.

Referenced by FrtosTask(), Run(), xTaskCreate(), and xTaskCreateStatic().

◆ m_name

const char* FrtosTask::m_name

◆ m_notify

◆ m_stack

stk::Word* FrtosTask::m_stack

◆ m_stack_owned

bool FrtosTask::m_stack_owned

Definition at line 459 of file freertos_stk.cpp.

Referenced by FrtosTask(), xTaskCreate(), xTaskCreateStatic(), and ~FrtosTask().

◆ m_stack_size

size_t FrtosTask::m_stack_size

Definition at line 458 of file freertos_stk.cpp.

Referenced by FrtosTask(), GetStackSize(), xTaskCreate(), and xTaskCreateStatic().

◆ m_state

◆ m_task_number

uint32_t FrtosTask::m_task_number

Definition at line 462 of file freertos_stk.cpp.

Referenced by FrtosTask(), and uxTaskGetSystemState().

◆ m_tls

void* FrtosTask::m_tls[4U]

◆ m_weight

volatile int32_t FrtosTask::m_weight

◆ s_task_counter

uint32_t FrtosTask::s_task_counter = 0U
static

Definition at line 466 of file freertos_stk.cpp.

Referenced by FrtosTask().


The documentation for this struct was generated from the following file: