SuperTinyKernel™ RTOS 1.08.x
Lightweight, high-performance, deterministic, bare-metal C++ RTOS for resource-constrained embedded systems. MIT Open Source License.
Loading...
Searching...
No Matches
stk::IStackMemory Class Referenceabstract

Interface for a stack memory region. More...

#include <stk_common.h>

Inheritance diagram for stk::IStackMemory:

Public Member Functions

virtual const WordGetStack () const =0
 Get pointer to the stack memory.
virtual size_t GetStackSize () const =0
 Get number of elements of the stack memory array.
virtual size_t GetStackSpace () const
 Get available stack space.

Protected Member Functions

 ~IStackMemory ()=default
 Destructor.

Detailed Description

Interface for a stack memory region.

Definition at line 412 of file stk_common.h.

Constructor & Destructor Documentation

◆ ~IStackMemory()

stk::IStackMemory::~IStackMemory ( )
protecteddefault

Destructor.

Note
Protected by design. Prevents unsafe polymorphic delete.

Member Function Documentation

◆ GetStack()

◆ GetStackSize()

◆ GetStackSpace()

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

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 430 of file stk_common.h.

431 {
432 const ArrayView<const Word> stack(GetStack(), GetStackSize());
433 const size_t total_size = stack.GetSize();
434 size_t space = 0U;
435
436 for (size_t i = 0U; i < total_size; ++i)
437 {
438 if (stack[i] == STK_STACK_MEMORY_FILLER)
439 {
440 space = i + 1U;
441 }
442 else
443 {
444 break; // terminate loop as soon as watermark ends
445 }
446 }
447
448 return space;
449 }
#define STK_STACK_MEMORY_FILLER
Sentinel value written to the entire stack region at initialization (stack watermark pattern).
Definition stk_defs.h:563
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:

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