1
00:00:00,910 --> 00:00:01,970
Hello, welcome back.

2
00:00:02,530 --> 00:00:08,140
In this lesson, we are going to see how to create a thread or a task.

3
00:00:09,020 --> 00:00:15,380
Using the crisis Arktos apps, so I'm going to make a copy of our very first project so that this would

4
00:00:15,380 --> 00:00:20,530
be us if we started from scratch, I'm not going to use any of the intermediate projects we created.

5
00:00:20,540 --> 00:00:24,020
I'm going to go to project one task creation over here.

6
00:00:25,690 --> 00:00:30,340
I'll make a copy of this and then I'll pass it over here.

7
00:00:32,380 --> 00:00:33,790
And then I'll call this.

8
00:00:35,670 --> 00:00:45,120
No, we are at number 35, I call this 35 on the school, see Mrs. Artus.

9
00:00:48,580 --> 00:00:56,560
And then I call this thread, remember, I said a thread, the word thread and task can be used interchangeably.

10
00:00:57,490 --> 00:01:02,980
Is because the crisis artist uses the word threat, that is why I'm calling this threat rather than

11
00:01:02,980 --> 00:01:10,080
Tosk, so I'm going to open the may not see fall over here, double click over here and I'm going to

12
00:01:10,270 --> 00:01:11,730
let's see what we have here.

13
00:01:12,520 --> 00:01:17,770
I'm going to clean everything that has to do with quote from here.

14
00:01:20,130 --> 00:01:21,060
Oddly, this.

15
00:01:23,010 --> 00:01:25,050
This is the task functions.

16
00:01:26,510 --> 00:01:30,110
Because we made a copy of our free artist's version.

17
00:01:30,630 --> 00:01:33,950
OK, and I'll clean this.

18
00:01:37,870 --> 00:01:41,950
And I'll clean what we have over here.

19
00:01:43,070 --> 00:01:46,260
OK, we just clean all of this so that we start from scratch together.

20
00:01:46,640 --> 00:01:51,640
So over here, this one here, we did this, remember, we wrote a new function for our You are right.

21
00:01:52,250 --> 00:01:53,720
This is the very first project.

22
00:01:53,730 --> 00:01:58,070
So we had integrated our you at the see, and you are totally false.

23
00:01:58,700 --> 00:02:03,530
OK, so in this project, let's see.

24
00:02:05,710 --> 00:02:09,140
I will just enable this and disable this.

25
00:02:09,580 --> 00:02:13,470
I hope you remember this because we wanted to work with you.

26
00:02:13,510 --> 00:02:15,290
I wanted it to be faster.

27
00:02:15,820 --> 00:02:22,060
What we did was we wrote this new function so that we wouldn't use the how you ought to transmit function.

28
00:02:22,370 --> 00:02:26,640
OK, if you check the project, you would find that.

29
00:02:26,950 --> 00:02:29,950
OK, so this is our you are right.

30
00:02:29,950 --> 00:02:33,610
And then this one allows us to use printf and.

31
00:02:36,300 --> 00:02:38,890
Our Ewart's code is still in here.

32
00:02:39,150 --> 00:02:44,240
OK, so this the project one, I hope you're not confused by that.

33
00:02:44,690 --> 00:02:49,080
OK, so what are we going to do to use Simms's ARTUS?

34
00:02:49,080 --> 00:02:53,520
We have to go and find the documentation for Simms's Artus.

35
00:02:54,570 --> 00:03:03,450
So we said Simms's Artus, the the function for creating a threat takes takes a structure as argument

36
00:03:03,720 --> 00:03:10,260
we need to describe or the threat argument in a structure, and then we pass that structure as argument.

37
00:03:11,250 --> 00:03:17,460
We need to describe all the threat attributes, the parameters and characteristics of the threat.

38
00:03:17,730 --> 00:03:25,080
We need to define them in a structure imposter's structure as arguments to the threat create function.

