1
00:00:00,640 --> 00:00:02,210
Hello, welcome back.

2
00:00:02,590 --> 00:00:09,520
In this lesson, we go in to see how to work with Q sets of going ahead to create a new project here

3
00:00:09,520 --> 00:00:12,250
called Number 17 Work in which Q sits.

4
00:00:12,940 --> 00:00:14,860
And this is an empty project.

5
00:00:14,860 --> 00:00:17,530
It's got no free Artus so far.

6
00:00:17,830 --> 00:00:19,720
I've cleaned all the free AHTO stuff.

7
00:00:20,050 --> 00:00:27,160
All we have here is our Jhpiego, you alternate system clock in it and the our respective functions.

8
00:00:27,430 --> 00:00:29,470
OK, so we're going to build it from scratch.

9
00:00:30,580 --> 00:00:31,780
So let's start off.

10
00:00:31,780 --> 00:00:37,720
We're going to have to Kyuss and we're going to add these two cubes to a single sets and we're going

11
00:00:37,720 --> 00:00:44,230
to see how our tasks will be able to receive and send using this new architecture of Q sets.

12
00:00:44,680 --> 00:00:50,170
So I'm going to start off by declaring two Qs, Q1 and Q2 like this.

13
00:00:50,680 --> 00:00:57,550
So I've declared to Qs over here, Q1 of initialize it to now like you to know, and then we're going

14
00:00:57,550 --> 00:00:59,620
to declare a single kupets.

15
00:01:01,370 --> 00:01:02,600
OK, like this.

16
00:01:04,330 --> 00:01:04,790
OK.

17
00:01:05,750 --> 00:01:14,420
So we have to kutya Q1 and Q2 and one, cuz it's cuz it's before we proceed, we would have to go to

18
00:01:14,420 --> 00:01:19,120
our three Arktos config, not each file to enable Khoosat to be able to use it.

19
00:01:19,790 --> 00:01:21,800
So I'm going to come over here.

20
00:01:22,300 --> 00:01:23,780
Our include foda.

21
00:01:24,740 --> 00:01:28,580
And then free artist config dot h, I'll double click this.

22
00:01:31,010 --> 00:01:34,640
And then it's open and I'm going to scroll down to find cuz it's.

23
00:01:37,020 --> 00:01:40,460
If CUSA doesn't exist here, we would have to type it ourselves.

24
00:01:42,450 --> 00:01:46,260
I can do control of who don't control and press F.

25
00:01:47,040 --> 00:01:48,030
And then search.

26
00:01:50,210 --> 00:01:51,260
Q sets.

27
00:01:52,340 --> 00:01:57,810
Well, it just keeps so we have you over here, another queue and then another queue.

28
00:01:58,070 --> 00:01:59,000
There is no queues.

29
00:01:59,000 --> 00:02:01,160
It's so we have to define it.

30
00:02:01,160 --> 00:02:03,110
We have to type this bit ourself.

31
00:02:06,190 --> 00:02:13,360
So close this and I'll come up over here to the top of the fall and over here, I'm simply where I have

32
00:02:13,360 --> 00:02:16,450
this, I'm simply going to add a new one.

33
00:02:18,420 --> 00:02:22,380
Config use underscore, it's so you type this.

34
00:02:24,260 --> 00:02:32,680
OK, so now cusa to be available and then control hesta safe and then may not see you over here so as

35
00:02:32,690 --> 00:02:33,990
to save may not see us.

36
00:02:34,010 --> 00:02:34,310
Well.

37
00:02:35,320 --> 00:02:39,160
Now we can proceed with created to accuse one Clouzot's.

38
00:02:40,570 --> 00:02:48,130
Now, in our main function, we go into we've declared the hunt for the Qs, sorry, if not created.

39
00:02:48,790 --> 00:02:50,470
Now we're going to create the Qs.

40
00:02:51,740 --> 00:02:54,140
So we're going to create Q1 and Q2.

41
00:02:56,540 --> 00:03:04,730
OK, so we've created two cues, each sense a character pointer and key, one offense, execute, create

42
00:03:05,420 --> 00:03:11,570
one size of character pointer and then cue to also the same thing.

43
00:03:12,290 --> 00:03:18,650
OK, so now we're going to add these cues to the cues using the execute function.

44
00:03:21,660 --> 00:03:29,070
It's as simple as excuse, could you give the name of the Q and a Q said you want to add it to so we

45
00:03:29,070 --> 00:03:34,170
add one to the Q set that we are two to the Q set as well.

46
00:03:35,080 --> 00:03:38,770
OK, once that is done, we're going to create our tasks.

