I am using FreeRTOS and have multiple tasks in my application of which two tasks are of least priority but needs to be executed initially. Lets name them as Task1, Task2, Task3, Task4.
xTaskCreate(MyTask1, "Task1", 100, NULL, 1, &TaskHandle_1);
xTaskCreate(MyTask2, "Task2", 150, NULL, 1, &TaskHandle_2);
xTaskCreate(MyTask3, "Task3", 256, NULL, 2, &TaskHandle_3);
xTaskCreate(MyTask4, "Task4", 1024, NULL, 3, &TaskHandle_4);
Task1 and Task2 are of lowest priority but they needs to be executed first since Task4 consists of condition which depends on Task1 parameters.
Since Task4 is of highest priority, it starts executing immediately and Task1 is executed after sometime.
Least possible solutions I think are:
- Make Task1 priority highest and then change its priority back to lowest.
- Suspend current task and start Task1 then resume task
How can I make Task1 run before Task4?