Broadcast event to multiple tasks

I am trying to set a event from a task(Z). There are three task(A, B, C) waiting for the same event. In case the priority of the task(Z) whcih sets the event is lower than the tasks(A, B, C) waiting for the event the events for fine and all the task gets unblocked. But in case the priority of all the tasks(Task(Z) setting the event and Tasks(A, B, C) waiting for the event) is same, then only one Task(A) gets unblocked and remaining Tasks(B, C) remain in blocked state. Why is it? To simplyfy i created only four tasks(Z, A, B, C) and one event group and start the scheduler. The task(Z) that sets the event does not perform any other functionality other than setting the events. And the tasks(A, B, C) waiting for the event also does not perform any functionality other than waiting for the event. Anyone knows the reason?

Broadcast event to multiple tasks

How do you determine that the tasks do not get unblocked. What is configUSETIMESLICING set to in FreeRTOSConfig.h – wondering if the implementation is just not allowing the other tasks to execute.

Broadcast event to multiple tasks

Hi Richard, The configUSETIMESLICING is set to 1. I have gpios which in toggle in every task. My task implementation is as below: – static void SetTask(void *pvParameters) { EventBits_t SetBit; uint8_t Gpio = *((uint8_t *)pvParameters);
for(; ; )
{
    SetGpio(Gpio);
    SetBit = xEventGroupSetBits(SetWaitEvt, 1);
    ClearGpio(Gpio);
}
} static void WaitTask1(void *pvParameters) { EventBits_t WaitBit1; uint8_t Gpio = *((uint8_t *)pvParameters);
for(; ; )
{
    SetGpio(Gpio);
    WaitBit1 = xEventGroupWaitBits(SetWaitEvt, 1, pdTRUE, pdTRUE, portMAX_DELAY);
    ClearGpio(Gpio);
}
} static void WaitTask2(void *pvParameters) { EventBits_t WaitBit2; uint8_t Gpio = *((uint8_t *)pvParameters);
for(; ; )
{
    SetGpio(Gpio);
    WaitBit2 = xEventGroupWaitBits(SetWaitEvt, 1, pdTRUE, pdTRUE, portMAX_DELAY);
    ClearGpio(Gpio);
}
} static void WaitTask3(void *pvParameters) { EventBits_t WaitBit3; uint8_t Gpio = *((uint8_t *)pvParameters);
for(; ; )
{
    SetGpio(Gpio);
    WaitBit3 = xEventGroupWaitBits(SetWaitEvt, 1, pdTRUE, pdTRUE, portMAX_DELAY);
    ClearGpio(Gpio);
}
}

Broadcast event to multiple tasks

At a quick look at your tasks, SetTask never blocks for anything, and thus totally starves any lower priority tasks and tasks of the same priority only get time based on the round robin scheduling, which isn’t designed to be perfect. Try adding a vTaskDelay call in SetTask to limit how fast it runs.

Broadcast event to multiple tasks

Hi Richard, I tried with vTaskDelay as well, but the result is same.

Broadcast event to multiple tasks

About all I can say is that for me, a single xEventGroupSetBits call will put all the tasks currently pending on a matching xEventGroupWaitBits call back to the ready state, and as long as I give them a chance to get CPU time will run.