Question regarding busy task

Hello.
I want to first apologise for the nativity of this question.
I am starting reading about FreeRTOS and I haven’t yet done any real work. Just some very basic demos.

There is a fundamental question that I haven’t been able to answer yet: do I have to worry about how long my task runs without explicitly wait for for a delay, mutex or other events that make the task release the cpu and block?
From the tutoriaIs i have watched I understand that the scheduler will take care to execute the tasks with the highest priority, in turn. And this makes sense to me

And then I see another video where it is explained that a task that was hogging the cpu without yelding causes the wdt to reset the chip because the wdt monitoring task didn’t have the chance to run. And now I am confused.
I would have expected the scheduler to round robin the higher priority tasks, giving them an equal slice of time.

Do you have advice on what I could read to clarify better this confusion that I have?

Thank you very much

It will Round Robin EQUAL priority tasks. (If round robin scheduling, and preemption are enabled).

A priority 5 task will totally block a priority 4 task unless it blocks.

A WatchDog task tends to be somewhat low in priority, above non-critical tasks, but low enough that if a critical task hangs, the watchdog will get tripped.

Hi @ccesaretto,

No need to apologize - this forum is a place for people of all levels of knowledge :slight_smile:. @richard-damon is 100% correct. To elaborate a bit, if there is a priority 6 task that is always in a ready or running state (not blocked), running with a priority 5 task, the priority 5 task will never run because the scheduler sees that the priority 6 task is still ready to execute and will continue to schedule it. In order for the priority 5 task to run, the priority 6 task needs to enter a blocked or suspended state - there are a number of ways this can happen (task blocks on receiving or sending to a queue, task suspends itself by calling vTaskDelay, etc).

I would recommend reading this FreeRTOS single-core AMP and SMP RTOS task scheduling - FreeRTOS. Feel free to ask any questions you still have or let me know if anything is confusing.

Best,

Jason Carroll

1 Like