39
00:03:25,090 --> 00:03:27,270
So I'll come to Google over here and type.

40
00:03:30,770 --> 00:03:40,160
Simms's Artus to over here and hit enter and I'll click this first link if you take me to the documentation.

41
00:03:43,470 --> 00:03:44,530
OK, here we are.

42
00:03:45,540 --> 00:03:52,620
So Simms's Artus to documentation, I can click over here, you can click here to see the function of

43
00:03:52,620 --> 00:03:53,070
abuse.

44
00:03:53,100 --> 00:03:56,220
This is the NASA APIs feature.

45
00:03:56,280 --> 00:04:02,880
We can drop down over here and then we can click function description and it gives us a list of all

46
00:04:02,880 --> 00:04:03,600
the functions.

47
00:04:04,750 --> 00:04:11,080
OK, so this over here can be a quick way of knowing the functions you might require.

48
00:04:11,470 --> 00:04:18,430
So over here, if you want to check thread management, there is a function to detach the thread.

49
00:04:19,130 --> 00:04:20,830
There's a function to get a thread ID.

50
00:04:20,830 --> 00:04:22,810
What we want to do is create a new thread.

51
00:04:22,810 --> 00:04:23,860
So that's a function here.

52
00:04:23,860 --> 00:04:27,360
Always threaten you, create a thread and add it to active threads.

53
00:04:27,520 --> 00:04:30,190
So let's click on this, threaten you and see what we have.

54
00:04:31,000 --> 00:04:31,520
OK.

55
00:04:31,540 --> 00:04:32,530
And as you can see.

56
00:04:34,070 --> 00:04:39,980
Dysfunction takes three arguments, the first argument is the threat function is what we used to call

57
00:04:39,980 --> 00:04:41,000
the task function.

58
00:04:41,360 --> 00:04:43,010
It is called threat function here.

59
00:04:43,280 --> 00:04:53,400
The second argument is it's a pointer to an argument or a parameter you can pass to the Detroit function.

60
00:04:53,420 --> 00:04:58,180
Remember, we can pass parameters to our created threat.

61
00:04:58,640 --> 00:05:01,150
So this argument is for that parameter.

62
00:05:01,430 --> 00:05:07,790
And this over here, the third argument is a pointer to a structure that you pass and this structure

63
00:05:07,790 --> 00:05:14,630
here inside this structure, you you would define the stack size of the threat, the the priority of

64
00:05:14,630 --> 00:05:18,020
the threat and other attributes that you want the threat to have.

65
00:05:19,490 --> 00:05:23,970
OK, when we come over here in this document, it tells us about the priority levels as well.

66
00:05:24,290 --> 00:05:27,680
Over here, it's created a special names for the priority.

67
00:05:27,680 --> 00:05:29,480
So there is priority normal.

68
00:05:31,480 --> 00:05:37,570
There is a priority below normal, normal, one mean normal priority plus one normal to normal, three

69
00:05:37,570 --> 00:05:44,800
normal for so many priorities, essentially, that it's given all of them symbolic names so that we

70
00:05:44,800 --> 00:05:46,930
need not use numbers.

71
00:05:47,440 --> 00:05:48,910
OK, so.

72
00:05:49,820 --> 00:05:50,730
Where is our function?

73
00:05:50,750 --> 00:05:56,210
This is it, if we screw up, it will tell us the argument for this function.

74
00:05:58,840 --> 00:06:00,970
Let's see, I grew up.

75
00:06:02,550 --> 00:06:03,150
Over here.

76
00:06:03,180 --> 00:06:10,350
OK, this table here describes the threat attributes to the structure that we pass to the threat, you

77
00:06:10,350 --> 00:06:12,240
can have these attributes.

78
00:06:13,110 --> 00:06:16,280
You can they can be a field for the name of the threat.

79
00:06:16,290 --> 00:06:17,010
Another one.

80
00:06:18,470 --> 00:06:24,300
This one is called Let's See, What does it say, attributes, unaskable bit the following bits mask

