Search code examples
freertos

How to sync tasks using FreeRTOS library?


I have 5 tasks(function) in 5 different which are running simultaneously. I want to implement like any function start running then other function should not run until the function completes its process. I want to implement using FreeRTOS. Example.

  • foo1.c ->Task1
  • foo2.c ->Task2
  • foo3.c ->Task3
  • foo4.c ->Task4
  • foo5.c ->Task5

Solution

  • It sounds like you need a mutex. Each task acquires the mutex when they start running, and release it when they are done. When any of the tasks is running, others are blocked on the mutex.