The Thread class allow defining, creating, and controlling thread functions in the system. More...
#include <Thread.h>
Public Types |
Public Member Functions | |
Thread (osPriority priority=osPriorityNormal, uint32_t stack_size=OS_STACK_SIZE, unsigned char *stack_mem=nullptr, const char *name=nullptr) | |
Allocate a new thread without starting execution. More... | |
Thread (uint32_t tz_module, osPriority priority=osPriorityNormal, uint32_t stack_size=OS_STACK_SIZE, unsigned char *stack_mem=nullptr, const char *name=nullptr) | |
Allocate a new thread without starting execution. More... | |
osStatus | start (mbed::Callback< void()> task) |
Starts a thread executing the specified function. More... | |
osStatus | join () |
Wait for thread to terminate. More... | |
osStatus | terminate () |
Terminate execution of a thread and remove it from Active Threads. More... | |
osStatus | set_priority (osPriority priority) |
Set priority of an active thread. More... | |
osPriority | get_priority () const |
Get priority of an active thread. More... | |
uint32_t | flags_set (uint32_t flags) |
Set the specified Thread Flags for the thread. More... | |
State | get_state () const |
State of this Thread. More... | |
uint32_t | stack_size () const |
Get the total stack memory size for this Thread. More... | |
uint32_t | free_stack () const |
Get the currently unused stack memory for this Thread. More... | |
uint32_t | used_stack () const |
Get the currently used stack memory for this Thread. More... | |
uint32_t | max_stack () const |
Get the maximum stack memory usage to date for this Thread. More... | |
const char * | get_name () const |
Get thread name. More... | |
osThreadId_t | get_id () const |
Get thread id. More... | |
virtual | ~Thread () |
Thread destructor. More... | |
The Thread class allow defining, creating, and controlling thread functions in the system.
Example:
tz_module
as argument during thread creation.MBED_TZ_DEFAULT_ACCESS is target specific define, should be set in targets.json file for Cortex-M23/M33 devices.
enum State |
State of the Thread.
Enumerator | |
---|---|
Inactive |
NOT USED. |
Ready |
Ready to run. |
Running |
Running. |
WaitingDelay |
Waiting for a delay to occur. |
WaitingJoin |
Waiting for thread to join. Only happens when using RTX directly. |
WaitingThreadFlag |
Waiting for a thread flag to be set. |
WaitingEventFlag |
Waiting for a event flag to be set. |
WaitingMutex |
Waiting for a mutex event to occur. |
WaitingSemaphore |
Waiting for a semaphore event to occur. |
WaitingMemoryPool |
Waiting for a memory pool. |
WaitingMessageGet |
Waiting for message to arrive. |
WaitingMessagePut |
Waiting for message to be send. |
WaitingInterval |
NOT USED. |
WaitingOr |
NOT USED. |
WaitingAnd |
NOT USED. |
WaitingMailbox |
NOT USED (Mail is implemented as MemoryPool and Queue) |
Deleted |
The task has been deleted or not started. |
Thread | ( | osPriority | priority = osPriorityNormal , |
uint32_t | stack_size = OS_STACK_SIZE , |
||
unsigned char * | stack_mem = nullptr , |
||
const char * | name = nullptr |
||
) |
Allocate a new thread without starting execution.
priority | initial priority of the thread function. (default: osPriorityNormal). |
stack_size | stack size (in bytes) requirements for the thread function. (default: OS_STACK_SIZE). |
stack_mem | pointer to the stack area to be used by this thread (default: nullptr). |
name | name to be used for this thread. It has to stay allocated for the lifetime of the thread (default: nullptr) |
Thread | ( | uint32_t | tz_module, |
osPriority | priority = osPriorityNormal , |
||
uint32_t | stack_size = OS_STACK_SIZE , |
||
unsigned char * | stack_mem = nullptr , |
||
const char * | name = nullptr |
||
) |
Allocate a new thread without starting execution.
tz_module | trustzone thread identifier (osThreadAttr_t::tz_module) Context of RTOS threads in non-secure state must be saved when calling secure functions. tz_module ID is used to allocate context memory for threads, and it can be safely set to zero for threads not using secure calls at all. See "TrustZone RTOS Context Management" for more details. |
priority | initial priority of the thread function. (default: osPriorityNormal). |
stack_size | stack size (in bytes) requirements for the thread function. (default: OS_STACK_SIZE). |
stack_mem | pointer to the stack area to be used by this thread (default: nullptr). |
name | name to be used for this thread. It has to stay allocated for the lifetime of the thread (default: nullptr) |
uint32_t flags_set | ( | uint32_t | flags | ) |
Set the specified Thread Flags for the thread.
flags | specifies the flags of the thread that should be set. |
uint32_t free_stack | ( | ) | const |
Get the currently unused stack memory for this Thread.
osThreadId_t get_id | ( | ) | const |
Get thread id.
const char* get_name | ( | ) | const |
Get thread name.
osPriority get_priority | ( | ) | const |
Get priority of an active thread.
State get_state | ( | ) | const |
osStatus join | ( | ) |
Wait for thread to terminate.
uint32_t max_stack | ( | ) | const |
Get the maximum stack memory usage to date for this Thread.
osStatus set_priority | ( | osPriority | priority | ) |
Set priority of an active thread.
priority | new priority value for the thread function. |
uint32_t stack_size | ( | ) | const |
Get the total stack memory size for this Thread.
osStatus start | ( | mbed::Callback< void()> | task | ) |
Starts a thread executing the specified function.
task | function to be executed by this thread. |
osStatus terminate | ( | ) |
Terminate execution of a thread and remove it from Active Threads.
uint32_t used_stack | ( | ) | const |
Get the currently used stack memory for this Thread.