81
00:06:24,350 --> 00:06:28,410
can be used to set options through a detached or trainable.

82
00:06:28,430 --> 00:06:29,520
These are other options.

83
00:06:29,750 --> 00:06:32,850
So basically, there are so many options, we're not going to use all of them.

84
00:06:32,850 --> 00:06:36,770
Are we going to use the thread name, the stack size and the priority?

85
00:06:37,100 --> 00:06:41,510
OK, so now if all of that sounds blurry, let's just go to our project.

86
00:06:41,540 --> 00:06:42,500
This a fresh project.

87
00:06:42,500 --> 00:06:43,550
We don't need you out yet.

88
00:06:43,550 --> 00:06:44,380
You can delete it.

89
00:06:44,750 --> 00:06:48,560
But in any case, there's just a fresh project we go into.

90
00:06:49,720 --> 00:06:50,530
Starts by.

91
00:06:52,810 --> 00:06:59,740
Creating our task profile is we need profiles so that we can be able to see what our threat or task

92
00:06:59,740 --> 00:07:00,530
is working or not.

93
00:07:01,090 --> 00:07:02,810
So I'll bring the profile this year.

94
00:07:02,830 --> 00:07:08,000
We start with typedef great orange task profiler, red, green and blue.

95
00:07:08,440 --> 00:07:13,110
OK, I'm going to define the stock size over here.

96
00:07:13,120 --> 00:07:15,790
I'll see stock size five one two.

97
00:07:16,450 --> 00:07:19,840
OK, once that is done, I'm going to come over here.

98
00:07:20,380 --> 00:07:21,940
I'm going to declare.

99
00:07:24,310 --> 00:07:33,550
The structure for our threat, so coming to my main function over here and then I'll see this thread

100
00:07:34,660 --> 00:07:38,530
a TTR underscore t right.

101
00:07:39,880 --> 00:07:41,040
And then I'll give it a name.

102
00:07:41,050 --> 00:07:43,150
I call this green threat attributes.

103
00:07:51,050 --> 00:07:54,620
I can use an abbreviation of trips like this.

104
00:07:55,820 --> 00:07:57,710
OK, so this is a structure.

105
00:08:02,880 --> 00:08:05,460
And then I guess the addenda members.

106
00:08:06,680 --> 00:08:14,030
We use the dot operator, so I'll see DOT over here and you see it gives me all the members of the structure.

107
00:08:15,020 --> 00:08:20,450
I can select name, priority, stuck, memory, stock size, et cetera, what we want to start with

108
00:08:20,450 --> 00:08:21,100
is the name.

109
00:08:21,110 --> 00:08:27,050
So I'll say that name over here and I'll simply call this green task.

110
00:08:29,960 --> 00:08:30,530
And then.

111
00:08:34,670 --> 00:08:43,640
I see a dot over here stack size, and then I just assigned a stock size with a sign at the top over

112
00:08:43,640 --> 00:08:43,970
here.

113
00:08:50,420 --> 00:08:57,470
And then once that's done, I said dot or assign a priority level over here, I'll just give it a priority

114
00:08:57,470 --> 00:08:58,990
of normal or C.

115
00:08:59,570 --> 00:08:59,900
O.

116
00:08:59,920 --> 00:09:01,070
S priority.

117
00:09:04,530 --> 00:09:05,640
Almost like this.

118
00:09:06,160 --> 00:09:11,090
OK, so this is it, this is the green thread attributes.

119
00:09:11,430 --> 00:09:17,580
So then once we are done, we use the the function we saw is called the always threaten you.

120
00:09:18,030 --> 00:09:20,100
This function is what creates a new threat.

121
00:09:21,620 --> 00:09:22,610
Who is threatening you?

122
00:09:23,060 --> 00:09:33,020
OK, so we would say over here, who is threat knew and we passed the first argument.

123
00:09:33,350 --> 00:09:35,660
The first argument has to be a threat function.

