Hello, welcome back.
In this lesson, we're going to see how to block a task writes.
I'll copy the Lost Project.
Or actually, I'll copy an earlier one.
Let's see, we copy one of the earlier ones, I copy TASC Priority.
Copy this.
And then paste over here.
And then I renamed this to know Martin.
Blocking the task, you would wonder, why do we need to block the task?
I would explain.
OK, here we go.
Yes, number 10, OK.
Open this right, so.
A task is either running or not running.
We have to run in states, a task which is in the running states is ready to run.
Maybe it's not got to its turn, but it is ready to run and not run in states.
There is a state in there or a sub state of not running known as the blocked state and this blocked
state.
That task may be blocked because of something it is waiting for.
A task is blocked when it's waiting for an event and this event can be a resource token or at time event.
So the resource token can be a SEMAFO and you can think of a SEMAFO as a key.
So when this happens, when the task requires an event to occur or a resource to be available before
it continues its execution, it is placed in a blocked state.
This type of block to states that we shall see now is going to be the block states.
In which that time waits for a time U.S..
This type of block states that we shall see now is going to be the block states in which the task waits
for a tiny things to occur.
So in effect, we shall see how to use that task delay function.
So delay basically means wait for this particular amount of time.
So delay wait for a timeout event so we shall see how to block tasks using the delay function.
OK, so this is the project.
Let's see.
We created three tasks here.
All of them have the same priority.
OK, so if your copy hasn't to tasks with the same priority, I'm sure you have three tasks, all of
them with the same priority.
OK, and then.
We have the task functions here, what we're going to do is we go into the field task, delay function
V task, delay function takes takes as equipment.
Right.
So because we're not used to saying delay for this amount of takes, we're used to seeing how much time
that delay show careful.
Because of this, there is a macro which allows us to convert our time value into ticks.
So what I'm going to do is I'm going to come over here or create this constant, I say constant, and
this is off tick type.
And then I'll call this variable.
Score 50 times and together 50 times, I'm going to use the PD, EMS to tick's function.
And over here or past 50.
So this function is going to return the amount of ticks required for 50 miles and it's going to straighten
this variable for me.
OK, so what I'm going to do is I'm going to go to all of our task functions and then I'll let one of
them delay for what time is, let's say red.
I'll save task.
DeLay underscore school tm's.
OK, so let's see how that works.
Click here to build.
And then click here to go to debug.
A select number 10 over here.
OK, over here.
uSwitch.
These ones do not exist because this project has got these.
This global variables.
I'm going to click here to run, as you can see, Red is not running as much as the others because red
has this delay.
Red is often blocked.
Is blocked for 50 times because of this, so this is the blocked states rights, so this is precisely
if you want to precisely this is the way to achieve that.
OK, so this or the risk, this or the risk for this lesson and I'll see you in the next lesson, have
a nice day.