This thread has been locked.

If you have a related question, please click the "Ask a related question" button in the top right corner. The newly created question will be automatically linked to this question.

Using Task_yield() for task scheduling

Hi,

Suppose I have a high priority task - taskA() and three equal lower  priority tasks -task1(),task2() and task3(). Each is coded as :

while(1)

{

   ...do_something();

Task_yield();

}

Am I correct in assuming that these will run as below:

taskA,task1,taskA,task2,taskA,task3 .... and so on? Also once a task yields does the next task run immediately or is synchronized to some internal

clock of RTOS?

Regards

  • Hi Nikhil,

    Task_yield() only yields the processor if another task of the same priority is ready. If I understand your example correctly then, TaskA will always run and never yield as it is the highest priority ready task. Assuming TaskA blocks on a semaphore or some other event, Task1, Task2 and Task3 will execute in a round-robin fashion.

    Coming to your second question. When Task_yield() is called, the currently running task will immediately yield the processor to the next same priority ready task.

    Please see Task_yield() cdoc for more info on this API.

    Best,

    Ashish