Hello, welcome back.
In this lesson, we sure described the threat a bit more, so we we said the threat, we can think of
the threat as a task executing.
So a threat needs a stock, as we described, that we need to save the execution states of the threat
before we move on to the next threat, otherwise, when we get back to it, we wouldn't know where we
left off in order to continue.
So a threat needs a stock in a stock is just it's just an area of memory.
You just click an and you have a stock.
So a stake requires an array to store its execution states.
Thread.
A threat also requires a program, and we often call this the task function, so is basically a block
of code that you've written in a function.
And we and you see this is the task function, meaning this is what I want this thread to execute.
So over here we call into a program.
A threat requires a stack.
It requires a program also known as the task function or the threat function.
So like I said, this program is just like a main function with an infinite loop.
And while one loop.
So when we are creating our own Real-Time operating system, we would have to declare the stock for
a thread and then the function for that threat or the task function or the program you can use whichever
way you want.
Right.
And then once we've done this, our our Toscano would deal with the rest.
It would take the stack and the task function and appropriately use them to give us what we want.
OK, so over here we are showing the registers.
The threat does not on its own registers this.
The image of the registers here is as the image of our cortex and register bank.
There is just one register bank in the microcontroller and all the threats have to share this one register
bank.
That is why we always have to collect the the execution state of the currently executing threat from
the register bank and save it onto the stock so that when it gets back to that turn of this threat,
we put it back into the registers and continue where we left off.
Right, so let's see, so if we have multiple threads, this is what we'll end up with, end up with
this image here, over here we're showing having four threads.
So thread one here, it's.
It's Thack and then it's program, which is the thread function or the task function thread to has its
stock and its program thread three has its stock and its program through it for us, its stock and its
program.
And the registers we show here is the same registers.
These this image.
I shouldn't confuse you.
It doesn't mean they all have the registers over here.
We are trying to describe that.
Each of them just collect each of them, save what is in the registers into the stack and then.
Over here, the program.
The address of the program is placed in the PC business known as the program Counter Register, it decides
the next instruction to be executed.
That is why we have the arrow from here pointing out our program.
Right.
So in any case, each thread requires its stack and its its its program or its task function.
Of course, the other parameters that needs to be decided based on the scheduling policy is being designed.
We may have to include the priority of the thread.
We may have to include other things.
But typically you need a stack and then you need the program that a threat has to execute, which we
call the task function.
So this order is for this lesson and then I'll show you the next lesson.
Have a nice day.