Practical application of clearing notification flags on entry vs on exit

I have been looking for practical examples/reasons for clearing notifications flags on entry vs on exit vs both (if ever used) but couldn’t find any. There was a previous post but still not clear about it.

I have always been clearing on entry so I know for sure that if it has set it would need to be processed but when would you clear on exit and both (if ever used both)?

Could someone give me a practical example?

Many thanks :slight_smile:

I think it’s most common to clear the flags on exit.

Consider a task that monitors two sensors. Each gives an interrupt on change. The ISRs set the corresponding flag to notify the task. The task’s job is to read the new data from the sensor that changed (or both if they happen to both have new data).

This task would instruct xTaskNotifyWait() to clear the flags on exit so the task doesn’t miss an event. If xTaskNotifyWait() cleared the flags on entry, then it might clear a flag before the application saw it. Of course with clear-on-exit, it’s possible the task may occasionally read a sensor that doesn’t have any new data, but that is typically harmless.

Thank you Jeff that makes sense :slight_smile: