Suspend/Resume or Event groups? Best practise

I started to studying freeRTOS recently, and now I’m working in my first project. And I have a doubt about design, thinking about performace and solve memory, what is the best practise?

My application has a simple state machine, each state is a Task. I started the development implement binary semaphores, then, the tasks was waiting forever to take its semaphore, then execute. But with a lot of tasks, I was think about to change this N semaphores per One Event group.

My question is, is this the best process? Or should use a Suspend/Resume mechanism to coordinate this process.

First, a Task per State is not the best practice. In general, any multi-task design where one task releases another then waits till that task finished then starts back up is often a sub-optimal design. Tasks are to allow operations to proceed in PARALLEL, so if you can’t have parallel operation, tasks may. not be the answer.

Put the whole state machine in a single task.

If you were going to do this multi-task method, I would use the Direct-to-Task notifications.

Do NOT use “Suspend/Resume”, as that will have an essential race condition in the design.

1 Like