The situations of giving control of the CPU to the tasks

I guess if the system has two tasks of equal priority and they are ready to run at the same time, The scheduler gives control of the CPU to both tasks equally.

Assume when the first task is given the highest priority and the second task is given the lowest priority. The scheduler will always run the highest priority task and will never give control of the CPU to the lowest priority tasks.

Besides giving equal priority, what are the situations where the scheduler can give control of the CPU to the task with the lowest priority?

As you said, never if 2 or more tasks are ready always the task with the highest priority runs.
The other, lower priority only task gets scheduled, if the higher priority task blocks on something (semaphore, queue, notification, etc) or issues a delay. Which means it’s not longer ready (to run) until it’s woken up again or the delay or timeout expires.
This is well documented here RTOS fundamentals.

1 Like

Got it, When the current task doesn’t require CPU only then we can assign CPU to another tasks. The other task has to wait because the task which is being executed is the highest priority task

Will calling vTaskDelay cause the task1 to sleep (blocked from getting any CPU) for the number of FreeRTOS ticks specified.

I would recommend reading the API documentation for that function, and the free to download book - rather than have the information duplicated here.