47
00:03:39,100 --> 00:03:46,930
We're going to have to send the tasks of the same priority of one and then one receive our task with

48
00:03:46,930 --> 00:03:48,430
a higher priority of two.

49
00:03:49,280 --> 00:03:52,120
OK, so I'm going to bring descender tasks.

50
00:03:53,920 --> 00:03:55,390
We have to send a task.

51
00:03:55,960 --> 00:04:02,140
We have sent a task one over here to the stack size is too much.

52
00:04:02,150 --> 00:04:03,880
I'm going to reduce it to one hundred.

53
00:04:05,900 --> 00:04:12,940
OK, so then we have send a task one over here, we're going to create a task function for it's called

54
00:04:12,950 --> 00:04:17,790
we send a task one and then it's got a priority of one over here.

55
00:04:18,110 --> 00:04:22,570
Send a task to priority of one as well, OK?

56
00:04:23,090 --> 00:04:28,130
And we're going to create a receiver task with a higher priority.

57
00:04:31,780 --> 00:04:38,410
We've created a receiver task once that is done, we going to start our scheduler, lest we forget.

58
00:04:40,450 --> 00:04:47,120
We start the show, OK, so then we only have to deal with our task functions.

59
00:04:47,140 --> 00:04:54,880
Now I'm going to create the task function for the first and the task as simple as this V task one,

60
00:04:54,880 --> 00:05:00,640
because that's the name we said we given the send task one task function and we're going to declare

61
00:05:00,640 --> 00:05:02,020
the amount of time to wait.

62
00:05:02,500 --> 00:05:03,550
We're going to say wait.

63
00:05:03,550 --> 00:05:04,570
Four hundred Ms.

64
00:05:07,150 --> 00:05:12,450
We're going to see, OK, this the amount of time you should block with four hundred Ms.

65
00:05:19,540 --> 00:05:25,030
And we're going to define the data to say and remember, we said our cue is going to be send in character

66
00:05:25,030 --> 00:05:25,560
pointers.

67
00:05:26,140 --> 00:05:32,410
So we're going to say, OK, send MSG, MSG message from V. Task one.

68
00:05:32,980 --> 00:05:33,550
OK.

69
00:05:35,650 --> 00:05:39,700
Once that is done, we going to open our infinite loop over here.

70
00:05:44,470 --> 00:05:52,080
And we're going to see wait for them is by putting it in the blog states four hundred Ms.

71
00:05:53,160 --> 00:05:54,720
So we're going to save TASC.

72
00:05:57,870 --> 00:06:03,960
V. Task DeLay, one hundred M is OK, and then once that is done, we're going to send it.

73
00:06:05,930 --> 00:06:15,260
So we're going to send our MSgt to one like this Kyuss and we send into Q1 address of MSgt, we put

74
00:06:15,260 --> 00:06:23,050
zero here, OK, for the takeaway timeout, OK, once that is done, we going to copy this.

75
00:06:23,810 --> 00:06:28,430
This is V tasc one and then paste it over here to get V task to.

76
00:06:30,090 --> 00:06:35,940
Over here and over here, the message is going to be message from send a task to and I'm going to make

77
00:06:35,940 --> 00:06:37,740
this one wait for two hundred Ms.

78
00:06:38,800 --> 00:06:39,360
OK.

79
00:06:42,870 --> 00:06:50,010
And over here, we send in this information to task to Q2, sorry, OK, so, so far so good.

80
00:06:50,010 --> 00:06:55,750
We are using just cuz we've not written anything with regards to Cusato yet.

81
00:06:56,520 --> 00:07:03,380
OK, so it's in the receiver task that we find the the use and the benefit of the queue sits.

82
00:07:03,780 --> 00:07:08,490
We're going to come down here to create the task function for our receiver task.

83
00:07:12,820 --> 00:07:23,440
We first start off by declaring a Q variable to hold the the AQ Hondo variable, because what is going

84
00:07:23,440 --> 00:07:28,890
to happen is our Q set is going to return the handle of the Q that has new data.

85
00:07:29,290 --> 00:07:30,790
So we need to store it somewhere.

86
00:07:30,790 --> 00:07:39,190
We declare this excuse that contains data as the name of the variable to hold the Q and then we're going

87
00:07:39,190 --> 00:07:48,910
to have a character pointer as well for the data because our Qs data type is character pointer.

88
00:07:49,510 --> 00:07:55,330
OK, so then we're going to open our infinite loop over here, I'll say.

89
00:07:55,330 --> 00:07:58,300
Well one open and close.