124
00:09:35,990 --> 00:09:38,840
So we're going to have a threat function.

125
00:09:39,200 --> 00:09:45,680
We shall call this threat the threat function, which we used to call the task function, because taskin

126
00:09:45,680 --> 00:09:48,000
threat we use in the in the same context.

127
00:09:48,500 --> 00:09:56,330
So this is going to be a green task function and then we don't have any arguments or parameters to pass

128
00:09:56,330 --> 00:09:57,230
to this threat.

129
00:09:57,230 --> 00:10:02,780
So we pass all over here and then the attributes we need to add the attribute here.

130
00:10:05,530 --> 00:10:10,090
Like this, so then this will create our green threat for us.

131
00:10:12,090 --> 00:10:23,760
OK, so then we're going to repeat this, we can repeat this for, let's see, Red and the others.

132
00:10:23,760 --> 00:10:24,600
So I copy this.

133
00:10:28,170 --> 00:10:35,670
And this time, I'll call the attributes red threat attributes such that I'll change to red as well

134
00:10:36,330 --> 00:10:36,960
over here.

135
00:10:36,990 --> 00:10:41,370
I misspelled the word task, so the name of the thread.

136
00:10:43,870 --> 00:10:48,620
This one becomes red, although the priority be the same.

137
00:10:49,900 --> 00:10:51,070
And over here.

138
00:10:51,910 --> 00:10:59,260
So we have to pass this attributes as the third argument, and we're going to create a task function

139
00:10:59,260 --> 00:11:02,800
called Red Early Controller Task.

140
00:11:03,610 --> 00:11:06,640
OK, so once that is done, we can.

141
00:11:08,690 --> 00:11:11,310
Do one for orange and blue.

142
00:11:13,340 --> 00:11:21,740
So how about you post the video and you try to create four orange and blue because we have we have four

143
00:11:21,740 --> 00:11:28,010
profiler's here and we've created two threats to do one for orange and then blue and then on post the

144
00:11:28,010 --> 00:11:28,370
video.

145
00:11:29,460 --> 00:11:36,090
Right, it's as simple as what we've done is simple, we simply defined a structure.

146
00:11:39,680 --> 00:11:41,120
Over here, we give it a name.

147
00:11:42,320 --> 00:11:48,610
I'm going to call this orange task, I'll keep the priority the same.

148
00:11:49,160 --> 00:11:52,450
The task function is going to be orange, the controller.

149
00:11:53,630 --> 00:11:59,450
And then over here, we're going to change the name of the attributes to Orange.

150
00:12:00,390 --> 00:12:07,080
And we're going to pass this as the documents to the function and then we're going to do one for blue.

151
00:12:09,110 --> 00:12:18,310
You copy this, and then over here, we call the attributes blue, then the thread name.

152
00:12:19,400 --> 00:12:22,000
Blew in over here.

153
00:12:23,490 --> 00:12:30,360
The threat function blew and we're going to pass the attributes here.

154
00:12:32,060 --> 00:12:42,380
Like this, OK, so once we've created all of our threads or tasks over here, our OS task scheduler

155
00:12:42,380 --> 00:12:44,600
starts becomes always Kenna's that.

156
00:12:44,750 --> 00:12:45,830
So we start Akino.

157
00:12:47,180 --> 00:12:50,180
OK, you start Akino.

158
00:12:52,790 --> 00:12:55,010
So over here, he starts Keino.

159
00:12:59,830 --> 00:13:03,880
And then over here, we create threats.

160
00:13:08,650 --> 00:13:14,560
And also, actually, one step is required before we create the threats, we have to initialize the

161
00:13:14,560 --> 00:13:15,060
kennel.

162
00:13:15,910 --> 00:13:17,290
So I come up here.

163
00:13:21,140 --> 00:13:28,520
Initialise Keino like this, and we use Erskin initialize function, which we we can find in our function

164
00:13:28,520 --> 00:13:29,210
references.

