# Task event management

**URL:** <https://forums.freertos.org/t/task-event-management/7166>\
**Category:** Kernel\
**Created:** [April 27, 2018, 12:06pm UTC](https://forums.freertos.org/t/task-event-management/7166 "2018-04-27T12:06:16Z")\
**Posts on this page:** 2\
**Page:** 1

<div class="post-metadata">

**Author:** ![system](https://d2v6vdsk2p900z.cloudfront.net/original/1X/7fc8fdb729c645aab5b20282bbe34e57cb407be6.jpeg) [@system](https://forums.freertos.org/u/system)\
**Post date:** [April 27, 2018, 12:06pm UTC](https://forums.freertos.org/t/task-event-management/7166/1 "2018-04-27T12:06:16Z")

</div>

**[giso1](https://sourceforge.net/u/giso1/)** wrote on [Friday, April 27, 2018](https://sourceforge.net/p/freertos/discussion/382005/thread/d0a7ccd2/#9fcf):

Hi,

I have the following pseudo code

task\_run()  
{  
while (true)  
{  
xTaskNotifyWait(eventA|eventB)  
if (eventA)  
{  
send RF command  
xTaskNotifyWait(eventA)  
}  
if (eventB)  
{  
process command  
}  
do something else  
}  
}

EventA is triggered by interrupt when RF data is received.  
EventB is triggered when application request to trigger a cmd  
I have the following issue when I have the following sequence

- EventA received
- task is woken up
- EventB occurs before the second xTaskNotifyWait is called  
the first xTaskNotifyWait(eventA|eventB) will not detect eventB.

to simulate I do the following  
task\_run()  
{  
while (true)  
{  
xTaskNotifyWait(eventA|eventB)  
if (eventA)  
{  
trigger EventB  
send RF command  
xTaskNotifyWait(eventA)  
}  
if (eventB)  
{  
process command  
}  
do something else  
}  
}

Is that the expected behaviour?  
I would have expected that when waiting for a specific event, xTaskNotifyWait would only retrieve these specific events and if other event have been set they would be kept and available for other call to xTaskNotifyWait.

Thanks for feedback.

---

<div class="post-metadata">

**Author:** ![rtel](https://d3iykfbgfh8zhg.cloudfront.net/user_avatar/forums.freertos.org/rtel/32/31_2.png) [@rtel](https://forums.freertos.org/u/rtel)\
**Post date:** [April 27, 2018, 2:16pm UTC](https://forums.freertos.org/t/task-event-management/7166/2 "2018-04-27T14:16:05Z")

</div>

**[rtel](https://sourceforge.net/u/rtel/)** wrote on [Friday, April 27, 2018](https://sourceforge.net/p/freertos/discussion/382005/thread/d0a7ccd2/#9fcf/b4a7):

It looks like you are expecting the same behaviour as an event group,  
where bits are latched. That is not the case when using a notification,  
where you specify which bits to clear on exit from the wait function.  
If the eventB bit is set between the first and second calls to  
xTaskNotifyWait() then you will have to either remember it was set so  
you can then process it on the next go around the loop, or make sure the  
second call to xTaskNotifyWait() only clears the eventA bit so leaves  
the eventB bit set.

If that does not explain the behaviour you are seeing, or you still have  
a problem, then please reply with the actual code so I can see the  
parameters you are passing and try to replicate it.