90
00:07:59,180 --> 00:08:05,930
And then we're going to use the function excuse selects from set, then we pass the cue sets and then

91
00:08:06,200 --> 00:08:07,790
we delete infinitely.

92
00:08:09,310 --> 00:08:12,030
OK, so we see excuse.

93
00:08:13,350 --> 00:08:15,030
Select from set and then.

94
00:08:15,920 --> 00:08:20,360
This function were returned, accuses the House, new data and storage in a.

95
00:08:21,960 --> 00:08:24,150
Khuda content states are variable here.

96
00:08:26,150 --> 00:08:26,660
OK.

97
00:08:28,260 --> 00:08:29,430
Or minimize this.

98
00:08:29,610 --> 00:08:30,140
OK.

99
00:08:33,910 --> 00:08:38,410
So we are blocking here indefinitely until they're secured data.

100
00:08:38,500 --> 00:08:44,920
So that's why we're using Portsmouth's delay here, we blocking for an infinite amount of time, essentially

101
00:08:45,340 --> 00:08:46,200
maximum delay.

102
00:08:47,050 --> 00:08:53,350
And then when there is data, when Cuba's new data then is going to be returned and stored in our variable

103
00:08:53,350 --> 00:08:53,680
here.

104
00:08:54,250 --> 00:09:02,010
OK, so now that we have the handle of the KHUDA has new data, then we can use our Q API to receive.

105
00:09:02,290 --> 00:09:10,990
So we use our curacy function excusive function and we simply pass the handle of the Q that we want

106
00:09:10,990 --> 00:09:14,380
to receive from and then we store it over here.

107
00:09:15,640 --> 00:09:16,210
OK.

108
00:09:18,350 --> 00:09:22,250
And once that is done, we can print the results.

109
00:09:22,770 --> 00:09:24,080
I can simply say printf.

110
00:09:26,910 --> 00:09:27,990
The content of this.

111
00:09:29,470 --> 00:09:31,060
OK, like this.

112
00:09:33,200 --> 00:09:39,800
So that is it, so that's the essential part our accused use uses excuse select from set.

113
00:09:40,340 --> 00:09:47,180
You pass the cue set on those arguments and take wait time, OK?

114
00:09:47,190 --> 00:09:54,290
And then this function is going to get stuck here or is going to wait here until there is a queue in

115
00:09:54,290 --> 00:09:56,050
the queue sets that has new data.

116
00:09:56,270 --> 00:10:02,210
When that happens, the handle of that queue is going to be returned and stored in our variable and

117
00:10:02,210 --> 00:10:03,530
we're going to use the handle.

118
00:10:05,020 --> 00:10:08,980
I commend to our curacy function to receive data from its.

119
00:10:09,890 --> 00:10:12,560
OK, so all we have to do.

120
00:10:13,450 --> 00:10:19,600
Descender function, prototypes of our task functions to the top over here.

121
00:10:22,120 --> 00:10:29,890
This is the one for senator, one task and then send to we need the last one for the receiver to ask.

122
00:10:31,370 --> 00:10:34,450
Grab this over here, put this over here.

123
00:10:37,680 --> 00:10:43,560
OK, so we're looking good, no, let's build and see what we have.

124
00:10:44,870 --> 00:10:46,730
I'm going to explain this.

125
00:10:47,950 --> 00:10:53,140
And then I'm going to right click over here, I'll see Build Project.

126
00:10:54,420 --> 00:10:55,080
Like this.

127
00:10:56,540 --> 00:10:59,660
And then I'll explain this a bit so that we can see the progress.

128
00:11:01,540 --> 00:11:03,790
It says it's built successfully.

129
00:11:04,900 --> 00:11:13,440
OK, I'm going to right click and then I'll say run us ASTM 30 to Coatex and I'll select 17 over here.

130
00:11:13,480 --> 00:11:15,700
I'll double click on 17 click.

131
00:11:15,700 --> 00:11:16,840
OK, over here.

132
00:11:21,290 --> 00:11:23,060
And it's flashing onto the board.

133
00:11:24,060 --> 00:11:26,120
I see we still have real time here.

134
00:11:27,280 --> 00:11:32,080
This is from our previous project, I'm going to clear this, I'm going to open the port.

135
00:11:34,670 --> 00:11:40,360
I'm going to press the reset to my board to see real time, it's not opening.

136
00:11:40,670 --> 00:11:41,180
Let's see.

137
00:11:42,450 --> 00:11:45,750
The last time we had that, there was an anomaly in the code.

138
00:11:46,860 --> 00:11:49,190
Let's see if we have similar issues.

