Hello, welcome back.
In this lesson, we are going to see how to create a thread or a task.
Using the crisis Arktos apps, so I'm going to make a copy of our very first project so that this would
be us if we started from scratch, I'm not going to use any of the intermediate projects we created.
I'm going to go to project one task creation over here.
I'll make a copy of this and then I'll pass it over here.
And then I'll call this.
No, we are at number 35, I call this 35 on the school, see Mrs. Artus.
And then I call this thread, remember, I said a thread, the word thread and task can be used interchangeably.
Is because the crisis artist uses the word threat, that is why I'm calling this threat rather than
Tosk, so I'm going to open the may not see fall over here, double click over here and I'm going to
let's see what we have here.
I'm going to clean everything that has to do with quote from here.
Oddly, this.
This is the task functions.
Because we made a copy of our free artist's version.
OK, and I'll clean this.
And I'll clean what we have over here.
OK, we just clean all of this so that we start from scratch together.
So over here, this one here, we did this, remember, we wrote a new function for our You are right.
This is the very first project.
So we had integrated our you at the see, and you are totally false.
OK, so in this project, let's see.
I will just enable this and disable this.
I hope you remember this because we wanted to work with you.
I wanted it to be faster.
What we did was we wrote this new function so that we wouldn't use the how you ought to transmit function.
OK, if you check the project, you would find that.
OK, so this is our you are right.
And then this one allows us to use printf and.
Our Ewart's code is still in here.
OK, so this the project one, I hope you're not confused by that.
OK, so what are we going to do to use Simms's ARTUS?
We have to go and find the documentation for Simms's Artus.
So we said Simms's Artus, the the function for creating a threat takes takes a structure as argument
we need to describe or the threat argument in a structure, and then we pass that structure as argument.
We need to describe all the threat attributes, the parameters and characteristics of the threat.
We need to define them in a structure imposter's structure as arguments to the threat create function.
So I'll come to Google over here and type.
Simms's Artus to over here and hit enter and I'll click this first link if you take me to the documentation.
OK, here we are.
So Simms's Artus to documentation, I can click over here, you can click here to see the function of
abuse.
This is the NASA APIs feature.
We can drop down over here and then we can click function description and it gives us a list of all
the functions.
OK, so this over here can be a quick way of knowing the functions you might require.
So over here, if you want to check thread management, there is a function to detach the thread.
There's a function to get a thread ID.
What we want to do is create a new thread.
So that's a function here.
Always threaten you, create a thread and add it to active threads.
So let's click on this, threaten you and see what we have.
OK.
And as you can see.
Dysfunction takes three arguments, the first argument is the threat function is what we used to call
the task function.
It is called threat function here.
The second argument is it's a pointer to an argument or a parameter you can pass to the Detroit function.
Remember, we can pass parameters to our created threat.
So this argument is for that parameter.
And this over here, the third argument is a pointer to a structure that you pass and this structure
here inside this structure, you you would define the stack size of the threat, the the priority of
the threat and other attributes that you want the threat to have.
OK, when we come over here in this document, it tells us about the priority levels as well.
Over here, it's created a special names for the priority.
So there is priority normal.
There is a priority below normal, normal, one mean normal priority plus one normal to normal, three
normal for so many priorities, essentially, that it's given all of them symbolic names so that we
need not use numbers.
OK, so.
Where is our function?
This is it, if we screw up, it will tell us the argument for this function.
Let's see, I grew up.
Over here.
OK, this table here describes the threat attributes to the structure that we pass to the threat, you
can have these attributes.
You can they can be a field for the name of the threat.
Another one.
This one is called Let's See, What does it say, attributes, unaskable bit the following bits mask
can be used to set options through a detached or trainable.
These are other options.
So basically, there are so many options, we're not going to use all of them.
Are we going to use the thread name, the stack size and the priority?
OK, so now if all of that sounds blurry, let's just go to our project.
This a fresh project.
We don't need you out yet.
You can delete it.
But in any case, there's just a fresh project we go into.
Starts by.
Creating our task profile is we need profiles so that we can be able to see what our threat or task
is working or not.
So I'll bring the profile this year.
We start with typedef great orange task profiler, red, green and blue.
OK, I'm going to define the stock size over here.
I'll see stock size five one two.
OK, once that is done, I'm going to come over here.
I'm going to declare.
The structure for our threat, so coming to my main function over here and then I'll see this thread
a TTR underscore t right.
And then I'll give it a name.
I call this green threat attributes.
I can use an abbreviation of trips like this.
OK, so this is a structure.
And then I guess the addenda members.
We use the dot operator, so I'll see DOT over here and you see it gives me all the members of the structure.
I can select name, priority, stuck, memory, stock size, et cetera, what we want to start with
is the name.
So I'll say that name over here and I'll simply call this green task.
And then.
I see a dot over here stack size, and then I just assigned a stock size with a sign at the top over
here.
And then once that's done, I said dot or assign a priority level over here, I'll just give it a priority
of normal or C.
O.
S priority.
Almost like this.
OK, so this is it, this is the green thread attributes.
So then once we are done, we use the the function we saw is called the always threaten you.
This function is what creates a new threat.
Who is threatening you?
OK, so we would say over here, who is threat knew and we passed the first argument.
The first argument has to be a threat function.
So we're going to have a threat function.
We shall call this threat the threat function, which we used to call the task function, because taskin
threat we use in the in the same context.
So this is going to be a green task function and then we don't have any arguments or parameters to pass
to this threat.
So we pass all over here and then the attributes we need to add the attribute here.
Like this, so then this will create our green threat for us.
OK, so then we're going to repeat this, we can repeat this for, let's see, Red and the others.
So I copy this.
And this time, I'll call the attributes red threat attributes such that I'll change to red as well
over here.
I misspelled the word task, so the name of the thread.
This one becomes red, although the priority be the same.
And over here.
So we have to pass this attributes as the third argument, and we're going to create a task function
called Red Early Controller Task.
OK, so once that is done, we can.
Do one for orange and blue.
So how about you post the video and you try to create four orange and blue because we have we have four
profiler's here and we've created two threats to do one for orange and then blue and then on post the
video.
Right, it's as simple as what we've done is simple, we simply defined a structure.
Over here, we give it a name.
I'm going to call this orange task, I'll keep the priority the same.
The task function is going to be orange, the controller.
And then over here, we're going to change the name of the attributes to Orange.
And we're going to pass this as the documents to the function and then we're going to do one for blue.
You copy this, and then over here, we call the attributes blue, then the thread name.
Blew in over here.
The threat function blew and we're going to pass the attributes here.
Like this, OK, so once we've created all of our threads or tasks over here, our OS task scheduler
starts becomes always Kenna's that.
So we start Akino.
OK, you start Akino.
So over here, he starts Keino.
And then over here, we create threats.
And also, actually, one step is required before we create the threats, we have to initialize the
kennel.
So I come up here.
Initialise Keino like this, and we use Erskin initialize function, which we we can find in our function
references.
OK, so this is what we have next.
We simply need to create the task functions so we can start with the tasks, which ones that we have.
Let's we have all four of them.
So I'll just start with green.
This the task function is the same as the ones we've created before, we simply incrementing the various
profiler's.
So I just bring them from a previous project we created over here, we have Green Lady Controller Tosk,
we simply incrementing Green Task Group Phyla, we have Orange Task.
I like incremented in orange early.
They control to task.
We have the same florette we have the same for blue.
OK, so we're looking good now let's do it and see what we've got here.
Come over here.
Right, click.
I'll see the old project over here.
It's building the project.
OK.
Oh, goodness.
Just bear with me.
We have to put the function prototypes at the top, the task functions.
So that is why we received this type of error.
OK, so we simply put the function prototypes here at the top here.
OK, so let's do it again.
So we have we simply copied the prototypes of each task function and placed the top let's build.
OK, we've got no arrow, no warning.
I'm going to right click over here.
And see.
Dbag us ystem 32 iSelect 35 Aubagio.
Oh, say, OK, over here.
It's open in.
OK, let's switch over here.
OK, let's see.
It's getting ready, it's ready now.
A click here to run and US can see.
What happened?
OK, they are working, we have each of them running equally and we can eliminate our delay if we want.
We have this delay, pseudo delays that we've created, but we have each task.
Running.
OK, so this is how we can create our task.
We can do the same thing we did in our native free Arktos API so we can use this census Arktos version
to APIs.
We can use it to achieve the same thing.
OK, so this all the risk for this lesson and I assume the next lesson.
Have a nice day.