1
00:00:00,550 --> 00:00:01,640
Hello, welcome back.

2
00:00:01,660 --> 00:00:09,700
In this lesson, we go going to see how to resume a thread just like we saw in our native free ARTUS

3
00:00:09,700 --> 00:00:10,780
API lessons.

4
00:00:11,080 --> 00:00:12,580
So we suspended a thread.

5
00:00:12,580 --> 00:00:15,620
We created this global variable here called Suspend Monitor.

6
00:00:15,880 --> 00:00:18,220
I'm going to cut this and bring it to the top.

7
00:00:19,330 --> 00:00:23,380
And I'm going to also create two other variables.

8
00:00:23,860 --> 00:00:28,280
We would have one code resume monitor in another one called suspended.

9
00:00:28,330 --> 00:00:31,590
This will be set to true if it's suspended or not.

10
00:00:31,900 --> 00:00:35,620
It starts off as false because we've not suspended a thread yet.

11
00:00:36,370 --> 00:00:42,280
OK, and to use the Boolean, we need to include SDD Booth H, otherwise we'll receive an error.

12
00:00:43,380 --> 00:00:46,710
So I'm going to include that age over here.

13
00:00:48,020 --> 00:00:53,880
OK, so we have these variables, so spend money to resume monitor suspended.

14
00:00:54,240 --> 00:00:58,740
OK, so let's go back to the bit where the task gets suspended.

15
00:00:59,100 --> 00:01:03,070
The red a little controller task is the one doing the suspension.

16
00:01:03,480 --> 00:01:07,440
So what happened is we kept incrementing suspend monitor.

17
00:01:07,440 --> 00:01:19,230
And when it became greater than when it became greater than we call it 49, we we suspended blue.

18
00:01:23,960 --> 00:01:28,670
This is a confusing way of writing it, rather than, say, greater than or equal to, I'll simply say,

19
00:01:28,670 --> 00:01:30,830
if it is equal to 50, suspend.

20
00:01:31,990 --> 00:01:37,250
So equal to, equal to and then 50 here, OK?

21
00:01:38,050 --> 00:01:44,650
So we are familiar with this next one we want to do is we want to set the flag suspend flag.

22
00:01:45,620 --> 00:01:51,770
Before we suspend blue, actually, we want to suspend flights here to try to indicate that, OK, we've

23
00:01:51,770 --> 00:01:55,700
suspended and we want to reset the suspend monitor to zero.

24
00:01:56,760 --> 00:01:57,330
OK.

25
00:02:00,520 --> 00:02:01,120
Like this.

26
00:02:01,490 --> 00:02:11,890
OK, so then we're going to have the Orange Thread Monitor for resumption the orange thread over here,

27
00:02:11,920 --> 00:02:18,900
which is below here, is going to also check if suspend is such a true.

28
00:02:18,940 --> 00:02:29,860
So over here, like we did earlier, we say if unaskable suspend it, we open and close it, suspend

29
00:02:29,860 --> 00:02:34,000
it, then we start counting for the time we ought to resume.

30
00:02:34,450 --> 00:02:41,260
And we do this by increments and the resumption the resume monitor and we can see if resume monitor

31
00:02:42,040 --> 00:02:45,610
equals two hundred, then we want to resume.

32
00:02:45,640 --> 00:02:55,660
So over here, just like we did earlier, I can see if resume monitor equals two hundred, then we want

33
00:02:55,660 --> 00:02:59,770
to call our always threat resume function.

34
00:03:02,090 --> 00:03:06,110
Two, we can call it to resume the blue thread, OK?

35
00:03:07,190 --> 00:03:12,560
And we also have to reset our resume monitor and said suspend back to force.

36
00:03:13,070 --> 00:03:13,570
OK.

37
00:03:16,140 --> 00:03:21,060
And of course, we can use semaphores to achieve this, but we using our own control variables.

38
00:03:21,960 --> 00:03:27,510
OK, so this what we have, let's build and see where we get a click over here to build.

39
00:03:29,100 --> 00:03:29,820
It's building.

40
00:03:32,380 --> 00:03:33,910
It's built successfully.

41
00:03:35,050 --> 00:03:37,030
I'm going to right click over here.

42
00:03:37,920 --> 00:03:39,480
And debuggers.

43
00:03:40,660 --> 00:03:42,310
Estimated to cortex in.

44
00:03:43,310 --> 00:03:45,350
iSelect, 38 Aubagio.

45
00:03:47,440 --> 00:03:48,850
And OK.

46
00:03:53,970 --> 00:03:54,720
It's open in.

47
00:03:56,840 --> 00:03:57,410
Switch.

48
00:04:03,050 --> 00:04:05,120
It's loading, and then I'll click to run.

49
00:04:09,190 --> 00:04:11,670
Something happened, live expressions, see?

50
00:04:17,100 --> 00:04:18,490
OK, something happened.

51
00:04:18,510 --> 00:04:19,650
I'm going to stop this.

52
00:04:19,830 --> 00:04:22,830
Let's go back in our collective book.

53
00:04:31,000 --> 00:04:32,170
Switch over here.

54
00:04:37,970 --> 00:04:44,480
OK, I'm going to click here to run, we see all of them incrementing as soon as we hit fifty one.

55
00:04:47,100 --> 00:04:49,080
Blue task is frozen.

56
00:04:52,510 --> 00:04:58,330
And then let's see, did he ever get resumes so it gets resumed quickly and then it's incremented by

57
00:04:58,330 --> 00:04:58,630
one?

58
00:05:00,520 --> 00:05:04,240
OK, and if we want to observe further, we can.

59
00:05:05,720 --> 00:05:07,610
We can add our suspend monitor.

60
00:05:10,290 --> 00:05:14,050
Also, spend money to and resume monitors, we can add them over here.

61
00:05:15,450 --> 00:05:16,740
This is resume monitor.

62
00:05:17,700 --> 00:05:19,050
This is suspend monitor.

63
00:05:20,340 --> 00:05:21,990
OK, so let's run.

64
00:05:23,050 --> 00:05:26,230
OK, resume monitor as soon as it hits two hundred.

65
00:05:27,560 --> 00:05:35,180
The task resumes, OK, so it's working as expected and of course, we've seen this before, so we expected

66
00:05:35,330 --> 00:05:37,550
nothing apart from this.

67
00:05:38,060 --> 00:05:38,870
That's all there is.

68
00:05:38,910 --> 00:05:39,740
I'll see you later.

69
00:05:39,770 --> 00:05:40,510
Have a nice day.
