CMSIS-RTOS RTX: Signal Management

| CMSIS-RTOS RTX Version 4.80 CMSIS-RTOS RTX: Real-Time Operating System for Cortex-M processor-based devices

- Main Page
- Usage and Description
- Reference

All Data Structures Files Functions Variables Typedefs Enumerations Enumerator Macros Groups Pages
Macros | Functions
Signal Management
CMSIS-RTOS API (RTX)

Control or wait for signal flags. More...

## Macros
#define | osFeature_Signals 16
| 16 Signal Flags available per thread

## Functions
int32_t | osSignalSet (osThreadId thread_id, int32_t signals)
| Set the specified Signal Flags of an active thread.
int32_t | osSignalClear (osThreadId thread_id, int32_t signals)
| Clear the specified Signal Flags of an active thread.
os_InRegs osEvent | osSignalWait (int32_t signals, uint32_t millisec)
| Wait for one or more Signal Flags to become signaled for the current RUNNING thread.

## Description

The Signal Management function group allows to control or wait signal flags. Each thread has assigned signal flags.

## Macro Definition Documentation

#define osFeature_Signals 16

CMSIS-RTOS RTX supports up to 16 signal flags per thread.

## Function Documentation

int32_t osSignalClear | ( | osThreadId | thread_id,
|  | int32_t | signals
| ) |  |

Parameters

  [in] | thread_id | thread ID obtained by osThreadCreate or osThreadGetId.
  [in] | signals | specifies the signal flags of the thread that shall be cleared.

Returns
  previous signal flags of the specified thread or 0x80000000 in case of incorrect parameters or call from ISR.

Clear the signal flags of an active thread. This function cannot be called from interrupt service routines.

Note
  Cannot be called from Interrupt Service Routines.

Example

void Thread_2 (void const *arg);
osThreadDef (Thread_2, osPriorityHigh, 1, 0);
static void EX_Signal_1 (void) {
int32_t signals;
osThreadId thread_id;
thread_id = osThreadCreate (osThread(Thread_2), NULL);
if (thread_id == NULL) {
// Failed to create a thread.
}
else {
f :
signals = osSignalClear (thread_id, 0x01);
}
}

int32_t osSignalSet | ( | osThreadId | thread_id,
|  | int32_t | signals
| ) |  |

Parameters

  [in] | thread_id | thread ID obtained by osThreadCreate or osThreadGetId.
  [in] | signals | specifies the signal flags of the thread that should be set.

Returns
  previous signal flags of the specified thread or 0x80000000 in case of incorrect parameters.

Set the signal flags of an active thread.

Note
  Interrupt Service Routines can call this function.

Example

void Thread_2 (void const *arg);
osThreadDef (Thread_2, osPriorityHigh, 1, 0);
static void EX_Signal_1 (void) {
int32_t signals;
uint32_t exec;
osThreadId thread_id;
thread_id = osThreadCreate (osThread(Thread_2), NULL);
if (thread_id == NULL) {
// Failed to create a thread.
}
else {
signals = osSignalSet (thread_id, 0x00000005); // Send signals to the created thread
}
}

osEvent osSignalWait | ( | int32_t | signals,
|  | uint32_t | millisec
| ) |  |

Parameters

  [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.

Returns
  event flag information or error code.

Suspend the execution of the current RUNNING thread until all specified signal flags with the parameter signals are set. When this 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:

- when millisec is 0, the function returns instantly.
- when millisec is set to osWaitForever the function will wait for an infinite time until a specified signal is set.
- all other values specify a time in millisecond for a timeout.

Status and Error Codes

- osOK: no signal received when the timeout value millisec was 0.
- osEventTimeout: signal not occurred within timeout
- osEventSignal: signal occurred, value.signals contains the signal flags; these signal flags are cleared.
- osErrorValue: the value signals is outside of the permitted range.
- osErrorISR: osSignalWait cannot be called from interrupt service routines.

Note
  Cannot be called from Interrupt Service Routines.

Example

void Thread_2 (void const *arg);
osThreadDef (Thread_2, osPriorityHigh, 1, 0);
static void EX_Signal_1 (void) {
osThreadId thread_id;
osEvent evt;
thread_id = osThreadCreate (osThread(Thread_2), NULL);
if (thread_id == NULL) {
// Failed to create a thread.
}
else {
:
// wait for a signal
evt = osSignalWait (0x01, 100);
if (evt.status == osEventSignal) {
// handle event status
}
}
}