How to Synchronize Multiple tasks

mukeshtalks wrote on Tuesday, June 14, 2016:


I am working on FreeRtos Version 7.6. My application is Solar inverter based on STM32f3 CortexM4f3 Controller. Kernel tick is 1ms.
I have created 4 tasks:

  1. Task for Battery Charging Using Solar
  2. Task for Inverter Control
  3. Task for HMI(LCD and Keypad)
  4. Task for Serial Communication. Wait for Que to receive data from USART interrupt.

Here i have kept the Task1, 2 and 4 at lowest priority (2), and Task 3 is at highest Priority(3) but there is a task delay of 4 Seconds so that other task get chance to run.
Now i am facing the issue the task are not synchronised and not working properly. I need to Synchnorize them. I need help in uderstanding the the different and best option for synchronizing the task.


davedoors wrote on Tuesday, June 14, 2016:


mukeshtalks wrote on Tuesday, June 14, 2016:

Thanks Dave, Can i use other methods like Binary semaphores, Mutex Etc.

rtel wrote on Tuesday, June 14, 2016:

I don’t think the description of your problem is detailed enough to say, nor do you say why you would favour another method over xEventGroupSync().

xEventGroupSync() is designed specifically to synchronise more than two tasks at once. If you only want to synchronise two tasks at any time then you could use any of the communication mechanisms.

mukeshtalks wrote on Tuesday, June 14, 2016:

Hi, Thnaks for your quic reply. Actually My application is using FreeRTOS Ver 7.6, Which i dont want to change to latest version at this movement because project is almost at end state and dont know the side effects of upgrading the RTOS version and don’t have time as well. In this version xEventGroupSync() is not there if i am not wrong. I thing by syncronizing two of my major task Task 1 and task 2 (As mentioned Above) i feel My major problems can be solved but I need to try.

My Problem is both tasks 1 & 2 are running at the same priroity at kernel tick (1ms). But sometime both are executing at every 1ms and some time One of the task take more time to execute. Because of this My close lopp written in both the tasks are not working. I also share the structure b/w both task using mutex to avoid memory corruption.

Can you please suggest the simplest way to overcome this situation.