xEventGroupWaitBits unexpected behavior

dark1st wrote on Wednesday, February 07, 2018:

Hello,

I found the following behavior of xEventGroupWaitBits function.

I have 2 tasks.

in the 1st task I do smth like:

xEventGroupWaitBits(handle, bits, …, portMAX_DELAY)

in the 2nd task I do smth like:

vTaskSuspend(handle_task1);
activity();
vTaskResume(handle_task1);

in the task1 the function xEventGroupWaitBits exits immediately right after vtaskResume even if no bits were set.

Is this a correct behavior?


Best regards, Alexey

rtel wrote on Wednesday, February 07, 2018:

That is expected - unlike in the queue receive functions, which have an
outer loop to keep re-testing, there is nothing in the
xEventGroupWaitBits() function that will re-test the block condition
when the task blocked task leaves the blocked state.

dark1st wrote on Thursday, February 08, 2018:

.

dark1st wrote on Thursday, February 08, 2018:

Is it possible to get any kind of notification about “unexpected exit from xEventGroupWaitBits” in case of a task resume?

rtel wrote on Thursday, February 08, 2018:

If the task that is waiting for event bits is also being suspended and
resumed then you could check the time before calling
xEventGroupWaitBits(), and then if the function returns without any bits
being set, check the time again to know if the function returned because
of a timeout. If the requested block time has not expired, and no bits
are set, then you could assume the function returned because the task
got suspended and then resumed again.