I need help with Task Synchronization in FreeRTOS

Hey everyone, :wave:

Pulling my hair out here trying to wrangle some tasks in my FreeRTOS project. These little guys need to play nice together, and that means getting their synchronization on point. The whole semaphores vs mutexes thing is throwing me a curveball. Sure, I get the basic idea, but which one to use when is a mystery. Queues seem like they could be handy for passing messages between tasks, but I’m worried about potential problems lurking in the shadows.

Here’s where I’m hoping the collective wisdom of the embedded world can shine a light:

  • Semaphore or mutex, that is the question? How do you choose the right tool for the job?
  • Anyone else battle the pitfalls of queues? Spilled data, anyone? How’d you fix it?
  • Got any stellar examples of clean task synchronization with FreeRTOS? Share the magic!
  • What are the synchronization booby traps I should watch out for to keep things running smoothly?
  • Real experiences and war stories from the trenches of embedded development are most welcome!
    I check this resource: https://forums.freertos.org/t/need-help-running-a-simple-freertos-task-on-tmruby4c123gh6pm-tiva-c-launchpad/19314 BUT I have not found any solution.

Thanks in advance!

Respected community member :innocent:

I think of semaphores as signals/events to wake up tasks. Mutexes are for MUTual EXclusion, i.e. synchronizing access to shared resources. I wrote a blog on semaphores vs. mutexes some years ago. You find it here: https://percepio.com/rtos-101-semaphores-and-queues/


This request is very strange. Given your previous contribs, for example here:

, you are either already extremly knowledgeable and experienced person (in which case this question does not make sense), somebody in marketing dedicated to petting people’s bellies, or a bot.

I don’t know how others here feel about this, but I do not like the idea of funny games played with me serving as a guinea pig. I like hardcore tech discussions with real human beings of similar background or in real need of technical device, and so far, this forum has been the ideal place for this kind of exchange. If it instead turns into a playground for obnoxious cyber experiments, I will be happy to withdraw.

If, however, I should be totally off and you should indeed be a developer who at the same time gives expert advice AND asks newbie questions, my best advice for you would be to query the forum for this kind of request. This very question has been asked many times before, and in the answers given so far, many links to existing documentation have been provided. Regurgitating this is mostly a waste of internet bandwidth. There is nothing significantly new anyone could contribute here.

I agree with you completely @RAc. This does seem odd given previous post and replies. We try to stay vigilant about this and I’ll continue to monitor this in the coming days.

As for your question…This is very vague. We’d like to help but without a specific problem you’re trying to solve the best guidance we can provide will also be generic.

I’d recommend reading: