1
00:00:00,650 --> 00:00:01,680
Hello, welcome back.

2
00:00:01,700 --> 00:00:09,260
In this lesson, we sure described the threat a bit more, so we we said the threat, we can think of

3
00:00:09,260 --> 00:00:12,710
the threat as a task executing.

4
00:00:13,650 --> 00:00:21,240
So a threat needs a stock, as we described, that we need to save the execution states of the threat

5
00:00:21,510 --> 00:00:26,400
before we move on to the next threat, otherwise, when we get back to it, we wouldn't know where we

6
00:00:26,400 --> 00:00:28,240
left off in order to continue.

7
00:00:28,710 --> 00:00:33,120
So a threat needs a stock in a stock is just it's just an area of memory.

8
00:00:33,300 --> 00:00:35,460
You just click an and you have a stock.

9
00:00:35,790 --> 00:00:40,920
So a stake requires an array to store its execution states.

10
00:00:42,230 --> 00:00:42,680
Thread.

11
00:00:43,610 --> 00:00:51,200
A threat also requires a program, and we often call this the task function, so is basically a block

12
00:00:51,200 --> 00:00:54,170
of code that you've written in a function.

13
00:00:54,170 --> 00:01:00,170
And we and you see this is the task function, meaning this is what I want this thread to execute.

14
00:01:00,560 --> 00:01:02,450
So over here we call into a program.

15
00:01:02,720 --> 00:01:04,460
A threat requires a stack.

16
00:01:04,550 --> 00:01:09,840
It requires a program also known as the task function or the threat function.

17
00:01:10,520 --> 00:01:15,300
So like I said, this program is just like a main function with an infinite loop.

18
00:01:15,300 --> 00:01:16,140
And while one loop.

19
00:01:16,760 --> 00:01:23,330
So when we are creating our own Real-Time operating system, we would have to declare the stock for

20
00:01:23,330 --> 00:01:30,140
a thread and then the function for that threat or the task function or the program you can use whichever

21
00:01:30,140 --> 00:01:30,830
way you want.

22
00:01:32,130 --> 00:01:32,500
Right.

23
00:01:32,780 --> 00:01:37,640
And then once we've done this, our our Toscano would deal with the rest.

24
00:01:37,760 --> 00:01:43,790
It would take the stack and the task function and appropriately use them to give us what we want.

25
00:01:44,210 --> 00:01:46,490
OK, so over here we are showing the registers.

26
00:01:46,970 --> 00:01:50,060
The threat does not on its own registers this.

27
00:01:50,540 --> 00:01:56,660
The image of the registers here is as the image of our cortex and register bank.

28
00:01:57,050 --> 00:02:04,130
There is just one register bank in the microcontroller and all the threats have to share this one register

29
00:02:04,130 --> 00:02:04,450
bank.

30
00:02:04,790 --> 00:02:11,480
That is why we always have to collect the the execution state of the currently executing threat from

31
00:02:11,480 --> 00:02:16,640
the register bank and save it onto the stock so that when it gets back to that turn of this threat,

32
00:02:16,880 --> 00:02:20,420
we put it back into the registers and continue where we left off.

33
00:02:21,460 --> 00:02:30,100
Right, so let's see, so if we have multiple threads, this is what we'll end up with, end up with

34
00:02:30,100 --> 00:02:33,430
this image here, over here we're showing having four threads.

35
00:02:34,390 --> 00:02:36,820
So thread one here, it's.

36
00:02:37,900 --> 00:02:44,350
It's Thack and then it's program, which is the thread function or the task function thread to has its

37
00:02:44,350 --> 00:02:50,800
stock and its program thread three has its stock and its program through it for us, its stock and its

38
00:02:50,800 --> 00:02:51,280
program.

39
00:02:51,490 --> 00:02:54,840
And the registers we show here is the same registers.

40
00:02:54,860 --> 00:02:56,650
These this image.

41
00:02:56,650 --> 00:02:57,690
I shouldn't confuse you.

42
00:02:57,700 --> 00:03:00,660
It doesn't mean they all have the registers over here.

43
00:03:00,670 --> 00:03:02,350
We are trying to describe that.

44
00:03:03,040 --> 00:03:10,270
Each of them just collect each of them, save what is in the registers into the stack and then.

45
00:03:11,200 --> 00:03:12,370
Over here, the program.

46
00:03:13,520 --> 00:03:19,040
The address of the program is placed in the PC business known as the program Counter Register, it decides

47
00:03:19,040 --> 00:03:20,870
the next instruction to be executed.

48
00:03:20,900 --> 00:03:24,200
That is why we have the arrow from here pointing out our program.

49
00:03:24,530 --> 00:03:24,930
Right.

50
00:03:25,160 --> 00:03:32,970
So in any case, each thread requires its stack and its its its program or its task function.

51
00:03:33,500 --> 00:03:39,940
Of course, the other parameters that needs to be decided based on the scheduling policy is being designed.

52
00:03:40,190 --> 00:03:43,010
We may have to include the priority of the thread.

53
00:03:43,250 --> 00:03:45,350
We may have to include other things.

54
00:03:45,740 --> 00:03:52,040
But typically you need a stack and then you need the program that a threat has to execute, which we

55
00:03:52,040 --> 00:03:53,600
call the task function.

56
00:03:54,050 --> 00:03:57,500
So this order is for this lesson and then I'll show you the next lesson.

57
00:03:57,530 --> 00:03:58,190
Have a nice day.
