Hello, welcome back.
In this lesson, we go in to see how to work with Q sets of going ahead to create a new project here
called Number 17 Work in which Q sits.
And this is an empty project.
It's got no free Artus so far.
I've cleaned all the free AHTO stuff.
All we have here is our Jhpiego, you alternate system clock in it and the our respective functions.
OK, so we're going to build it from scratch.
So let's start off.
We're going to have to Kyuss and we're going to add these two cubes to a single sets and we're going
to see how our tasks will be able to receive and send using this new architecture of Q sets.
So I'm going to start off by declaring two Qs, Q1 and Q2 like this.
So I've declared to Qs over here, Q1 of initialize it to now like you to know, and then we're going
to declare a single kupets.
OK, like this.
OK.
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
our three Arktos config, not each file to enable Khoosat to be able to use it.
So I'm going to come over here.
Our include foda.
And then free artist config dot h, I'll double click this.
And then it's open and I'm going to scroll down to find cuz it's.
If CUSA doesn't exist here, we would have to type it ourselves.
I can do control of who don't control and press F.
And then search.
Q sets.
Well, it just keeps so we have you over here, another queue and then another queue.
There is no queues.
It's so we have to define it.
We have to type this bit ourself.
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
this, I'm simply going to add a new one.
Config use underscore, it's so you type this.
OK, so now cusa to be available and then control hesta safe and then may not see you over here so as
to save may not see us.
Well.
Now we can proceed with created to accuse one Clouzot's.
Now, in our main function, we go into we've declared the hunt for the Qs, sorry, if not created.
Now we're going to create the Qs.
So we're going to create Q1 and Q2.
OK, so we've created two cues, each sense a character pointer and key, one offense, execute, create
one size of character pointer and then cue to also the same thing.
OK, so now we're going to add these cues to the cues using the execute function.
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
add one to the Q set that we are two to the Q set as well.
OK, once that is done, we're going to create our tasks.
We're going to have to send the tasks of the same priority of one and then one receive our task with
a higher priority of two.
OK, so I'm going to bring descender tasks.
We have to send a task.
We have sent a task one over here to the stack size is too much.
I'm going to reduce it to one hundred.
OK, so then we have send a task one over here, we're going to create a task function for it's called
we send a task one and then it's got a priority of one over here.
Send a task to priority of one as well, OK?
And we're going to create a receiver task with a higher priority.
We've created a receiver task once that is done, we going to start our scheduler, lest we forget.
We start the show, OK, so then we only have to deal with our task functions.
Now I'm going to create the task function for the first and the task as simple as this V task one,
because that's the name we said we given the send task one task function and we're going to declare
the amount of time to wait.
We're going to say wait.
Four hundred Ms.
We're going to see, OK, this the amount of time you should block with four hundred Ms.
And we're going to define the data to say and remember, we said our cue is going to be send in character
pointers.
So we're going to say, OK, send MSG, MSG message from V. Task one.
OK.
Once that is done, we going to open our infinite loop over here.
And we're going to see wait for them is by putting it in the blog states four hundred Ms.
So we're going to save TASC.
V. Task DeLay, one hundred M is OK, and then once that is done, we're going to send it.
So we're going to send our MSgt to one like this Kyuss and we send into Q1 address of MSgt, we put
zero here, OK, for the takeaway timeout, OK, once that is done, we going to copy this.
This is V tasc one and then paste it over here to get V task to.
Over here and over here, the message is going to be message from send a task to and I'm going to make
this one wait for two hundred Ms.
OK.
And over here, we send in this information to task to Q2, sorry, OK, so, so far so good.
We are using just cuz we've not written anything with regards to Cusato yet.
OK, so it's in the receiver task that we find the the use and the benefit of the queue sits.
We're going to come down here to create the task function for our receiver task.
We first start off by declaring a Q variable to hold the the AQ Hondo variable, because what is going
to happen is our Q set is going to return the handle of the Q that has new data.
So we need to store it somewhere.
We declare this excuse that contains data as the name of the variable to hold the Q and then we're going
to have a character pointer as well for the data because our Qs data type is character pointer.
OK, so then we're going to open our infinite loop over here, I'll say.
Well one open and close.
And then we're going to use the function excuse selects from set, then we pass the cue sets and then
we delete infinitely.
OK, so we see excuse.
Select from set and then.
This function were returned, accuses the House, new data and storage in a.
Khuda content states are variable here.
OK.
Or minimize this.
OK.
So we are blocking here indefinitely until they're secured data.
So that's why we're using Portsmouth's delay here, we blocking for an infinite amount of time, essentially
maximum delay.
And then when there is data, when Cuba's new data then is going to be returned and stored in our variable
here.
OK, so now that we have the handle of the KHUDA has new data, then we can use our Q API to receive.
So we use our curacy function excusive function and we simply pass the handle of the Q that we want
to receive from and then we store it over here.
OK.
And once that is done, we can print the results.
I can simply say printf.
The content of this.
OK, like this.
So that is it, so that's the essential part our accused use uses excuse select from set.
You pass the cue set on those arguments and take wait time, OK?
And then this function is going to get stuck here or is going to wait here until there is a queue in
the queue sets that has new data.
When that happens, the handle of that queue is going to be returned and stored in our variable and
we're going to use the handle.
I commend to our curacy function to receive data from its.
OK, so all we have to do.
Descender function, prototypes of our task functions to the top over here.
This is the one for senator, one task and then send to we need the last one for the receiver to ask.
Grab this over here, put this over here.
OK, so we're looking good, no, let's build and see what we have.
I'm going to explain this.
And then I'm going to right click over here, I'll see Build Project.
Like this.
And then I'll explain this a bit so that we can see the progress.
It says it's built successfully.
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.
I'll double click on 17 click.
OK, over here.
And it's flashing onto the board.
I see we still have real time here.
This is from our previous project, I'm going to clear this, I'm going to open the port.
I'm going to press the reset to my board to see real time, it's not opening.
Let's see.
The last time we had that, there was an anomaly in the code.
Let's see if we have similar issues.
I don't think we have any such issues today.
So let's inspect our code to see where we may have anomalies, so we started off over here by creating
two Qs.
And storing them in their handles and then we added these two accused to our Cusato known as Cusato,
whose handle this year.
OK, the issue is we didn't agree to discuss it, so we just declared its Hondo.
We've not created it.
Right.
So we have to create accuses.
I'll come over here and we just use the excuse to create set function.
To critics, it's like this, OK?
So this Cusato is going to hold to Kyuss HQ has a single element.
OK, also, one other thing we're going to do is I'm going to be printing something here so that whenever
we have an issue, a list.
We can eliminate the cause being that you add to our print system initializing whenever we start.
So that when we see this get printed, we know this, that you are just fine.
OK, so we're looking good and then yeah, the stock size looks fine.
When I scroll down here and over here, we can simplify it.
We need not.
We can just see a character pointer should be fine.
This is in to we do the same for task one.
OK, and then over here in print, if I'm going to see percentages, when you give the specify a percentages,
print this string.
Yeah, this string could.
Yes, here.
OK, let's see whether this will get us running.
I'll click over here to build.
It's built successfully.
All right, click over here.
Run us SDM 30 to.
Double click number 17 over here.
It's downloading onto the board.
It's finished downloading, I'm going to open real to.
OK, you know, we have real time.
I'm going to clear, as can see, a message from V Task one V. Task to oppose.
So we have.
Send a task to send a task, one task, one task to task, one task, one task to the reason why we
have task one more than task to of course, you would realize that we put in one of the senders for
a longer time in the blocked state.
Task to entice block states for two hundred Emmis, whereas task one enters for one hundred.
So that is why Task one is having more time.
That's why I want to send in more than task, too.
But this is a this is how to use it.
So whichever has new data to use, it will return the handle of the queue and then we can use the handle
to receive from the Q and use the data as we wish.
So this or the risk for this lesson, if you have any questions, leave them in the questions analysis
area and I shall see you later.
Have a nice the.