1
00:00:00,940 --> 00:00:02,060
Hello, welcome back.

2
00:00:02,080 --> 00:00:07,850
In this lesson, we're going to see how to use the ideal task, right?

3
00:00:07,870 --> 00:00:15,880
So the ideal task is one of the default tasks that are created automatically when we when we start our

4
00:00:15,880 --> 00:00:18,700
scheduler, we need not create those explicitly.

5
00:00:18,700 --> 00:00:21,610
Like we create like we create our other tasks.

6
00:00:21,850 --> 00:00:24,360
These tasks are created automatically.

7
00:00:24,370 --> 00:00:25,690
There is the ideal task.

8
00:00:26,020 --> 00:00:30,640
And then there is the task task, which we shall see how they all work.

9
00:00:31,270 --> 00:00:31,630
Right.

10
00:00:31,640 --> 00:00:35,110
I'm going to come to one of our old projects and then make a copy.

11
00:00:36,620 --> 00:00:37,220
Let's see.

12
00:00:38,170 --> 00:00:41,770
Welcome to project number four over here, knownas top priority.

13
00:00:42,160 --> 00:00:48,490
I'll copy and paste over here and then I'll call this number 13, the ideal task.

14
00:01:03,370 --> 00:01:07,620
OK, so it's open over here, going to open me, see over here.

15
00:01:09,860 --> 00:01:16,880
Right, so let's see what this project has, this project has three tasks, all of the same priority.

16
00:01:17,890 --> 00:01:19,390
Right, OK.

17
00:01:19,690 --> 00:01:26,380
And then all of them have their profiles and they simply increment these profiles, and when we run

18
00:01:26,380 --> 00:01:30,060
this, we expect to see all of them executed with the same value.

19
00:01:30,400 --> 00:01:31,380
Let's confirm that.

20
00:01:31,750 --> 00:01:34,510
I'm going to come over here to click over here to build.

21
00:01:37,480 --> 00:01:40,180
It's built successfully a click here to download onto the board.

22
00:01:43,410 --> 00:01:44,400
And then I say, OK.

23
00:01:50,620 --> 00:01:52,380
Then I'll switch over here.

24
00:01:56,510 --> 00:02:00,440
So we have our blue red green click here to run.

25
00:02:01,500 --> 00:02:05,520
As you can see, they are running to have the same rates essentially, so they are sharing the time

26
00:02:05,760 --> 00:02:07,350
running for equal amount of time.

27
00:02:07,860 --> 00:02:09,210
OK, I'm going to come out here.

28
00:02:11,040 --> 00:02:15,240
No, I'm going to come down here to include one function.

29
00:02:17,530 --> 00:02:19,760
I'm going to come down here to include one function.

30
00:02:20,380 --> 00:02:22,830
This is a callback function, meaning dysfunction.

31
00:02:23,740 --> 00:02:29,560
The name has been defined somewhere and we simply need to provide its implementation and we don't need

32
00:02:29,560 --> 00:02:30,280
to call it.

33
00:02:30,730 --> 00:02:33,510
This function is called the application Eido Hook.

34
00:02:34,120 --> 00:02:36,390
So it's a void function.

35
00:02:36,400 --> 00:02:41,050
And then we start with V and then we see application.

36
00:02:41,060 --> 00:02:42,640
I do OK.

37
00:02:44,470 --> 00:02:46,010
And then it takes no argument.

38
00:02:46,540 --> 00:02:47,830
So there's a callback function.

39
00:02:47,830 --> 00:02:49,640
The name has to be exactly the same.

40
00:02:50,080 --> 00:02:58,540
So it is inside this function that we we put the content that we want to execute.

41
00:02:58,870 --> 00:03:00,730
When the scheduler is an ideal.

42
00:03:00,730 --> 00:03:05,680
States and EIDO states basically means there is nothing to execute when the scheduler has nothing to

43
00:03:05,680 --> 00:03:06,280
execute.

44
00:03:07,090 --> 00:03:12,340
Perhaps we could take this opportunity to perform a bit of housekeeping, cleaning up certain things.

45
00:03:12,940 --> 00:03:15,300
We can do that using our idea here.

46
00:03:16,270 --> 00:03:18,700
So I'm going to create a counter for this.

47
00:03:18,700 --> 00:03:21,520
There's this function going to see.

48
00:03:23,190 --> 00:03:24,080
Wycheproof profiler.

49
00:03:25,500 --> 00:03:31,050
Controversy and then a paste over here, I call this I task profiler.

