Bare Metal Programming Tool Kit
|
an execution context (used by the RTOS) More...
#include <context.h>
Public Member Functions | |
constexpr | context (unsigned char *bottom, unsigned char *size) |
used only to construct the main context | |
context (void body(), unsigned int stack_size) | |
construct a context: specify its body and stack size | |
unsigned int | stack_unused () const |
check how much of the stack is still free | |
unsigned int | stack_used () const |
check how much of the stack has ever been used | |
void | resume () |
resume execution of this context | |
Public Attributes | |
const unsigned int | stack_size |
the size of the stack | |
Friends | |
std::ostream & | bmptk::operator<< (std::ostream &s, const context &st) |
Related Functions | |
(Note that these are not member functions.) | |
std::ostream & | operator<< (std::ostream &s, const context &st) |
prints a context | |
bmptk::context::context | ( | void | body(), |
unsigned int | stack_size | ||
) |
construct a context: specify its body and stack size
This constructor creates an exceution context, from the body function (the code to be executed by the context) and the stack size. To start executing within the context
void bmptk::context::resume | ( | ) |
resume execution of this context
This method resumes (or starts) execution of this context. The execution starts at the begiining of the body function provided to the constructor. When it is suspended (by calling the resume() of another context) and then resumed, execution resumes after the resume() call. When the body function terminates the the main is resumed. (And when terminated context is resumed main is resumed again).
unsigned int bmptk::context::stack_unused | ( | ) | const |
check how much of the stack is still free
This function checks how much of a stack has never been used. When an stack is alloacted its is filled with the pattern 0xDEAD. This function checks how much of this pattern is left, to determine how much of the stack is still untouched.
Note that this method can underestimate the stack use when the task only reads from (not writes tp) memory. This is rare, but when in doubt make your stack somewhat larger than seems to be required.
|
inline |
check how much of the stack has ever been used
This function checks how much of a stack has ever been used. When an stack is alloacted its is filled with the pattern 0xDEAD. This function checks how much of this pattern is left, to determine how much of the stack is still untouched.
Note that this method can underestimate the stack use when the task only reads from (not writes tp) memory. This is rare, but when in doubt make your stack somewhat larger than seems to be required.
|
related |
prints a context
This operator prints a line of information about a context. This is meant for debugging purposes only.