Wake up multiple tasks with single IO event

Hello everyone,

I recently found out about FreeRTOS and been doing some experiments with it. I’m looking to make a “button” driver utilizing user buttons on the board I have.

Here’s the behavior I’m looking to implement:

  • allow multiple tasks to block and wait for a button “event” to occur.
  • once the button is pressed all tasks that were awaiting for the button press would be unblocked
  • If a button event happens and afterwards a task queries the button driver for an event, the task would block and await a future button event. Button events only apply for tasks already waiting for the event.

I’ve been looking into how to do it and I think using an event group is the way to go, but I just wanted to ask since I’m new to FreeRTOS.


  1. Is an event group the best way to go in order to implement the behavior I’m looking for?
    I’m looking to make this driver as simple and as lightweight as possible (it’s a silly little driver), so I’m looking to spend as little time as possible in kernel-space & avoid creating driver tasks/daemons.

  2. My understanding is I don’t need to specify how many tasks are waiting for the same event group, is that correct?
    Ideally that’s what I want. I’m making a driver so I’d like my code to work with N tasks, although it’s not the end of the world if not.

Yes, An EventGroup is the way to handle multiple things waiting for a single ‘event’ to happen. When the event is posted to the group, EVERY task that was waiting in a way that the event is satisfied gets woken.

Thank you for clarifying Richard! I was 90% sure for that. My confusion mainly came from finding out about task notifications since the docs say it’s a lot more efficient to use, but it seems that it one can only notify a single task.

The Direct-to-Task notification system IS more efficient, largely because it only needs to handle waking up a single task, so it can be optimized for that. This removes a lot of resource contention.

If most of your events will only ever wake up a single task, and only occasionally do you need to wake up multiple tasks (but with a small upper limit for how many might be needed) you could replace the Event Group with a loop to signal each of the tasks with the direct-to-task system. I suspect that unless you are on the edge of your performance envelope, it won’t be worth the complexity.