139
00:11:50,170 --> 00:11:53,370
I don't think we have any such issues today.

140
00:11:56,730 --> 00:12:03,720
So let's inspect our code to see where we may have anomalies, so we started off over here by creating

141
00:12:03,720 --> 00:12:04,590
two Qs.

142
00:12:06,040 --> 00:12:13,310
And storing them in their handles and then we added these two accused to our Cusato known as Cusato,

143
00:12:13,320 --> 00:12:14,290
whose handle this year.

144
00:12:15,070 --> 00:12:20,440
OK, the issue is we didn't agree to discuss it, so we just declared its Hondo.

145
00:12:20,440 --> 00:12:21,370
We've not created it.

146
00:12:22,120 --> 00:12:22,560
Right.

147
00:12:23,380 --> 00:12:25,600
So we have to create accuses.

148
00:12:26,440 --> 00:12:33,070
I'll come over here and we just use the excuse to create set function.

149
00:12:34,240 --> 00:12:37,270
To critics, it's like this, OK?

150
00:12:38,760 --> 00:12:43,140
So this Cusato is going to hold to Kyuss HQ has a single element.

151
00:12:44,870 --> 00:12:51,980
OK, also, one other thing we're going to do is I'm going to be printing something here so that whenever

152
00:12:51,980 --> 00:12:54,350
we have an issue, a list.

153
00:12:55,970 --> 00:13:02,840
We can eliminate the cause being that you add to our print system initializing whenever we start.

154
00:13:06,060 --> 00:13:10,110
So that when we see this get printed, we know this, that you are just fine.

155
00:13:10,540 --> 00:13:17,190
OK, so we're looking good and then yeah, the stock size looks fine.

156
00:13:17,880 --> 00:13:22,710
When I scroll down here and over here, we can simplify it.

157
00:13:23,700 --> 00:13:24,660
We need not.

158
00:13:26,330 --> 00:13:29,090
We can just see a character pointer should be fine.

159
00:13:33,230 --> 00:13:36,320
This is in to we do the same for task one.

160
00:13:39,770 --> 00:13:50,760
OK, and then over here in print, if I'm going to see percentages, when you give the specify a percentages,

161
00:13:51,470 --> 00:13:52,760
print this string.

162
00:13:53,330 --> 00:13:54,560
Yeah, this string could.

163
00:13:54,570 --> 00:13:54,960
Yes, here.

164
00:13:55,190 --> 00:13:58,240
OK, let's see whether this will get us running.

165
00:13:58,610 --> 00:13:59,960
I'll click over here to build.

166
00:14:06,280 --> 00:14:07,480
It's built successfully.

167
00:14:09,080 --> 00:14:10,640
All right, click over here.

168
00:14:12,100 --> 00:14:13,720
Run us SDM 30 to.

169
00:14:14,840 --> 00:14:16,940
Double click number 17 over here.

170
00:14:20,600 --> 00:14:22,250
It's downloading onto the board.

171
00:14:29,580 --> 00:14:32,430
It's finished downloading, I'm going to open real to.

172
00:14:35,550 --> 00:14:37,300
OK, you know, we have real time.

173
00:14:37,320 --> 00:14:43,630
I'm going to clear, as can see, a message from V Task one V. Task to oppose.

174
00:14:44,430 --> 00:14:45,210
So we have.

175
00:14:46,430 --> 00:14:53,420
Send a task to send a task, one task, one task to task, one task, one task to the reason why we

176
00:14:53,420 --> 00:15:00,590
have task one more than task to of course, you would realize that we put in one of the senders for

177
00:15:00,590 --> 00:15:02,240
a longer time in the blocked state.

178
00:15:03,220 --> 00:15:08,830
Task to entice block states for two hundred Emmis, whereas task one enters for one hundred.

179
00:15:09,490 --> 00:15:11,880
So that is why Task one is having more time.

180
00:15:12,160 --> 00:15:15,090
That's why I want to send in more than task, too.

181
00:15:15,550 --> 00:15:17,670
But this is a this is how to use it.

182
00:15:17,890 --> 00:15:24,730
So whichever has new data to use, it will return the handle of the queue and then we can use the handle

183
00:15:24,730 --> 00:15:28,390
to receive from the Q and use the data as we wish.

184
00:15:28,870 --> 00:15:33,160
So this or the risk for this lesson, if you have any questions, leave them in the questions analysis

185
00:15:33,160 --> 00:15:35,080
area and I shall see you later.

186
00:15:35,180 --> 00:15:35,920
Have a nice the.
