Hello.
Welcome back.
OK.
So let's go to a new threat, threat three, and we are going to, um, we're going to add that also
to these threats for sending the four taken and sending the message.
Basically, we're going to let it take, Becky.
The key to the restroom and also be able to use the restroom, which is that you are out in our story.
So using the same new text, we can use this as well.
I'm going to copy this book over here and then paste it in our new thread, which is thread three.
I'm going to comment this out.
Patients over here.
And, um, we're going to send a message.
This message is going to be hello from threat to three.
Going to come up here.
And I know I'll say hello from three to three, right?
And they know where to put the same amount of delay, which is tenements.
So now we have hello from thread one, thread two and thread three.
And then.
Put this over here like this.
Okay, let's put and see what we have.
Click over here to build.
Putin.
To build successfully.
And then click to debug.
It's loaded, okay?
We use in terror time in this experiment.
So I'm going to exit this quick over here to come out of it and I'll come over here to a term, then
select this three sort of baud rate to the appropriate value.
This one over here.
And then, OK, click away to reset.
OK, we get in a bit of a conflict.
Lizzie.
And yet it's understandable why we should get this, OK?
So what happens is the threats have the same priority.
So if one threat has the key and the threat.
Right.
Loses the key.
The other two threats, stop fighting for a key.
So in a way, that is what creates this, um, this issue with a you.
So when we have just two threads, one releases the key data, one just picks it up and then uses the
key.
But now we have two threads waiting.
And they both have the same priority.
So it's the one the other one believes is the key.
No one is ahead of the other.
The key is dropped.
And then there is there's a conflict for who gets the key.
That is I think that is what is manifested into the in the second one.
It's up this way.
But anyway, this is not the experiment we run in here that we can synchronize the threat further to,
um, to let this arm.
To let all of them work peacefully.
We can, um.
We can do that.
But that's not experiment.
We're going to see how to notify.
Between threats.
And furthermore, actually, we can um.
Uh, a simple issue will be to reduce that learmount between the threat.
So that do all work peacefully.
Uh, a proper issue is to apply another form of synchronization between the threats.
Well, let's go ahead and look at notification.
I'll leave this for you as an assignment.
If you if you've not found a way to make them more, you know what?
Peacefully, then, um, leave it.
And the questions and answers area.
Why should it be an issue?
Let's see how to create notifications.
So we are going to notify thread number three from thread to using the, um, the push.
But we was so when we pressed when we pressed the push button, which is often which is going to be
read into it to a notification should be sent to thread three to use the, um.
You ought to transmit its message, which is greetings from threat three.
So let's do that.
So I'm going to enable the, um, the push button and thread to again, um, this is what we did.
I'm gonna come over here and then remove the comment and then, um, we can.
No, I'm just gonna fetch all of this.
This is how a.
You quote using them UTX.
Cut this.
And then our place in here.
So to, um, to send a notification, we need to use the, um, the task notify function.
Come over here and say X task.
Notify the first argument is the.
It's the task you want to notify.
And you have to pass the task on the.
Remember the task on the list, like the idea of each task.
We want to notify Task three.
We need to task 300.
Copy.
Task or threat three from.
Yeah.
Come down here.
Post this over here.
The second argument is a flag that we can set, we can, um, there's a range, I think, you know,
eight others up to eight PYT range of flags that we can set.
This flag would be used to identify the notification.
I'm going to set E X zero one and then I'm going to pass E set bit.
So there are ways of notifying you can either set pits or disable it.
So here we are set in bits.
So our pass is set said bits.
Yeah.
So we send in the notification to thread three three three.
We have to wait for the notification to arrive.
So I'm going to go to thread three words or thread three.
This is to reach over here.
And in here we are going to use the next task.
Notify wait.
Function say X task.
Notify wait and then pass PD force over here.
And it's your X, F, f.
And then at five value.
And then PD Mux delay of port must delay.
So we passed this here because we don't want it to reset the flags upon entry.
And this one here resets all the flags before leaving.
So upon entry, do not reset the flags and here reset the flags when leaving and the notify value.
Here's the value that will be received.
And this is what would we would use to confirm this is the notification we want.
And postmarks delay means wait indefinitely for this notification to arrive if we don't use postmarks
delay.
And we use that time such as 5:00 a.m., as it can wait for five a.m., as if the notification doesn't
arrive.
It would proceed to execute the other lines of code.
But here we are saying wait indefinitely.
So we have to define notify value here.
So you inferred you this underscore to.
That's Five-fold.
So, um, this variable here would have the notification value, you would have it.
So we basically would declaring an empty verbal to start the notification value.
And we've got to check the notification value if it's the one we're waiting for.
And we can use the end, um, the logical end to do this.
We can say if if notified value contains or our expected value.
So I'll say if over here.
And say, and your ex sure won because you can have notification coming from different tasks.
If this is three quarters of zero.
Right.
If that's the case, then we can know it's the right notification, we can, um, transmit our data.
Or just cut this and put it in the.
Right.
So we will received a notification because remember when we said send notification, we added this threat
threat 3s, thread I.D. would that notification would arrive.
And we confirm if this or X were one, then this is the notification that tells us to go ahead and use
the U.
We can have another notification coming from another thread, and that could be through extra, too.
And we can check if it's so X to do this other action.
Right.
So what does this thread, too?
I'm going to make sure that notification is sent when we press the button.
So I'm going to cut this over here.
The task notify function.
I'm going to put it here.
This is the action that we take when the pattern is pressed.
So won't the button is pressed.
We want to do two things.
We want to send notification to thread three, as well as print our threat to message.
But this is not really relevant here.
OK.
But we can keep it.
And then let's Putin see what we have.
Let's hope we have no errors.
OK.
We've got no arrow.
Let's get onto the board.
Click over here.
It's downloaded.
Download in.
OK.
It's downloaded.
Going to escape by coming out of it.
I'm going to terror attempt to see where we have.
AK.
When I select the port, this one over here, then I set the board rate to the appropriate value.
This one over here, we have Cretans from threat one.
As see, as I pressed the button, we see Cretans from threat three and threat to let me just increase
the font size so that we all see what we see properly.
It's open in.
A select 14 here.
Then I'm going to use this one.
See the council.
OK, so this is it.
Greetings from threat one.
The Botin is not prest.
So I'm going to select 14 over here and then use this font.
And now it's bigger.
OK.
So this is third one only sent.
Remember, we only send a message from three to when the button is pressed and at the same time we send
a notification as well.
So the button is no press.
No, I'm going to press the button.
You can see we find greetings from Threat three and then greetings from threat to us.
Well, right.
Because of what we are Twyning threat to.
OK.
So in threat number two, just to point out.
When a botanist press, we send a notification and then we print out what threat to message.
And when we send a notification threat, three receives the notification.
And then it's printed message.
So this weather is this is how to send notification between friends or even amongst threats.
I advise you to, um, experiment more, try to send a notification coming from threat one as well.
And then check that is the right notification.
Just give it a different notification value and then take an appropriate action.
That's all there is.
I'll see you later.