µOS++ IIIe Reference 7.0.0
The third edition of µOS++, a POSIX inspired open source framework, written in C++
Loading...
Searching...
No Matches
os::rtos::thread::stack Class Reference

Thread stack. More...

#include <cmsis-plus/rtos/os.h>

Public Types

using allocation_element_t = os::rtos::port::stack::allocation_element_t
 Type of a stack allocation element.
 
using element_t = os::rtos::port::stack::element_t
 Type of a stack element.
 

Public Member Functions

Constructors & Destructor
 stack ()
 Construct a thread stack object instance.
 
 ~stack ()=default
 Destruct the stack object instance.
 
Public Member Functions
void clear (void)
 Clear the stack pointer and size.
 
void set (stack::element_t *address, std::size_t size_bytes)
 Set the stack address and size.
 
void initialize (void)
 Align the pointers and initialise to a known pattern.
 
stack::element_tbottom (void)
 Get the stack lowest reserved address.
 
stack::element_ttop (void)
 Get the top stack address.
 
std::size_t size (void)
 Get the stack size.
 
bool check_bottom_magic (void)
 Check if bottom magic word is still there.
 
bool check_top_magic (void)
 Check if top magic word is still there.
 
std::size_t available (void)
 Compute how much available stack remains.
 

Static Public Member Functions

Public Static Member Functions
static std::size_t min_size (void)
 Get the min stack size.
 
static std::size_t min_size (std::size_t size_bytes)
 Set the min stack size.
 
static std::size_t default_size (void)
 Get the default stack size.
 
static std::size_t default_size (std::size_t size_bytes)
 Set the default stack size.
 

Static Public Attributes

static const element_t magic = os::rtos::port::stack::magic
 

Detailed Description

Thread stack.

This class does not contain the stack space itself, it is allocated outside, but stores the address and the size of the stack.

It also manages the global variables storing the min and default stack sizes.

Definition at line 429 of file os-thread.h.

Member Typedef Documentation

◆ allocation_element_t

using os::rtos::thread::stack::allocation_element_t = os::rtos::port::stack::allocation_element_t

Type of a stack allocation element.

For alignment reasons, the stack is allocated in larger chunks, usually 8-bytes long on Cortex-M cores.

Definition at line 447 of file os-thread.h.

◆ element_t

using os::rtos::thread::stack::element_t = os::rtos::port::stack::element_t

Type of a stack element.

The stack is organised as an array of platform words (usually 4-bytes long on Cortex-M cores).

Definition at line 439 of file os-thread.h.

Constructor & Destructor Documentation

◆ stack()

os::rtos::thread::stack::stack ( )
inline

Construct a thread stack object instance.

Warning
Cannot be invoked from Interrupt Service Routines.

Definition at line 2121 of file os-thread.h.

◆ ~stack()

os::rtos::thread::stack::~stack ( )
default

Destruct the stack object instance.

Member Function Documentation

◆ available()

std::size_t os::rtos::thread::stack::available ( void  )

Compute how much available stack remains.

Parameters
None.
Returns
Number of available bytes.

Count the number of bytes where the magic is still there.

Warning
: For large stacks it may be an expensive operation.
Cannot be invoked from Interrupt Service Routines.

Definition at line 191 of file os-thread.cpp.

◆ bottom()

thread::stack::element_t * os::rtos::thread::stack::bottom ( void  )
inline

Get the stack lowest reserved address.

Parameters
None.
Returns
The address of the stack reserved area.
Note
Can be invoked from Interrupt Service Routines.

Definition at line 2151 of file os-thread.h.

◆ check_bottom_magic()

bool os::rtos::thread::stack::check_bottom_magic ( void  )
inline

Check if bottom magic word is still there.

Parameters
None.
Return values
trueThe magic word is still there.
falseThe magic word was overwritten.
Note
Can be invoked from Interrupt Service Routines.

Definition at line 2178 of file os-thread.h.

◆ check_top_magic()

bool os::rtos::thread::stack::check_top_magic ( void  )
inline

Check if top magic word is still there.

Parameters
None.
Return values
trueThe magic word is still there.
falseThe magic word was overwritten.
Note
Can be invoked from Interrupt Service Routines.

Definition at line 2187 of file os-thread.h.

◆ clear()

void os::rtos::thread::stack::clear ( void  )
inline

Clear the stack pointer and size.

Parameters
None.
Returns
Nothing
Warning
Cannot be invoked from Interrupt Service Routines.

Definition at line 2130 of file os-thread.h.

◆ default_size() [1/2]

std::size_t os::rtos::thread::stack::default_size ( std::size_t  size_bytes)
inlinestatic

Set the default stack size.

Parameters
[in]size_bytesDefault stack size in bytes.
Returns
The previous value of the default stack size in bytes.
Warning
Cannot be invoked from Interrupt Service Routines.

Definition at line 2225 of file os-thread.h.

◆ default_size() [2/2]

std::size_t os::rtos::thread::stack::default_size ( void  )
inlinestatic

Get the default stack size.

Parameters
None.
Returns
The default stack size in bytes.
Note
Can be invoked from Interrupt Service Routines.

Definition at line 2216 of file os-thread.h.

◆ initialize()

void os::rtos::thread::stack::initialize ( void  )

Align the pointers and initialise to a known pattern.

Parameters
None.
Returns
Nothing.

◆ min_size() [1/2]

std::size_t os::rtos::thread::stack::min_size ( std::size_t  size_bytes)
inlinestatic

Set the min stack size.

Parameters
[in]size_bytesMinimum stack size in bytes.
Returns
The previous value of the min stack size in bytes.
Warning
Cannot be invoked from Interrupt Service Routines.

Definition at line 2205 of file os-thread.h.

◆ min_size() [2/2]

std::size_t os::rtos::thread::stack::min_size ( void  )
inlinestatic

Get the min stack size.

Parameters
None.
Returns
The min stack size in bytes.
Note
Can be invoked from Interrupt Service Routines.

Definition at line 2196 of file os-thread.h.

◆ set()

void os::rtos::thread::stack::set ( stack::element_t address,
std::size_t  size_bytes 
)
inline

Set the stack address and size.

Parameters
[in]addressBottom stack address.
[in]size_bytesReserved stack size, in bytes.
Parameters
None.
Returns
Nothing
Warning
Cannot be invoked from Interrupt Service Routines.

Definition at line 2140 of file os-thread.h.

◆ size()

std::size_t os::rtos::thread::stack::size ( void  )
inline

Get the stack size.

Parameters
None.
Returns
The stack size in bytes.
Note
Can be invoked from Interrupt Service Routines.

Definition at line 2169 of file os-thread.h.

◆ top()

thread::stack::element_t * os::rtos::thread::stack::top ( void  )
inline

Get the top stack address.

Parameters
None.
Returns
The address after the last stack element.
Note
Can be invoked from Interrupt Service Routines.

Definition at line 2160 of file os-thread.h.

Member Data Documentation

◆ magic

const element_t os::rtos::thread::stack::magic = os::rtos::port::stack::magic
static

Definition at line 449 of file os-thread.h.


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