Hello, welcome back.
In this lesson, we're going to see how to use the ideal task, right?
So the ideal task is one of the default tasks that are created automatically when we when we start our
scheduler, we need not create those explicitly.
Like we create like we create our other tasks.
These tasks are created automatically.
There is the ideal task.
And then there is the task task, which we shall see how they all work.
Right.
I'm going to come to one of our old projects and then make a copy.
Let's see.
Welcome to project number four over here, knownas top priority.
I'll copy and paste over here and then I'll call this number 13, the ideal task.
OK, so it's open over here, going to open me, see over here.
Right, so let's see what this project has, this project has three tasks, all of the same priority.
Right, OK.
And then all of them have their profiles and they simply increment these profiles, and when we run
this, we expect to see all of them executed with the same value.
Let's confirm that.
I'm going to come over here to click over here to build.
It's built successfully a click here to download onto the board.
And then I say, OK.
Then I'll switch over here.
So we have our blue red green click here to run.
As you can see, they are running to have the same rates essentially, so they are sharing the time
running for equal amount of time.
OK, I'm going to come out here.
No, I'm going to come down here to include one function.
I'm going to come down here to include one function.
This is a callback function, meaning dysfunction.
The name has been defined somewhere and we simply need to provide its implementation and we don't need
to call it.
This function is called the application Eido Hook.
So it's a void function.
And then we start with V and then we see application.
I do OK.
And then it takes no argument.
So there's a callback function.
The name has to be exactly the same.
So it is inside this function that we we put the content that we want to execute.
When the scheduler is an ideal.
States and EIDO states basically means there is nothing to execute when the scheduler has nothing to
execute.
Perhaps we could take this opportunity to perform a bit of housekeeping, cleaning up certain things.
We can do that using our idea here.
So I'm going to create a counter for this.
There's this function going to see.
Wycheproof profiler.
Controversy and then a paste over here, I call this I task profiler.
Then I'll copy this and then I'll place this inside, I do Hook.
Where is it?
It's up here.
So we increment this just like we have to incrementing the rest.
Now let's build and see what happens.
I'm going to click over here to build.
And then.
I'm going to click here to go to debark.
And I'm going to switch.
I'm going to order one new profiler to our live expressions when I copy this controversy, then obviously
over here, not quick to run.
Right, we see that nothing is happening, our ideal is not being executed this year.
This implies that the church has no free time to deal with ideal stuff.
OK, let's introduce a Whately.
We saw how to delay or put a task in a block states to wait for a timeout event.
I'm going to say constant tick tock.
And it's quality over here.
And then I'm going to create a delay of 250 Emmis, 250 TM's, and what I want to do is CDMs to Tick's.
And then I'm going to pass 250 times in here, controversy, then control feature based.
OK, now one other thing I'll do is I'm going to disable two of the tasks we're going to deal with just
below or just command the task creation function for red and green and over here, just plus active.
So in blue, I'm going to come here.
And if we delay the task delay.
I'm going to make blue delay for this amount of time, 250, Emmis a copy this, then paste it over
here like this.
OK, so I'm going to click here to build.
We have to address the scene where we could get that from.
Take type appears problematic.
Take a side on this quote.
In expansion of Markku PD, Ms.
Thank you.
Let's see, PDM is on and a to takes OK, over here, I ended up passing this argument here, but this
should be the number 250.
OK, let's build and see again.
We have no erro click here to get onto the boat.
And then I'll switch over here.
OK, let's click to Run.
Click here to run.
No, we simply have to run in.
OK, I don't ask.
It's not running, OK, so let's go to our config file and see if we've enabled Idol task.
To go to our config file, we come by here.
This is how project we come to middleware, or we can go through three artists to see and then we go
to three artists to reach declaration, and then in there we go to config.
Over here, let's see whether we are using Idil TASC.
I do task and neighborhood.
OK, so I do task is disabled here, I'm going to set it to one to enable it to save.
I'm going to come back.
You click here to build.
And then I'll come I'll come over here to debark.
And then switch.
Then.
Around this, you can see our editors are so much free time to work because we have just a single task
and this task goes to sleep for 250 times.
And during the sleep time, the ideal task executes its content.
It performs its housekeeping job.
OK, so.
Before, when we did a NASA experiment to the EIDO task was disabled, so let's just enable these and
go back to the initial stage we started with going to enable this.
And I'm going to comment about the delay that we have in Blue Task and see what happens.
Click over here to build.
Now we have all three tasks and there is no delay.
None of them is going to sleep.
Then I'm going to click here.
To go to debunk.
And then switch.
And then I'm going to click here to run, as you can see, when we have all three tasks and none of
them is being put in the in the blocked state, there is no time to deal with do task.
OK, so how about this?
How about let's just see how well each task goes to sleep four to five times, just like blue going
to enable this delay for each of them.
Right.
Then I'm going to click here to build.
Then.
Going to click here to get onto the board.
Switch over here.
And I'm going to click here to run.
So with this, because they all go to sleep, there is some time to perform IDU task.
So you see I do task running over here and all of them, they execute to go to sleep four to five times.
Right.
So the ideal task is basically for performing certain housekeeping stuff like cleaning memory and all
of that.
And as you can see, this task is not created.
We just call its name and then put our block of code over here.
Over here like this.
So so the question is, how come when we have all the tasks running without delay, I do a task doesn't
run at all.
How is this implemented?
The way this is implemented?
Is that the ideal task has the lowest priority of all tasks.
So if we have our other three tasks with the same priority, which is higher than the ideal task by
that arrangement, ideal task, execute at all.
And we saw this experiment when we were running the the the priority, you know, when we were executing
the project on changing task priorities.
So that is why the EIDO task does not execute.
But when these tasks that have a higher priority than idle tasks go to sleep, then idle task cannot
cannot perform its job.
So that is why we have it working like the.
Right.
So this is all there is, and I'll see you in the next lesson of Neistat.