50
00:03:33,880 --> 00:03:40,450
Then I'll copy this and then I'll place this inside, I do Hook.

51
00:03:40,470 --> 00:03:41,100
Where is it?

52
00:03:41,310 --> 00:03:42,030
It's up here.

53
00:03:44,160 --> 00:03:47,600
So we increment this just like we have to incrementing the rest.

54
00:03:48,060 --> 00:03:49,560
Now let's build and see what happens.

55
00:03:49,590 --> 00:03:51,030
I'm going to click over here to build.

56
00:03:54,640 --> 00:03:55,150
And then.

57
00:03:56,470 --> 00:03:58,180
I'm going to click here to go to debark.

58
00:04:02,850 --> 00:04:03,960
And I'm going to switch.

59
00:04:08,070 --> 00:04:15,530
I'm going to order one new profiler to our live expressions when I copy this controversy, then obviously

60
00:04:15,760 --> 00:04:17,670
over here, not quick to run.

61
00:04:19,630 --> 00:04:26,540
Right, we see that nothing is happening, our ideal is not being executed this year.

62
00:04:26,950 --> 00:04:31,840
This implies that the church has no free time to deal with ideal stuff.

63
00:04:32,440 --> 00:04:36,150
OK, let's introduce a Whately.

64
00:04:36,370 --> 00:04:42,120
We saw how to delay or put a task in a block states to wait for a timeout event.

65
00:04:43,120 --> 00:04:45,420
I'm going to say constant tick tock.

66
00:04:47,910 --> 00:04:49,470
And it's quality over here.

67
00:04:54,080 --> 00:05:04,910
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.

68
00:05:08,990 --> 00:05:14,300
And then I'm going to pass 250 times in here, controversy, then control feature based.

69
00:05:15,130 --> 00:05:21,860
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

70
00:05:21,860 --> 00:05:29,670
below or just command the task creation function for red and green and over here, just plus active.

71
00:05:29,690 --> 00:05:31,040
So in blue, I'm going to come here.

72
00:05:31,040 --> 00:05:33,230
And if we delay the task delay.

73
00:05:38,050 --> 00:05:45,880
I'm going to make blue delay for this amount of time, 250, Emmis a copy this, then paste it over

74
00:05:45,880 --> 00:05:48,280
here like this.

75
00:05:51,000 --> 00:05:53,400
OK, so I'm going to click here to build.

76
00:05:55,480 --> 00:05:58,300
We have to address the scene where we could get that from.

77
00:06:00,240 --> 00:06:02,880
Take type appears problematic.

78
00:06:06,250 --> 00:06:08,190
Take a side on this quote.

79
00:06:10,350 --> 00:06:13,290
In expansion of Markku PD, Ms.

80
00:06:14,420 --> 00:06:14,760
Thank you.

81
00:06:14,810 --> 00:06:23,690
Let's see, PDM is on and a to takes OK, over here, I ended up passing this argument here, but this

82
00:06:23,690 --> 00:06:25,250
should be the number 250.

83
00:06:26,090 --> 00:06:28,010
OK, let's build and see again.

84
00:06:29,380 --> 00:06:32,260
We have no erro click here to get onto the boat.

85
00:06:36,810 --> 00:06:38,570
And then I'll switch over here.

86
00:06:40,100 --> 00:06:41,420
OK, let's click to Run.

87
00:06:44,380 --> 00:06:45,280
Click here to run.

88
00:06:46,550 --> 00:06:48,290
No, we simply have to run in.

89
00:06:50,750 --> 00:06:52,450
OK, I don't ask.

90
00:06:52,490 --> 00:06:59,150
It's not running, OK, so let's go to our config file and see if we've enabled Idol task.

91
00:07:00,680 --> 00:07:03,440
To go to our config file, we come by here.

92
00:07:04,760 --> 00:07:12,050
This is how project we come to middleware, or we can go through three artists to see and then we go

93
00:07:12,050 --> 00:07:19,070
to three artists to reach declaration, and then in there we go to config.

94
00:07:21,810 --> 00:07:25,260
Over here, let's see whether we are using Idil TASC.

95
00:07:28,080 --> 00:07:29,540
I do task and neighborhood.

96
00:07:30,720 --> 00:07:37,290
OK, so I do task is disabled here, I'm going to set it to one to enable it to save.

97
00:07:38,080 --> 00:07:38,930
I'm going to come back.

98
00:07:38,940 --> 00:07:40,950
You click here to build.

99
00:07:47,270 --> 00:07:50,450
And then I'll come I'll come over here to debark.

100
00:07:53,760 --> 00:07:54,570
And then switch.

