Free RTOS - Multiple task

sharmil wrote on Wednesday, December 19, 2018:

Hi,
I am using Free RTOs in our custom project. I need to create multiple threads in my free rtos project. I have created 4 task with idle priority and I am not able to run all the task simultaneously. When one thread is running and waiting for something (blocking condition) another thread will start executing and which will not allow first thread to run .
Please provide the solution for the same.
Regards,
Sharmila

richarddamon wrote on Wednesday, December 19, 2018:

First, on the sort of processor that FreeRTOS runs, you never have multiple tasks running ‘Simultaneously’, as you only have a single processor executing just one thread at a time, But instead what normally happens is that the processor will execute one task for a while, then switch to the next, and so on.

FreeRTOS will always be running the Highest Priority Ready Task at any given moment. If Pre-emption and Time Slicing are enabled then tasks of the same priority will be run in sequence switching on each timer tick.

If you have multiple tasks at the same (Idle) priority, and you are not getting this sort of behavion, then likely you have disabled Preemption, disabled Time-Slicing, or somehow don’t have a timer tick happening.

The solution is too fix the above problem, or if the tasks aren’t designed to be able to handle pre-emption (they aren’t using proper critical section for shared data access), then you can get much of the same effet by having all the tasks that might run for a long period of time to periodically Yield to let another task that might be ready have a turn at running. This is basically required if Pre-emption or Time-Slicing is turned off and tasks don’t regularly block,