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.

Detailed Description

Interface for a stack memory region.

Definition at line 400 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 418 of file stk_common.h.

419 {
420 const ArrayView<const Word> stack(GetStack(), GetStackSize());
421 const size_t total_size = stack.GetSize();
422 size_t space = 0U;
423
424 for (size_t i = 0U; i < total_size; ++i)
425 {
426 if (stack[i] == STK_STACK_MEMORY_FILLER)
427 {
428 space = i + 1U;
429 }
430 else
431 {
432 break; // terminate loop as soon as watermark ends
433 }
434 }
435
436 return space;
437 }
#define STK_STACK_MEMORY_FILLER
Sentinel value written to the entire stack region at initialization (stack watermark pattern).
Definition stk_defs.h:502
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: