1
00:00:00,620 --> 00:00:01,800
Hello, welcome back.

2
00:00:01,820 --> 00:00:06,830
In this lesson, we're going to see how to block a task writes.

3
00:00:09,110 --> 00:00:11,120
I'll copy the Lost Project.

4
00:00:12,010 --> 00:00:14,560
Or actually, I'll copy an earlier one.

5
00:00:15,310 --> 00:00:19,960
Let's see, we copy one of the earlier ones, I copy TASC Priority.

6
00:00:20,140 --> 00:00:20,800
Copy this.

7
00:00:22,300 --> 00:00:23,860
And then paste over here.

8
00:00:25,380 --> 00:00:27,540
And then I renamed this to know Martin.

9
00:00:34,250 --> 00:00:37,650
Blocking the task, you would wonder, why do we need to block the task?

10
00:00:38,120 --> 00:00:39,070
I would explain.

11
00:00:40,770 --> 00:00:41,970
OK, here we go.

12
00:00:44,640 --> 00:00:45,970
Yes, number 10, OK.

13
00:00:47,560 --> 00:00:49,990
Open this right, so.

14
00:00:51,420 --> 00:00:53,650
A task is either running or not running.

15
00:00:53,670 --> 00:00:58,660
We have to run in states, a task which is in the running states is ready to run.

16
00:00:59,160 --> 00:01:05,040
Maybe it's not got to its turn, but it is ready to run and not run in states.

17
00:01:05,070 --> 00:01:11,640
There is a state in there or a sub state of not running known as the blocked state and this blocked

18
00:01:11,640 --> 00:01:12,090
state.

19
00:01:12,780 --> 00:01:17,070
That task may be blocked because of something it is waiting for.

20
00:01:17,880 --> 00:01:25,050
A task is blocked when it's waiting for an event and this event can be a resource token or at time event.

21
00:01:26,100 --> 00:01:30,600
So the resource token can be a SEMAFO and you can think of a SEMAFO as a key.

22
00:01:32,680 --> 00:01:40,210
So when this happens, when the task requires an event to occur or a resource to be available before

23
00:01:40,210 --> 00:01:44,380
it continues its execution, it is placed in a blocked state.

24
00:01:45,610 --> 00:01:49,600
This type of block to states that we shall see now is going to be the block states.

25
00:01:50,720 --> 00:01:53,390
In which that time waits for a time U.S..

26
00:01:54,340 --> 00:01:59,890
This type of block states that we shall see now is going to be the block states in which the task waits

27
00:01:59,890 --> 00:02:01,550
for a tiny things to occur.

28
00:02:02,350 --> 00:02:06,200
So in effect, we shall see how to use that task delay function.

29
00:02:06,610 --> 00:02:11,550
So delay basically means wait for this particular amount of time.

30
00:02:12,370 --> 00:02:18,220
So delay wait for a timeout event so we shall see how to block tasks using the delay function.

31
00:02:18,670 --> 00:02:22,330
OK, so this is the project.

32
00:02:23,410 --> 00:02:23,980
Let's see.

33
00:02:24,280 --> 00:02:26,110
We created three tasks here.

34
00:02:26,710 --> 00:02:28,600
All of them have the same priority.

35
00:02:34,410 --> 00:02:42,540
OK, so if your copy hasn't to tasks with the same priority, I'm sure you have three tasks, all of

36
00:02:42,540 --> 00:02:44,160
them with the same priority.

37
00:02:44,460 --> 00:02:46,110
OK, and then.

38
00:02:47,950 --> 00:02:56,500
We have the task functions here, what we're going to do is we go into the field task, delay function

39
00:02:57,040 --> 00:03:01,050
V task, delay function takes takes as equipment.

40
00:03:02,080 --> 00:03:02,520
Right.

41
00:03:03,010 --> 00:03:09,940
So because we're not used to saying delay for this amount of takes, we're used to seeing how much time

42
00:03:09,940 --> 00:03:11,140
that delay show careful.

43
00:03:12,120 --> 00:03:17,760
Because of this, there is a macro which allows us to convert our time value into ticks.

44
00:03:18,600 --> 00:03:26,100
So what I'm going to do is I'm going to come over here or create this constant, I say constant, and

45
00:03:26,100 --> 00:03:27,570
this is off tick type.

46
00:03:30,250 --> 00:03:31,780
And then I'll call this variable.

47
00:03:33,210 --> 00:03:41,310
Score 50 times and together 50 times, I'm going to use the PD, EMS to tick's function.

48
00:03:44,890 --> 00:03:46,720
And over here or past 50.

49
00:03:47,450 --> 00:03:55,900
So this function is going to return the amount of ticks required for 50 miles and it's going to straighten

50
00:03:55,900 --> 00:03:56,860
this variable for me.

51
00:03:57,620 --> 00:04:04,780
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

52
00:04:04,780 --> 00:04:06,940
them delay for what time is, let's say red.

53
00:04:07,330 --> 00:04:08,500
I'll save task.

54
00:04:10,860 --> 00:04:15,000
DeLay underscore school tm's.

55
00:04:17,520 --> 00:04:20,130
OK, so let's see how that works.

56
00:04:20,280 --> 00:04:22,200
Click here to build.

57
00:04:26,570 --> 00:04:29,090
And then click here to go to debug.

58
00:04:30,390 --> 00:04:32,100
A select number 10 over here.

59
00:04:33,210 --> 00:04:34,230
OK, over here.

60
00:04:38,870 --> 00:04:39,500
uSwitch.

61
00:04:44,650 --> 00:04:47,950
These ones do not exist because this project has got these.

62
00:04:48,940 --> 00:04:50,200
This global variables.

63
00:04:52,210 --> 00:04:58,510
I'm going to click here to run, as you can see, Red is not running as much as the others because red

64
00:04:58,510 --> 00:04:59,400
has this delay.

65
00:04:59,440 --> 00:05:00,640
Red is often blocked.

66
00:05:02,000 --> 00:05:09,500
Is blocked for 50 times because of this, so this is the blocked states rights, so this is precisely

67
00:05:09,680 --> 00:05:13,340
if you want to precisely this is the way to achieve that.

68
00:05:14,530 --> 00:05:19,780
OK, so this or the risk, this or the risk for this lesson and I'll see you in the next lesson, have

69
00:05:19,780 --> 00:05:20,160
a nice day.
