Appearance
Threading
Threading Functions.
Types
Name | |
---|---|
struct | osThreadAttr_t Attributes structure for thread. |
Functions Overview
Name | |
---|---|
osThreadId_t | osThreadNew(osThreadFunc_t func, void * argument, const osThreadAttr_t * attr) Create a thread and add it to Active Threads. |
const char * | osThreadGetName(osThreadId_t thread_id) Get name of a thread. |
osThreadId_t | osThreadGetId(void ) Return the thread ID of the current running thread. |
osThreadState_t | osThreadGetState(osThreadId_t thread_id) Get current thread state of a thread. |
uint32_t | osThreadGetStackSize(osThreadId_t thread_id) Get stack size of a thread. |
uint32_t | osThreadGetStackSpace(osThreadId_t thread_id) Get available stack space of a thread based on stack watermark recording during execution. |
osStatus_t | osThreadSetPriority(osThreadId_t thread_id, osPriority_t priority) Change priority of a thread. |
osPriority_t | osThreadGetPriority(osThreadId_t thread_id) Get current priority of a thread. |
osStatus_t | osThreadYield(void ) Pass control to next thread that is in state READY. |
osStatus_t | osThreadSuspend(osThreadId_t thread_id) Suspend execution of a thread. |
osStatus_t | osThreadResume(osThreadId_t thread_id) Resume execution of a thread. |
void | osThreadExit(void ) Terminate execution of current running thread. |
osStatus_t | osThreadTerminate(osThreadId_t thread_id) Terminate execution of a thread. |
uint32_t | osThreadGetCount(void ) Get number of active threads. |
uint32_t | osThreadEnumerate(osThreadId_t * thread_array, uint32_t array_items) Enumerate active threads. |
uint32_t | osThreadFlagsSet(osThreadId_t thread_id, uint32_t flags) Set the specified Thread Flags of a thread. |
uint32_t | osThreadFlagsClear(uint32_t flags) Clear the specified Thread Flags of current running thread. |
uint32_t | osThreadFlagsGet(void ) Get the current Thread Flags of current running thread. |
uint32_t | osThreadFlagsWait(uint32_t flags, uint32_t options, uint32_t timeout) Wait for one or more Thread Flags of the current running thread to become signaled. |
Defines
Name | |
---|---|
osWaitForever | Wait forever timeout value. |
Function Details
function osThreadNew
cpp
osThreadId_t osThreadNew(
osThreadFunc_t func,
void * argument,
const osThreadAttr_t * attr
)
Create a thread and add it to Active Threads.
Parameters:
- func thread function.
- argument pointer that is passed to the thread function as start argument.
- attr thread attributes; NULL: default values.
Return: thread ID for reference by other functions or NULL in case of error.
function osThreadGetName
cpp
const char * osThreadGetName(
osThreadId_t thread_id
)
Get name of a thread.
Parameters:
- thread_id thread ID obtained by osThreadNew or osThreadGetId.
Return: name as null-terminated string.
function osThreadGetId
cpp
osThreadId_t osThreadGetId(
void
)
Return the thread ID of the current running thread.
Return: thread ID for reference by other functions or NULL in case of error.
function osThreadGetState
cpp
osThreadState_t osThreadGetState(
osThreadId_t thread_id
)
Get current thread state of a thread.
Parameters:
- thread_id thread ID obtained by osThreadNew or osThreadGetId.
Return: current thread state of the specified thread.
function osThreadGetStackSize
cpp
uint32_t osThreadGetStackSize(
osThreadId_t thread_id
)
Get stack size of a thread.
Parameters:
- thread_id thread ID obtained by osThreadNew or osThreadGetId.
Return: stack size in bytes.
function osThreadGetStackSpace
cpp
uint32_t osThreadGetStackSpace(
osThreadId_t thread_id
)
Get available stack space of a thread based on stack watermark recording during execution.
Parameters:
- thread_id thread ID obtained by osThreadNew or osThreadGetId.
Return: remaining stack space in bytes.
function osThreadSetPriority
cpp
osStatus_t osThreadSetPriority(
osThreadId_t thread_id,
osPriority_t priority
)
Change priority of a thread.
Parameters:
- thread_id thread ID obtained by osThreadNew or osThreadGetId.
- priority new priority value for the thread function.
Return: status code that indicates the execution status of the function.
function osThreadGetPriority
cpp
osPriority_t osThreadGetPriority(
osThreadId_t thread_id
)
Get current priority of a thread.
Parameters:
- thread_id thread ID obtained by osThreadNew or osThreadGetId.
Return: current priority value of the specified thread.
function osThreadYield
cpp
osStatus_t osThreadYield(
void
)
Pass control to next thread that is in state READY.
Return: status code that indicates the execution status of the function.
function osThreadSuspend
cpp
osStatus_t osThreadSuspend(
osThreadId_t thread_id
)
Suspend execution of a thread.
Parameters:
- thread_id thread ID obtained by osThreadNew or osThreadGetId.
Return: status code that indicates the execution status of the function.
function osThreadResume
cpp
osStatus_t osThreadResume(
osThreadId_t thread_id
)
Resume execution of a thread.
Parameters:
- thread_id thread ID obtained by osThreadNew or osThreadGetId.
Return: status code that indicates the execution status of the function.
function osThreadExit
cpp
void osThreadExit(
void
)
Terminate execution of current running thread.
function osThreadTerminate
cpp
osStatus_t osThreadTerminate(
osThreadId_t thread_id
)
Terminate execution of a thread.
Parameters:
- thread_id thread ID obtained by osThreadNew or osThreadGetId.
Return: status code that indicates the execution status of the function.
function osThreadGetCount
cpp
uint32_t osThreadGetCount(
void
)
Get number of active threads.
Return: number of active threads.
function osThreadEnumerate
cpp
uint32_t osThreadEnumerate(
osThreadId_t * thread_array,
uint32_t array_items
)
Enumerate active threads.
Parameters:
- thread_array pointer to array for retrieving thread IDs.
- array_items maximum number of items in array for retrieving thread IDs.
Return: number of enumerated threads.
function osThreadFlagsSet
cpp
uint32_t osThreadFlagsSet(
osThreadId_t thread_id,
uint32_t flags
)
Set the specified Thread Flags of a thread.
Parameters:
- thread_id thread ID obtained by osThreadNew or osThreadGetId.
- flags specifies the flags of the thread that shall be set.
Return: thread flags after setting or error code if highest bit set.
function osThreadFlagsClear
cpp
uint32_t osThreadFlagsClear(
uint32_t flags
)
Clear the specified Thread Flags of current running thread.
Parameters:
- flags specifies the flags of the thread that shall be cleared.
Return: thread flags before clearing or error code if highest bit set.
function osThreadFlagsGet
cpp
uint32_t osThreadFlagsGet(
void
)
Get the current Thread Flags of current running thread.
Return: current thread flags.
function osThreadFlagsWait
cpp
uint32_t osThreadFlagsWait(
uint32_t flags,
uint32_t options,
uint32_t timeout
)
Wait for one or more Thread Flags of the current running thread to become signaled.
Parameters:
- flags specifies the flags to wait for.
- options specifies flags options (osFlagsXxxx).
- timeout the timeout in milliseconds or osWaitForever in case of no time-out. must be 0, if called in an interrupt context.
Return: thread flags before clearing or error code if highest bit set.
Macros Documentation
define osWaitForever
cpp
#define osWaitForever 0xFFFFFFFFU
Wait forever timeout value.