Select your cookie preferences

We use essential cookies and similar tools that are necessary to provide our site and services. We use performance cookies to collect anonymous statistics, so we can understand how customers use our site and make improvements. Essential cookies cannot be deactivated, but you can choose “Customize” or “Decline” to decline performance cookies.

If you agree, AWS and approved third parties will also use cookies to provide useful site features, remember your preferences, and display relevant content, including relevant advertising. To accept or decline all non-essential cookies, choose “Accept” or “Decline.” To make more detailed choices, choose “Customize.”

Updated Jun 2025

xTaskNotifyAndQueryFromISR, xTaskNotifyAndQueryIndexedFromISR

[RTOS Task Notification API]

task.h

1 BaseType_t xTaskNotifyAndQueryFromISR(
2 TaskHandle_t xTaskToNotify,
3 uint32_t ulValue,
4 eNotifyAction eAction,
5 uint32_t *pulPreviousNotifyValue,
6 BaseType_t *pxHigherPriorityTaskWoken );
7
8 BaseType_t xTaskNotifyAndQueryIndexedFromISR(
9 TaskHandle_t xTaskToNotify,
10 UBaseType_t uxIndexToNotify
11 uint32_t ulValue,
12 eNotifyAction eAction,
13 uint32_t *pulPreviousNotifyValue,
14 BaseType_t *pxHigherPriorityTaskWoken );

See RTOS Task Notifications for more details.

xTaskNotifyAndQueryIndexedFromISR() performs the same operation as xTaskNotifyIndexedFromISR() with the addition that it also returns the target task's prior notification value (the notification value at the time the function is called rather than at the time the function returns) in the additional pulPreviousNotifyValue parameter.

xTaskNotifyAndQueryFromISR() performs the same operation as xTaskNotifyFromISR() with the addition that it also returns the target task's prior notification value (the notification value at the time the function is called rather than at the time the function returns) in the additional pulPreviousNotifyValue parameter.

Parameters:

  • xTaskToNotify

    The handle of the RTOS task being notified. This is the target task. To obtain a task's handle create the task using xTaskCreate() and make use of the pxCreatedTask parameter, or create the task using xTaskCreateStatic() and store the returned value, or use the task's name in a call to xTaskGetHandle(). The handle of the currently executing RTOS task is returned by the xTaskGetCurrentTaskHandle() API function.

  • uxIndexToNotify

    The index within the target task's array of notification values to which the notification is to be sent. uxIndexToNotify must be less than configTASK_NOTIFICATION_ARRAY_ENTRIES.

  • ulValue

    Used to update the notification value of the target task. See the description of the eAction parameter below.

  • eAction

    An enumerated type that can take one of the values documented below in order to perform the associated action.

  • pulPreviousNotifyValue

    Can be used to pass out the target task's notification value before any bits are modified by the action of xTaskNotifyAndQueryFromISR(). pulPreviousNotifyValue is an optional parameter, and can be set to NULL if it is not required. If pulPreviousNotifyValue is not used then consider using xTaskNotify() in place of xTaskNotifyAndQueryFromISR().

  • pxHigherPriorityTaskWoken

    *pxHigherPriorityTaskWoken must be initialised to pdFALSE (0). xTaskNotifyAndQueryFromISR() will set *pxHigherPriorityTaskWoken to pdTRUE if sending the notification caused a task to unblock, and the unblocked task has a priority higher than the currently running task. If xTaskNotifyAndQueryFromISR() sets this value to pdTRUE then a context switch should be requested before the interrupt is exited. See the example below. pxHigherPriorityTaskWoken is an optional parameter and can
    be set to NULL.

eAction values and associated actions

  • eNoAction

    The target task receives the event, but its
    notification value is not updated. In this case ulValue is not used.

  • eSetBits

    The notification value of the target task will be bitwise ORed with ulValue. For example, if ulValue is set to 0x01, then bit 0 will get set within the target task's notification value. Likewise if ulValue is 0x04 then bit 2 will get set in the target task's notification value. In this way the RTOS task notification mechanism can be used as a light weight alternative to an event group.

  • eIncrement

    The notification value of the target task will be incremented by one, making the call to xTaskNotify() equivalent to a call to xTaskNotifyGive(). In this case ulValue is not used.

  • eSetValueWithOverwrite

    The notification value of the target task is unconditionally set to ulValue. In this way the RTOS task notification mechanism is being used as a light weight alternative to xQueueOverwrite().

  • eSetValueWithoutOverwrite

    If the target task does not already have a notification pending then its notification value will be set to ulValue. If the target task already has a notification pending then its notification value is not updated as to do so would overwrite the previous value before it was used. In this case the call to xTaskNotify() fails and pdFALSE is returned. In this way the RTOS task notification mechanism is being used as a light weight alternative to xQueueSend() on a queue of length 1.

Returns:

pdPASS is returned in all cases other than when eAction is set to eSetValueWithoutOverwrite and the target task's notification value cannot be updated because the target task already had a notification pending.

Example usage:

1void vAnISR( void )
2{
3/* Must be Initialised to pdFALSE! */
4BaseType_t xHigherPriorityTaskWoken = pdFALSE.
5uint32_t ulPreviousValue;
6
7 /* Set bit 8 in the 0th notification value of the task referenced
8 by xTask1Handle. Store the task's previous 0th notification value
9 (before bit 8 is set) in ulPreviousValue. */
10 xTaskNotifyAndQueryIndexedFromISR( xTask1Handle,
11 0,
12 ( 1UL << 8UL ),
13 eSetBits,
14 &ulPreviousValue,
15 &xHigherPriorityTaskWoken );
16
17 /* The task's previous notification value is saved in
18 ulPreviousValue. */
19
20 /* If the task referenced by xTask1Handle was in the Blocked
21 state, waiting for the notification, then it will now have been
22 moved from the Blocked state to the Ready state. If its priority
23 is higher than the priority of the currently executing task (the
24 task this interrupt interrupted) then xHigherPriorityTaskWoken will
25 have been set to pdTRUE, and passing the variable into a call to
26 portYIELD_FROM_ISR() will result in the interrupt returning directly
27 to the unblocked task. If xHigherPriorityTaskWoken is still pdFALSE
28 then passing it into portYIELD_FROM_ISR() will have no effect. */
29 portYIELD_FROM_ISR( xHigherPriorityTaskWoken );
30}