ON THE CONDITION that they were not running in the first place.
No, that's not true, By that logic , Tasks that have a priority of 0 never run,
That's not true.
Sure but if i recall correctly when you setup tasks you do 2 things mostly always
You use xTaskCreatePinnedToCore
2, YOU SET the Priority as 1 (Therefore you re defining it)
Do you mind if it's not too much trouble to post the sketch for that test ?
i'd like to test it myself and examine it
The Scheduler starts upon power up after the main file is loaded, for simplicity sake you can assume that the scheduler loads at startup of board
also , it always has the highest priority
No.. What that is indicating , where it says O/S is O/S LEVEL Tasks
It means that O/S Level tasks that are necessary for housekeeping or knowing what
Task need to be allocated the next slice, get loaded
it doesn't mean it's the operating system that gets executed
it's OPERATING SYSTEM LEVEL TASKS that are getting executed at that level
The loop function is a task with priority 1. The idle task has a priority of 0. These
are separate tasks.
Not neccesarily, as you find out more about intertask communication a task may be waiting
for a notification or data from a queue so it wil be in the blocked state while waiting.
I think the highest priority task in the ready state would run first
Yes
Yes
Yes, except that that the interrupt will not change things unless the interrupt places
task11 into the blocked state somehow allowing task10 to run.
Ok
I don't know what you mean by that. The schedular is running in memory of course and it does
its housekeeping duties as part of the idle task.
Actually you're correct
i think i confused the two because he mentioned it was an empty task
No, but initially , All Tasls start in the Ready State
When a task Is explicitly created, it initially gets put in the READY State
and then it changes state from there based on certain factors and instructions as you said, right ?
I;m going through the docs now, i specifically remember it said that all tasks start in ready state
Execution inside the task loop (inside the for loop ) does not happen because the task is waiting on something to happen. I do not really consider that task being "run" or "running".
Thank you for evaluating my understandings. Now, I have got some clues/basis to begin systematic studies of the FreeRTOS Operating System designed for Embedded Systems.
Don't forget: void task(void* pvParams) { while(true) loop(); }
or void main() { setup(); while(true) loop(); }
so that the task is not empty nor exits.
Most of the real work done by FreeRTOS happens when the application code makes API calls and during the Tick Period ISR. Those are the times it has an opportunity to do context switches, etc.
You can also request a context switch upon return from a user ISR. So if the ISR causes a higher-priority task to become ready (by posting to a queue, sending a notification, etc), then when the ISR exits, control will pass to that new task and not the original one that was interrupt.
Please do not confuse people with such details about process control in code. Most contributions still are about task creation and try to find the woodoo behind the scene. We could rename this topic into "Control ESP32 tasks without using any task control API". <BG>
Thanks anyway for your contribution, I really like it. Unfortunately I'm still waiting for the cables to my ESP but already have two new topics on hold:
Ways to crash ESP32
Using ESP32 task control APIs
Do you think I could place the latter topic into "Programming Questions"?
Right,
from the manual "If a context switch should be performed, then the interrupt safe API function will set *pxHigherPriorityTaskWoken to pdTRUE. "
I had to look at that a few times before I figured out what it was trying to tell me.
Yes, the idle task is where context switching is decided.
Note: In the idf the default tick is 10 milliseconds but can be changed.
In the arduino it is 1 millisecond and I don't think it can be changed. That seems like
a pretty fast tick period to me.
NO. Like I said it will happen when user code calls an API that triggers an event causing a context switch. Or, upon return from an ISR that triggers an event causing a context switch. Or during the Tick ISR.
The Idle Task doesn't run reliably / periodically enough to handle that.
You can do absolutely nothing useful in FreeRTOS without understanding "task control APIs". Seven out of the twelve chapters in "Mastering the FreeRTOS⢠Real Time Kernel" are dedicated to those APIs. If you're not going to understand them, then you can't do inter-task communication and synchronization. In that case, there's no reason to bother with FreeRTOS at all.
Iām still seeing incorrect statements and general confusion in this thread about task priorities and context switching. Hereās concrete example that may clear things up a little (or not?). Try running the code below.
Then see if you can use the algorithm that I provided in a previous post to explain why the printouts happen in the order they do. Then change the relative priorities of the three tasks and see if the printouts happen in the order you thought they would.
Of course, what else could it mean .
but i think when i answered the question i'm pretty sure i confused it with the IDLE task priority. IDLE has a Priority of 0
We could...... LOL
However when we started this topic we had a little discussion as to the name and this is what we came up with .
Had we known the direction it would go in, maybe it'd be a different name but hey...
This actually was the point of what i wanted to do, To deep dive into multi core and multi tasking so......it's fine by me .
Let's just discuss it
also , i'm still working through the document and getting the test project ready
And given my recent issues with the ESP32's that i have i've ordered a few more and am waiting on them to arrive
in any case not as yet because i'm concentrating on going through the RTOS Manual
and getting a few practical things sorted so we can start doing interesting practical stuff
I will at some later point address this though, it's not a priority now,
my answer for now is just based on what the documentation says