101
00:07:59,350 --> 00:07:59,740
Then.

102
00:08:01,000 --> 00:08:08,960
Around this, you can see our editors are so much free time to work because we have just a single task

103
00:08:09,260 --> 00:08:12,170
and this task goes to sleep for 250 times.

104
00:08:12,500 --> 00:08:16,300
And during the sleep time, the ideal task executes its content.

105
00:08:16,310 --> 00:08:18,470
It performs its housekeeping job.

106
00:08:18,920 --> 00:08:19,730
OK, so.

107
00:08:20,680 --> 00:08:27,280
Before, when we did a NASA experiment to the EIDO task was disabled, so let's just enable these and

108
00:08:27,280 --> 00:08:30,820
go back to the initial stage we started with going to enable this.

109
00:08:30,820 --> 00:08:37,300
And I'm going to comment about the delay that we have in Blue Task and see what happens.

110
00:08:37,570 --> 00:08:38,700
Click over here to build.

111
00:08:38,890 --> 00:08:41,510
Now we have all three tasks and there is no delay.

112
00:08:41,530 --> 00:08:42,880
None of them is going to sleep.

113
00:08:43,570 --> 00:08:44,770
Then I'm going to click here.

114
00:08:46,300 --> 00:08:47,140
To go to debunk.

115
00:08:48,930 --> 00:08:49,650
And then switch.

116
00:08:54,360 --> 00:09:01,110
And then I'm going to click here to run, as you can see, when we have all three tasks and none of

117
00:09:01,110 --> 00:09:07,110
them is being put in the in the blocked state, there is no time to deal with do task.

118
00:09:07,800 --> 00:09:09,570
OK, so how about this?

119
00:09:10,020 --> 00:09:17,700
How about let's just see how well each task goes to sleep four to five times, just like blue going

120
00:09:17,700 --> 00:09:20,280
to enable this delay for each of them.

121
00:09:22,110 --> 00:09:22,560
Right.

122
00:09:24,070 --> 00:09:25,500
Then I'm going to click here to build.

123
00:09:28,110 --> 00:09:28,560
Then.

124
00:09:29,930 --> 00:09:32,110
Going to click here to get onto the board.

125
00:09:34,490 --> 00:09:35,660
Switch over here.

126
00:09:38,850 --> 00:09:40,260
And I'm going to click here to run.

127
00:09:41,400 --> 00:09:47,240
So with this, because they all go to sleep, there is some time to perform IDU task.

128
00:09:47,250 --> 00:09:53,340
So you see I do task running over here and all of them, they execute to go to sleep four to five times.

129
00:09:53,760 --> 00:09:54,170
Right.

130
00:09:54,210 --> 00:10:00,810
So the ideal task is basically for performing certain housekeeping stuff like cleaning memory and all

131
00:10:00,810 --> 00:10:01,170
of that.

132
00:10:02,100 --> 00:10:05,340
And as you can see, this task is not created.

133
00:10:05,520 --> 00:10:10,170
We just call its name and then put our block of code over here.

134
00:10:17,610 --> 00:10:18,690
Over here like this.

135
00:10:21,460 --> 00:10:30,100
So so the question is, how come when we have all the tasks running without delay, I do a task doesn't

136
00:10:30,490 --> 00:10:31,230
run at all.

137
00:10:31,360 --> 00:10:32,710
How is this implemented?

138
00:10:33,430 --> 00:10:34,670
The way this is implemented?

139
00:10:34,690 --> 00:10:38,700
Is that the ideal task has the lowest priority of all tasks.

140
00:10:39,280 --> 00:10:45,460
So if we have our other three tasks with the same priority, which is higher than the ideal task by

141
00:10:45,460 --> 00:10:48,270
that arrangement, ideal task, execute at all.

142
00:10:48,520 --> 00:10:56,300
And we saw this experiment when we were running the the the priority, you know, when we were executing

143
00:10:56,300 --> 00:10:58,740
the project on changing task priorities.

144
00:10:59,080 --> 00:11:02,160
So that is why the EIDO task does not execute.

145
00:11:02,320 --> 00:11:09,790
But when these tasks that have a higher priority than idle tasks go to sleep, then idle task cannot

146
00:11:09,790 --> 00:11:11,060
cannot perform its job.

147
00:11:11,680 --> 00:11:13,840
So that is why we have it working like the.

148
00:11:15,830 --> 00:11:16,290
Right.

149
00:11:16,460 --> 00:11:19,940
So this is all there is, and I'll see you in the next lesson of Neistat.
