CMSIS-RTOS
Version 1.03
Real-Time Operating System: API and RTX Reference Implementation.
|
Synchronize threads using signals. More...
Macros | |
#define | osFeature_Signals 8 |
maximum number of Signal Flags available per thread More... | |
Functions | |
int32_t | osSignalSet (osThreadId thread_id, int32_t signals) |
Set the specified Signal Flags of an active thread. More... | |
int32_t | osSignalClear (osThreadId thread_id, int32_t signals) |
Clear the specified Signal Flags of an active thread. More... | |
osEvent | osSignalWait (int32_t signals, uint32_t millisec) |
Wait for one or more Signal Flags to become signaled for the current RUNNING thread. More... | |
Signals are used to trigger execution states between threads. The signal management functions in CMSIS-RTOS allow you to control or wait for signal flags. Each thread has up to 31 assigned signal flags. The maximum number of signal flags is defined in the cmsis_os.h file (#define osFeature_Signals).
A thread
When a thread wakes up and resumes execution, its signal flags are automatically cleared.
Here is a simple example that shows how two thread can communicate with each others using signals:
The following steps are required to use signals:
tid_thread1
) that is supposed to wait for a signal, call the wait function: #define osFeature_Signals 8 |
The CMSIS-RTOS API may support a variable number of signal flags. This define specifies the number of signal flags available per thread. The maximum value is 32 signal flags per thread.
CMSIS-RTOS RTX Setting: osFeature_Signals is 16
int32_t osSignalClear | ( | osThreadId | thread_id, |
int32_t | signals | ||
) |
[in] | thread_id | thread ID obtained by osThreadCreate or osThreadGetId. |
[in] | signals | specifies the signal flags of the thread that shall be cleared. |
Clear the signal flags of an active thread.
Code Example
int32_t osSignalSet | ( | osThreadId | thread_id, |
int32_t | signals | ||
) |
[in] | thread_id | thread ID obtained by osThreadCreate or osThreadGetId. |
[in] | signals | specifies the signal flags of the thread that should be set. |
Set the signal flags of an active thread. This function may be used also within interrupt service routines.
Code Example
osEvent osSignalWait | ( | int32_t | signals, |
uint32_t | millisec | ||
) |
[in] | signals | wait until all specified signal flags set or 0 for any single signal flag. |
[in] | millisec | Timout Value or 0 in case of no time-out. |
Suspend the execution of the current RUNNING thread until all specified signal flags with the parameter signals are set. When the parameter signals is 0 the current RUNNING thread is suspended until any signal is set. When these signal flags are already set, the function returns instantly. Otherwise the thread is put into the state WAITING. Signal flags that are reported as event are automatically cleared.
The argument millisec specifies how long the system waits for the specified signal flags. While the system waits the tread calling this function is put into the state WAITING. The timeout value can have the following values:
Code Example