0
votes

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
2
Why is this tagged with C and C++? Why with AWS? What exactly do you mean with "task"? There is a lot of context missing from your question. Please, as a new user here, take the tour and read How to Ask. - Ulrich Eckhardt

2 Answers

0
votes

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.

0
votes

You need to use a mutex (mutually exclusive) semaphore.

Here is an example protecting the Serial Port of an ATmega Arduino Clone. This ensures that messages presented to the serial port by multiple tasks are not interleaved (corrupted).

You can see that the semaphore is taken before attempting to write to the serial port, and then given (freed) when the task has completed its activities.