Querying Task Notification pending?

Is it possible for a “sending” task, i.e., the one that sent the notification using xTaskNotify(), to determine if the notification is still pending, e.g., similar to uxSemaphoreGetCount() on a binary semaphore?

I looked at xTaskNotifyAndQuery(), but that seemed intended for retrieving the notification value, not the notification state.

Can you use xTaskNotifyAndQuery() with the action set to no action?

1 Like

No specific application, although I did previously do something similar with a counting semaphore to create “backpressure”. So, if the sending task has the option of either holding off on another notification or perhaps sending it to a different task, it might like to check the status of the first notification.

Not as I understand it. The return value will always be pdPASS and you can only pass out the notification value, not the state. Furthermore, I wasn’t sure how to interpret this:

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

Does the statement that the target task “receives” the event mean that the state is change to “pending” if it is previously “non-pending”? That is unclear from the description.

Just to close this off - you are able to add your own code into tasks.c without modifying the C file itself by defining configINCLUDE_FREERTOS_TASK_C_ADDITIONS_H then adding your code to a header file freertos_tasks_c_additions.h - this link shows the mechanism:
https://github.com/FreeRTOS/FreeRTOS-Kernel/blob/V10.4.5/tasks.c#L5431 - you could add a function there to return the value you are looking for.

1 Like