![]() |
CMSIS-RTOS2
Version 2.0.0
Real-Time Operating System: API and RTX Reference Implementation
|
Synchronize threads using flags. More...
Functions | |
int32_t | osThreadFlagsSet (osThreadId_t thread_id, int32_t flags) |
Set the specified Thread Flags of a thread. More... | |
int32_t | osThreadFlagsClear (int32_t flags) |
Clear the specified Thread Flags of current running thread. More... | |
int32_t | osThreadFlagsGet (void) |
Get the current Thread Flags of current running thread. More... | |
int32_t | osThreadFlagsWait (int32_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.
int32_t osThreadFlagsSet | ( | osThreadId_t | thread_id, |
int32_t | flags | ||
) |
[in] | thread_id | thread ID obtained by osThreadNew or osThreadGetId. |
[in] | flags | specifies the flags of the thread that shall be set. |
Set the thread flags for a thread instance specified by thread_id. This function may be used also within interrupt service routines. The threads waiting for the flag set will be notified to resume from BLOCKED state.
Code Example
osStatus osThreadFlagsClear | ( | int32_t | flags | ) |
[in] | flags | specifies the flags of the thread that shall be cleared. |
Clear the specified event flags set for the a calling thread.
int32_t osThreadFlagsGet | ( | void | ) |
Return the event flags currently set for the calling thread.
int32_t osThreadFlagsWait | ( | int32_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. |
Suspend the execution of the current RUNNING thread until any or all specified thread flags with the parameter flags are set. The options parameter 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.
When these thread flags are already set, the function returns instantly. Otherwise the thread is put into the state BLOCKED.
Code Example