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
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.

Detailed Description

Interface for a stack memory region.

Definition at line 318 of file stk_common.h.

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 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:

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