SuperTinyKernel™ RTOS 1.05.3
Lightweight, high-performance, deterministic, bare-metal C++ RTOS for resource-constrained embedded systems. MIT Open Source License.
Loading...
Searching...
No Matches
stk::test::TaskMockW< _Weight, _AccessMode > Class Template Reference

Task mock for SwitchStrategySmoothWeightedRoundRobin and similar algorithms. More...

#include <stktest.h>

Inheritance diagram for stk::test::TaskMockW< _Weight, _AccessMode >:
Collaboration diagram for stk::test::TaskMockW< _Weight, _AccessMode >:

Public Types

enum  

Public Member Functions

WordGetStack () const
 Get pointer to the stack memory.
size_t GetStackSize () const
 Get number of elements of the stack memory array.
size_t GetStackSizeBytes () const
 Get size of the memory in bytes.
EAccessMode GetAccessMode () const
 Get hardware access mode of the user task.
virtual void OnDeadlineMissed (uint32_t duration)
 Hard Real-Time mode is unsupported for weighted tasks. Triggers an assertion if called.
virtual int32_t GetWeight () const
 Returns the compile-time weight _Weight.
virtual TId GetId () const
 Get object's own address as its Id. Unique per task instance, requires no manual assignment.
virtual const char * GetTraceName () const
 Override in subclass to supply a name for SEGGER SystemView tracing. Returns NULL by default.

Private Member Functions

void Run ()
 Entry point of the user task.

Private Attributes

StackMemoryDef< _StackSize >::Type m_stack
 Stack memory region, 16-byte aligned.

Detailed Description

template<int32_t _Weight, EAccessMode _AccessMode>
class stk::test::TaskMockW< _Weight, _AccessMode >

Task mock for SwitchStrategySmoothWeightedRoundRobin and similar algorithms.

Note
QEMU allocates small stack for the function, therefore stack size is limited to STACK_SIZE_MIN for tests to pass (256 was causing a hard fault).

Definition at line 356 of file stktest.h.

Member Enumeration Documentation

◆ anonymous enum

anonymous enum
inherited

Definition at line 119 of file stk_helper.h.

Partial implementation of the user task with a compile-time scheduling weight. Use when the kernel is...
Definition stk_helper.h:117

Member Function Documentation

◆ GetAccessMode()

EAccessMode stk::TaskW< _Weight, _StackSize, _AccessMode >::GetAccessMode ( ) const
inlinevirtualinherited

Get hardware access mode of the user task.

Implements stk::ITask.

Definition at line 124 of file stk_helper.h.

124{ return _AccessMode; }

◆ GetId()

virtual TId stk::TaskW< _Weight, _StackSize, _AccessMode >::GetId ( ) const
inlinevirtualinherited

Get object's own address as its Id. Unique per task instance, requires no manual assignment.

Implements stk::ITask.

Definition at line 137 of file stk_helper.h.

137{ return hw::PtrToWord(this); }
__stk_forceinline Word PtrToWord(T *ptr) noexcept
Cast a pointer to a CPU register-width integer.
Definition stk_arch.h:94

◆ GetStack()

Word * stk::TaskW< _Weight, _StackSize, _AccessMode >::GetStack ( ) const
inlinevirtualinherited

Get pointer to the stack memory.

Implements stk::IStackMemory.

Definition at line 121 of file stk_helper.h.

121{ return const_cast<Word *>(m_stack); }

◆ GetStackSize()

size_t stk::TaskW< _Weight, _StackSize, _AccessMode >::GetStackSize ( ) const
inlinevirtualinherited

Get number of elements of the stack memory array.

Implements stk::IStackMemory.

Definition at line 122 of file stk_helper.h.

122{ return _StackSize; }

◆ GetStackSizeBytes()

size_t stk::TaskW< _Weight, _StackSize, _AccessMode >::GetStackSizeBytes ( ) const
inlinevirtualinherited

Get size of the memory in bytes.

Implements stk::IStackMemory.

Definition at line 123 of file stk_helper.h.

123{ return _StackSize * sizeof(Word); }

◆ GetTraceName()

virtual const char * stk::TaskW< _Weight, _StackSize, _AccessMode >::GetTraceName ( ) const
inlinevirtualinherited

Override in subclass to supply a name for SEGGER SystemView tracing. Returns NULL by default.

Implements stk::ITask.

Definition at line 141 of file stk_helper.h.

141{ return nullptr; }

◆ GetWeight()

virtual int32_t stk::TaskW< _Weight, _StackSize, _AccessMode >::GetWeight ( ) const
inlinevirtualinherited

Returns the compile-time weight _Weight.

Implements stk::ITask.

Definition at line 133 of file stk_helper.h.

133{ return _Weight; }

◆ OnDeadlineMissed()

virtual void stk::TaskW< _Weight, _StackSize, _AccessMode >::OnDeadlineMissed ( uint32_t duration)
inlinevirtualinherited

Hard Real-Time mode is unsupported for weighted tasks. Triggers an assertion if called.

Warning
Do not use TaskW with KERNEL_HRT. Use Task instead.

Implements stk::ITask.

Definition at line 129 of file stk_helper.h.

129{ STK_ASSERT(false); (void)duration; }
#define STK_ASSERT(e)
Runtime assertion. Halts execution if the expression e evaluates to false.
Definition stk_defs.h:330

◆ Run()

template<int32_t _Weight, EAccessMode _AccessMode>
void stk::test::TaskMockW< _Weight, _AccessMode >::Run ( )
inlineprivatevirtual

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()
{
while (true)
{
// task logic here
}
}
void Run()
Entry point of the user task.
Definition stktest.h:359

Implements stk::ITask.

Definition at line 359 of file stktest.h.

359{}

Member Data Documentation

◆ m_stack

StackMemoryDef<_StackSize>::Type stk::TaskW< _Weight, _StackSize, _AccessMode >::m_stack
privateinherited

Stack memory region, 16-byte aligned.

Definition at line 162 of file stk_helper.h.


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