165
00:13:29,900 --> 00:13:32,120
OK, so this is what we have next.

166
00:13:32,120 --> 00:13:39,290
We simply need to create the task functions so we can start with the tasks, which ones that we have.

167
00:13:39,290 --> 00:13:41,050
Let's we have all four of them.

168
00:13:41,060 --> 00:13:43,610
So I'll just start with green.

169
00:13:45,530 --> 00:13:52,310
This the task function is the same as the ones we've created before, we simply incrementing the various

170
00:13:52,310 --> 00:13:53,120
profiler's.

171
00:13:54,790 --> 00:14:04,000
So I just bring them from a previous project we created over here, we have Green Lady Controller Tosk,

172
00:14:04,000 --> 00:14:09,290
we simply incrementing Green Task Group Phyla, we have Orange Task.

173
00:14:09,590 --> 00:14:11,260
I like incremented in orange early.

174
00:14:11,290 --> 00:14:12,280
They control to task.

175
00:14:12,940 --> 00:14:15,710
We have the same florette we have the same for blue.

176
00:14:16,580 --> 00:14:21,960
OK, so we're looking good now let's do it and see what we've got here.

177
00:14:22,240 --> 00:14:23,050
Come over here.

178
00:14:24,790 --> 00:14:25,540
Right, click.

179
00:14:28,060 --> 00:14:29,740
I'll see the old project over here.

180
00:14:34,010 --> 00:14:35,210
It's building the project.

181
00:14:38,650 --> 00:14:39,220
OK.

182
00:14:40,000 --> 00:14:41,020
Oh, goodness.

183
00:14:42,190 --> 00:14:42,920
Just bear with me.

184
00:14:42,970 --> 00:14:46,780
We have to put the function prototypes at the top, the task functions.

185
00:14:48,790 --> 00:14:51,720
So that is why we received this type of error.

186
00:14:52,760 --> 00:15:00,240
OK, so we simply put the function prototypes here at the top here.

187
00:15:01,680 --> 00:15:03,620
OK, so let's do it again.

188
00:15:03,650 --> 00:15:09,770
So we have we simply copied the prototypes of each task function and placed the top let's build.

189
00:15:19,110 --> 00:15:21,240
OK, we've got no arrow, no warning.

190
00:15:21,860 --> 00:15:23,640
I'm going to right click over here.

191
00:15:25,120 --> 00:15:26,140
And see.

192
00:15:27,110 --> 00:15:32,180
Dbag us ystem 32 iSelect 35 Aubagio.

193
00:15:36,090 --> 00:15:37,680
Oh, say, OK, over here.

194
00:15:42,390 --> 00:15:43,200
It's open in.

195
00:15:45,210 --> 00:15:46,730
OK, let's switch over here.

196
00:15:50,990 --> 00:15:51,920
OK, let's see.

197
00:15:52,900 --> 00:15:54,640
It's getting ready, it's ready now.

198
00:15:54,670 --> 00:15:57,400
A click here to run and US can see.

199
00:15:58,310 --> 00:15:58,950
What happened?

200
00:15:58,970 --> 00:16:06,310
OK, they are working, we have each of them running equally and we can eliminate our delay if we want.

201
00:16:06,320 --> 00:16:11,960
We have this delay, pseudo delays that we've created, but we have each task.

202
00:16:13,080 --> 00:16:13,590
Running.

203
00:16:13,620 --> 00:16:19,360
OK, so this is how we can create our task.

204
00:16:19,410 --> 00:16:30,090
We can do the same thing we did in our native free Arktos API so we can use this census Arktos version

205
00:16:30,090 --> 00:16:30,970
to APIs.

206
00:16:30,990 --> 00:16:32,700
We can use it to achieve the same thing.

207
00:16:32,880 --> 00:16:36,800
OK, so this all the risk for this lesson and I assume the next lesson.

208
00:16:36,810 --> 00:16:37,620
Have a nice day.
