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::msgqueue::TryPutGetTask< _AccessMode > Class Template Reference

Verifies TryPut enqueues a message, TryGet retrieves it intact, and queue accounting stays consistent throughout. More...

Inheritance diagram for stk::test::msgqueue::TryPutGetTask< _AccessMode >:
Collaboration diagram for stk::test::msgqueue::TryPutGetTask< _AccessMode >:

Public Types

enum  

Public Member Functions

 TryPutGetTask (uint8_t task_id, int32_t)
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)
 Default no-op handler. Override in subclass to log or handle missed deadlines.
virtual void OnExit ()
 Default no-op handler. Override to implement join semantics (signal a waiting joiner).
virtual int32_t GetWeight () const
 Default weight of 1. Override in subclass if custom scheduling weight is needed.
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.
virtual size_t GetStackSpace ()
 Get available stack space.

Private Member Functions

void Run () override
 Entry point of the user task.

Private Attributes

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

Detailed Description

template<EAccessMode _AccessMode>
class stk::test::msgqueue::TryPutGetTask< _AccessMode >

Verifies TryPut enqueues a message, TryGet retrieves it intact, and queue accounting stays consistent throughout.

Definition at line 66 of file test_msgqueue.cpp.

Member Enumeration Documentation

◆ anonymous enum

anonymous enum
inherited

Definition at line 52 of file stk_helper.h.

Partial implementation of the user task.
Definition stk_helper.h:50

Constructor & Destructor Documentation

◆ TryPutGetTask()

template<EAccessMode _AccessMode>
stk::test::msgqueue::TryPutGetTask< _AccessMode >::TryPutGetTask ( uint8_t task_id,
int32_t  )
inline

Definition at line 71 of file test_msgqueue.cpp.

72 {}
Verifies TryPut enqueues a message, TryGet retrieves it intact, and queue accounting stays consistent...

References m_task_id.

Member Function Documentation

◆ GetAccessMode()

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

Get hardware access mode of the user task.

Implements stk::ITask.

Definition at line 57 of file stk_helper.h.

57{ return _AccessMode; }

◆ GetId()

virtual TId stk::Task< _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 77 of file stk_helper.h.

77{ 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::Task< _StackSize, _AccessMode >::GetStack ( ) const
inlinevirtualinherited

Get pointer to the stack memory.

Implements stk::IStackMemory.

Definition at line 54 of file stk_helper.h.

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

◆ GetStackSize()

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

Get number of elements of the stack memory array.

Implements stk::IStackMemory.

Definition at line 55 of file stk_helper.h.

55{ return _StackSize; }

◆ GetStackSizeBytes()

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

Get size of the memory in bytes.

Implements stk::IStackMemory.

Definition at line 56 of file stk_helper.h.

56{ return _StackSize * sizeof(Word); }

◆ GetStackSpace()

virtual size_t stk::IStackMemory::GetStackSpace ( )
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 252 of file stk_common.h.

253 {
254 const Word *stack = GetStack();
255 const size_t stack_size = GetStackSize();
256
257 // count leading Words equal to STK_STACK_MEMORY_FILLER (watermark)
258 size_t space = 0U;
260 {}
261
262 return space;
263 }

◆ GetTraceName()

virtual const char * stk::Task< _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 81 of file stk_helper.h.

81{ return nullptr; }

◆ GetWeight()

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

Default weight of 1. Override in subclass if custom scheduling weight is needed.

Note
Only relevant when using SwitchStrategySmoothWeightedRoundRobin. Prefer TaskW for compile-time weight assignment.

Implements stk::ITask.

Definition at line 73 of file stk_helper.h.

73{ return 1; }

◆ OnDeadlineMissed()

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

Default no-op handler. Override in subclass to log or handle missed deadlines.

Note
HRT deadline misses are only possible when the kernel is started with KERNEL_HRT.

Implements stk::ITask.

Definition at line 62 of file stk_helper.h.

#define STK_UNUSED(X)
Explicitly marks a variable as unused to suppress compiler warnings.
Definition stk_defs.h:524

◆ OnExit()

virtual void stk::Task< _StackSize, _AccessMode >::OnExit ( )
inlinevirtualinherited

Default no-op handler. Override to implement join semantics (signal a waiting joiner).

Note
Called by the kernel only in KERNEL_DYNAMIC mode.

Implements stk::ITask.

Definition at line 67 of file stk_helper.h.

67{}

◆ Run()

template<EAccessMode _AccessMode>
void stk::test::msgqueue::TryPutGetTask< _AccessMode >::Run ( )
inlineoverrideprivatevirtual

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() override
Entry point of the user task.

Implements stk::ITask.

Definition at line 75 of file test_msgqueue.cpp.

76 {
77 if (m_task_id == 0)
78 {
79 bool ok = true;
80
81 // Queue must start empty
82 ok &= g_Queue->IsEmpty();
83 ok &= (g_Queue->GetCount() == 0U);
84 ok &= (g_Queue->GetSpace() == _STK_MQ_CAPACITY);
85 ok &= (g_Queue->GetCapacity() == _STK_MQ_CAPACITY);
86 ok &= (g_Queue->GetMsgSize() == _STK_MQ_MSG_SIZE);
87 ok &= g_Queue->IsStorageValid();
88
89 // Enqueue one message
91 memset(tx, 0xAB, sizeof(tx));
92 ok &= g_Queue->TryPut(tx);
93
94 ok &= (g_Queue->GetCount() == 1U);
95 ok &= (g_Queue->GetSpace() == _STK_MQ_CAPACITY - 1U);
96 ok &= !g_Queue->IsEmpty();
97
98 // Dequeue and verify payload
100 ok &= g_Queue->TryGet(rx);
101 ok &= (memcmp(tx, rx, _STK_MQ_MSG_SIZE) == 0);
102 ok &= g_Queue->IsEmpty();
103 ok &= (g_Queue->GetCount() == 0U);
104
105 // Second TryGet on empty queue must fail
106 ok &= !g_Queue->TryGet(rx);
107
108 printf("TryPutGet: %s\n", ok ? "PASS" : "FAIL");
109 if (ok)
110 g_TestResult = 1;
111 }
112
114 }

References _STK_MQ_CAPACITY, _STK_MQ_MSG_SIZE, stk::test::msgqueue::g_InstancesDone, stk::test::msgqueue::g_Queue, stk::test::msgqueue::g_TestResult, and m_task_id.

Member Data Documentation

◆ m_stack

StackMemoryDef<_StackSize>::Type stk::Task< _StackSize, _AccessMode >::m_stack
privateinherited

Stack memory region, 16-byte aligned.

Definition at line 103 of file stk_helper.h.

◆ m_task_id

template<EAccessMode _AccessMode>
uint8_t stk::test::msgqueue::TryPutGetTask< _AccessMode >::m_task_id
private

Definition at line 68 of file test_msgqueue.cpp.

Referenced by Run(), and TryPutGetTask().


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