EventGroup bit clearing when multiple tasks wait for bit

nameofuser1 wrote on Wednesday, December 26, 2018:

I am not sure how to clear event bits if several tasks are waiting for the same bits.

Let us concider three tasks waiting for the same bit. Let their names be TASK_1, TASK_2 and TASK_3.
Suppose that TASK_1 and TASK_2 have priority of 1 and TASK_3 has priority of 2.

Imagine that bit of interest is set by task 4. Here comes my questions:

  1. At first TASK_3 will wake up since it has the highest priority. If bit is cleared inside TASK_3 will TASK_1 and TASK_2 still be executed?
  2. What if instead of clearing bit inside TASK_3 it is done in one of lower priority tasks i.e. TASK_1 and TASK_2. Does it ensure that all the tasks will wake up?

Another case:

  1. What if TASK_3 sets bit of interest and clear it right after setting. Will TASK_1 and TASK_2 be unblocked in this case?

Thanks!

rtel wrote on Wednesday, December 26, 2018:

If you have multiple tasks waiting on the same bit then ALL the tasks
will wake if the bit is set, not just the highest priority task. The
priority only makes a different to which task runs first. Therefore the
bits can be cleared inside the API function itself (the parameters to
the functions way which bits to clear and when). Anything else would
result in unworkable race conditions (which some OSes just push back to
the application writer to try and sort out).