Efficient Inter‑Task Communication with Nucleus SE Signals
In this RTOS Revealed series, we explore signals – the simplest, low‑cost method for inter‑task communication in Nucleus SE. Signals enable lightweight, reliable message passing between tasks.
Using Signals
Unlike other kernel objects, signals are not autonomous; they are intrinsically linked to a task and exist only within that task’s context. When signals are enabled in an application, every task automatically receives a set of eight binary signal flags.
Any task can set the signal flags of another task. However, only the owning task may read and clear those flags – and reading is destructive, meaning the flags are reset during the read operation. No other task can inspect or modify a task’s signal state.
Nucleus RTOS offers a facility that lets a task nominate a callback to run when another task sets one of its signal flags. This is analogous to an interrupt service routine. Unfortunately, this feature is not available in Nucleus SE; tasks must explicitly poll their signal flags.
Configuring Signals
Signals are configured primarily through #define directives in nuse_config.h. The key macro is NUSE_SIGNAL_SUPPORT, which, when set to TRUE, activates signal support across the entire application. The number of signals per task is fixed at eight; no additional configuration is required.
Enabling signals creates the necessary data structures and activates the relevant API calls. Each API function in Nucleus SE has its own enabling macro. For signals, the following enables are defined:
NUSE_SIGNALS_SEND NUSE_SIGNALS_RECEIVE
By default, both are set to FALSE, disabling the corresponding service calls and omitting any implementation code. To use signals, set the desired enables to TRUE. Failure to enable the API while using a call will result in a compile‑time error; using an unimplemented API will cause a link‑time error.
Sample excerpt from nuse_config.h:
#define NUSE_SIGNAL_SUPPORT FALSE /* Enables support for signals */ #define NUSE_SIGNALS_SEND FALSE /* Service call enabler */ #define NUSE_SIGNALS_RECEIVE FALSE /* Service call enabler */
Signals Service Calls
Nucleus SE provides four primary service calls related to signals. Only two are implemented in SE; the others are reserved for RTOS but not SE.
- Send signals to a specified task – NUSE_Signals_Send()
- Receive signals – NUSE_Signals_Receive()
- Register a signal handler – not implemented in SE
- Enable/disable signals – not implemented in SE
Send and Receive Operations
Signal flags are bits, best visualized as binary numbers. Since standard C lacks binary literals, Nucleus SE includes nuse_binary.h, which defines macros like b01010101 for all 256 8‑bit values.
#define b00000000 ((U8)0x00) #define b00000001 ((U8)0x01) #define b00000010 ((U8)0x02) #define b00000011 ((U8)0x03) #define b00000100 ((U8)0x04) #define b00000101 ((U8)0x05)
Sending Signals
Any task may set one or more signal flags on another task via an OR operation – previously set flags remain unchanged.
Nucleus RTOS API Call
STATUS NU_Send_Signals(NU_TASK *task, UNSIGNED signals);
Parameters:
- task – pointer to the control block of the target task
- signals – value of the signal flags to set
Returns:
- NU_SUCCESS – call succeeded
- NU_INVALID_TASK – invalid task pointer
Nucleus SE API Call
STATUS NUSE_Signals_Send(NUSE_TASK task, U8 signals);
Parameters:
- task – task index (ID) of the target task
- signals – value of the signal flags to set
Returns:
- NUSE_SUCCESS – call succeeded
- NUSE_INVALID_TASK – invalid task index
Implementation of NUSE_Signals_Send()
STATUS NUSE_Signals_Send(NUSE_TASK task, U8 signals){
#if NUSE_API_PARAMETER_CHECKING
if (task >= NUSE_TASK_NUMBER){
return NUSE_INVALID_TASK;
}
#endif
NUSE_CS_Enter();
NUSE_Task_Signal_Flags[task] |= signals;
NUSE_CS_Exit();
return NUSE_SUCCESS;
}
Receiving Signals
A task can only read its own signal flags, and the operation is destructive – the flags are cleared upon read.
Nucleus RTOS API Call
UNSIGNED NU_Receive_Signals(VOID);
Returns the current signal flag value.
Nucleus SE API Call
U8 NUSE_Signals_Receive(void);
Returns the current signal flag value.
Implementation of NUSE_Signals_Receive()
U8 NUSE_Signals_Receive(void){
U8 signals;
NUSE_CS_Enter();
signals = NUSE_Task_Signal_Flags[NUSE_Task_Active];
NUSE_Task_Signal_Flags[NUSE_Task_Active] = 0;
NUSE_CS_Exit();
return signals;
}
These straightforward functions illustrate how Nucleus SE manages signals efficiently without affecting task blocking or scheduling.
Embedded
- Binary Signals and Logic Gates: Foundations of Digital Electronics
- Analog and Digital Signals: Foundations of Industrial Instrumentation
- Mixed‑Frequency AC Signals: Coupling, Harmonics, and Practical Insights
- Understanding Square Wave Signals: Fundamentals and Applications
- Rutronik Distributes Redpine Signals’ RS14100: Ultra‑Low‑Power, Multi‑Protocol Secure Wireless MCUs
- Rutronik Offers Ultra‑Low‑Power, Multi‑Protocol SoCs from Redpine Signals
- Measuring the Magnetic Signature of a Single Atom’s Nucleus
- Essential RF & Microwave Design Principles for Reliable PCB Performance
- Crane Hand Signals: The Key to Safer Operations
- ABB Sensors: Reliable Electrical Signal Solutions for Industrial Control