CMSIS-RTOS2
Version 2.1.0
Real-Time Operating System: API and RTX Reference Implementation
|
Synchronize threads using flags. More...
Functions | |
uint32_t | osThreadFlagsSet (osThreadId_t thread_id, uint32_t flags) |
Set the specified Thread Flags of a thread. More... | |
uint32_t | osThreadFlagsClear (uint32_t flags) |
Clear the specified Thread Flags of current running thread. More... | |
uint32_t | osThreadFlagsGet (void) |
Get the current Thread Flags of current running thread. More... | |
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. More... | |
Thread Flags are a more specialized version of the Event Flags. See Event Flags. While Event Flags can be used to globally signal a number of threads, thread flags are only send to a single specific thread. Every thread instance can receive thread flags without any additional allocation of a thread flags object.
uint32_t osThreadFlagsSet | ( | osThreadId_t | thread_id, |
uint32_t | flags | ||
) |
[in] | thread_id | thread ID obtained by osThreadNew or osThreadGetId. |
[in] | flags | specifies the flags of the thread that shall be set. |
The function osThreadFlagsSet sets the thread flags for a thread specified by parameter thread_id. It returns the flags set, or an error code if highest bit is set (refer to Flags Functions Error Codes). This function may be used also within interrupt service routines. Threads waiting for a flag to be set will resume from BLOCKED state.
uint32_t osThreadFlagsClear | ( | uint32_t | flags | ) |
[in] | flags | specifies the flags of the thread that shall be cleared. |
The function osThreadFlagsClear clears the specified flags for the currently running thread. It returns the flags before clearing, or an error code if highest bit is set (refer to Flags Functions Error Codes).
uint32_t osThreadFlagsGet | ( | void | ) |
The function osThreadFlagsGet returns the flags currently set for the currently running thread.
uint32_t osThreadFlagsWait | ( | uint32_t | flags, |
uint32_t | options, | ||
uint32_t | timeout | ||
) |
[in] | flags | specifies the flags to wait for. |
[in] | options | specifies flags options (osFlagsXxxx). |
[in] | timeout | Timeout Value or 0 in case of no time-out. |
The function osThreadFlagsWait suspends the execution of the currently RUNNING thread until any or all of the thread flags specified with the parameter flags are set. When these thread flags are already set, the function returns instantly. Otherwise the thread is put into the state BLOCKED. The function then returns flags before clearing, or an error code if highest bit is set (refer to Flags Functions Error Codes).
The parameter options specifies the wait condition:
Option | |
---|---|
osFlagsWaitAny | Wait for any flag (default). |
osFlagsWaitAll | Wait for all flags. |
osFlagsNoClear | Do not clear flags which have been specified to wait for. |
If osFlagsNoClear
is set in the options osThreadFlagsClear can be used to clear flags manually.
The parameter timeout represents a number of timer ticks and is an upper bound. The exact time delay depends on the actual time elapsed since the last timer tick.
Code Example