1
00:00:00,870 --> 00:00:02,020
Hello, welcome back.

2
00:00:02,040 --> 00:00:07,830
This lesson, we're going to see how to resume a suspended task, I'm going to make a copy of the last

3
00:00:07,830 --> 00:00:12,830
project from the controversy to copy and paste over here.

4
00:00:14,610 --> 00:00:16,260
I've changed this to number nine.

5
00:00:22,360 --> 00:00:23,500
Resuming at task.

6
00:00:28,160 --> 00:00:29,900
OK, I'm going to open this.

7
00:00:35,570 --> 00:00:44,240
OK, so we have three tasks of the same priority level in our previous project where we did this in

8
00:00:45,440 --> 00:00:48,100
in in red task, we suspended blue.

9
00:00:48,620 --> 00:00:51,800
What I'm going to do is now I'm going to make red suspend itself.

10
00:00:52,610 --> 00:00:52,970
Right.

11
00:00:52,990 --> 00:00:56,590
So just to show you how to make a task, a task suspended.

12
00:00:56,600 --> 00:01:03,110
So our personnel here and for those of you who did the assignment, you were able to do this, OK,

13
00:01:03,110 --> 00:01:10,820
so we're going to make Red suspend itself and then we're going to let, let's say, green resume red.

14
00:01:12,340 --> 00:01:18,910
Right, so once read suspense itself, I'm going to I'm going to have a like I'm going to have a flag

15
00:01:18,910 --> 00:01:22,750
that tells us what a task is suspended or resumed.

16
00:01:23,110 --> 00:01:28,300
I'm going to cut this that we have over here and put out a top, OK?

17
00:01:29,590 --> 00:01:34,770
And then I'm also going to create a resume monitor, just like we have suspend monitor.

18
00:01:35,620 --> 00:01:37,360
I'm going to have resume monitor here.

19
00:01:42,160 --> 00:01:47,500
And then I'm also going to have a boolean called suspended.

20
00:01:52,070 --> 00:01:54,170
I call this is suspended.

21
00:01:57,810 --> 00:01:59,160
Initialize this to force.

22
00:01:59,850 --> 00:02:05,910
OK, so what's going to happen is when we come in here, you know what, Red?

23
00:02:07,330 --> 00:02:15,090
No air raid controller task when suspend monitors greater than 50, we're going to see suspended because

24
00:02:15,090 --> 00:02:18,670
the truth was we would suspend over here.

25
00:02:21,770 --> 00:02:22,330
OK.

26
00:02:23,810 --> 00:02:25,190
So this is key, right?

27
00:02:25,640 --> 00:02:31,670
So check this, if we put suspended Ecorse through here, this becomes unreachable because this very

28
00:02:31,670 --> 00:02:36,880
line here would terminate this entire thread function, so this one to run.

29
00:02:37,580 --> 00:02:40,340
So what we have to do is put it.

30
00:02:41,540 --> 00:02:47,420
Before we actually suspend its OK, suspend the costume like this.

31
00:02:49,770 --> 00:02:55,290
And perhaps we would wish to reset this or spend money to so set it to zero here.

32
00:02:57,860 --> 00:02:58,340
OK.

33
00:02:59,400 --> 00:02:59,850
Right.

34
00:03:00,870 --> 00:03:08,730
So then what are we going to do is we're going to come to green this and green threat, al green threat,

35
00:03:08,740 --> 00:03:17,340
it's going to check if the if suspended flying is set to try to come over here and see if it's suspended.

36
00:03:20,090 --> 00:03:24,900
Then we want to increment our our resume monitor.

37
00:03:25,640 --> 00:03:30,360
So let's say we want to wait for a while to resume, right.

38
00:03:30,620 --> 00:03:31,850
So we say resume.

39
00:03:33,760 --> 00:03:34,480
Monitor.

40
00:03:36,740 --> 00:03:39,560
Plus, plus, then we're going to see if.

41
00:03:43,620 --> 00:03:51,450
Resume monitor is greater than, let's say, greater than or equal to 30.

42
00:04:04,300 --> 00:04:06,990
If you wanted to screech, I don't know, you got 30.

43
00:04:08,220 --> 00:04:09,400
Let's make sure our.

44
00:04:12,230 --> 00:04:13,550
We're missing one race.

45
00:04:17,080 --> 00:04:21,220
OK, if this is greater than or equal to 30, what we want to do is.

46
00:04:22,960 --> 00:04:24,490
We want to resume.

47
00:04:25,750 --> 00:04:28,810
Red, which suspended itself, so I'm going to have to ask.

48
00:04:30,980 --> 00:04:33,830
Resume read Hando.

49
00:04:39,050 --> 00:04:41,450
And then resume.

50
00:04:43,230 --> 00:04:45,360
Monita, we're going to set to resume monitor.

51
00:04:48,290 --> 00:04:53,690
Equals zero, and then we're going to set it suspended back to force.

52
00:04:58,600 --> 00:05:04,960
OK, so then you may wonder how come this time where we are assuming we didn't put it as the last line

53
00:05:04,960 --> 00:05:09,100
in the block, but when we were suspended, we made sure we placed this at the last line.

54
00:05:09,550 --> 00:05:16,240
The reason is that when we resumed this, when we resume read, this blog is going to continue running

55
00:05:16,540 --> 00:05:18,790
because Red has the same priority.

56
00:05:20,200 --> 00:05:24,790
I scream, so when we resume read is pull back at the back of the queue.

57
00:05:25,710 --> 00:05:32,700
Ta ta ta run doesn't interrupt this if Fred had a greater priority than green and as soon as we resume

58
00:05:32,700 --> 00:05:35,920
it, it's going to assume the the the running time.

59
00:05:36,560 --> 00:05:38,650
OK, so that's the difference here.

60
00:05:39,960 --> 00:05:42,780
So let's wait and see what we've got a click over here to build.

61
00:05:44,610 --> 00:05:46,980
OK, we've gone through some of it, but as I say.

62
00:05:48,580 --> 00:05:51,370
Multiple markets this point, but as I see.

63
00:05:52,400 --> 00:05:53,390
It's suspended.

64
00:05:57,060 --> 00:05:58,950
Let's see the name of our global frebel.

65
00:06:02,110 --> 00:06:03,410
OK, OK, OK.

66
00:06:08,640 --> 00:06:11,250
So perhaps we may need to include.

67
00:06:17,150 --> 00:06:17,960
Come over here.

68
00:06:21,510 --> 00:06:21,800
The.

69
00:06:24,090 --> 00:06:29,010
They include SDD H.

70
00:06:31,290 --> 00:06:32,520
They're not quick to run.

71
00:06:34,960 --> 00:06:41,440
OK, the arrest disappeared, I'll get onto the boat by clicking here we are at number nine.

72
00:06:43,350 --> 00:06:44,400
OK, over here.

73
00:06:50,300 --> 00:06:51,200
Click here to switch.

74
00:06:52,820 --> 00:06:55,310
And I'm going to suspend monitor.

75
00:06:56,620 --> 00:07:03,490
Or resume monitor, a copy machine monitor added to our live expressions when the hits enter.

76
00:07:03,970 --> 00:07:05,080
So let's observe the.

77
00:07:06,690 --> 00:07:09,630
So what is the what is the configuration here?

78
00:07:10,050 --> 00:07:10,910
Let's go through it.

79
00:07:11,280 --> 00:07:12,510
We said when we start.

80
00:07:15,280 --> 00:07:21,550
Red is going to be suspended, Red will suspend itself after suspend monitor reaches 50.

81
00:07:22,550 --> 00:07:30,310
And then once that happens, resume monitor will start monitoring when the time is right to resume.

82
00:07:30,590 --> 00:07:37,400
So as soon as Red goes into suspension, resume wanted to start counting and then resume when it reaches

83
00:07:37,400 --> 00:07:37,940
30.

84
00:07:38,180 --> 00:07:39,560
Redubbed resume.

85
00:07:39,890 --> 00:07:40,280
Resume.

86
00:07:40,280 --> 00:07:41,060
Wanted to hear.

87
00:07:43,490 --> 00:07:49,810
Would make sure red is resumed and then Red goes back to execute until its reaches 50 again and then

88
00:07:50,540 --> 00:07:54,060
resume when it kicks back in and then it continues like that.

89
00:07:54,400 --> 00:07:59,810
I'm going to click here to run, as you can see, resume Moniteau Zero because Red hasn't suspended

90
00:07:59,810 --> 00:08:00,140
yet.

91
00:08:00,350 --> 00:08:01,370
Everyone is running.

92
00:08:01,370 --> 00:08:02,780
All the tasks are running.

93
00:08:03,290 --> 00:08:08,010
Suspend Monitor is running its race in here, so spend money to hits 50 now.

94
00:08:08,030 --> 00:08:09,710
Resume Monitor is calculating.

95
00:08:09,830 --> 00:08:10,880
The red is frozen.

96
00:08:10,880 --> 00:08:13,310
Red is not running anymore, ok.

97
00:08:13,370 --> 00:08:17,980
Red has woken up because as you monitor just hit 30.

98
00:08:18,820 --> 00:08:20,270
OK, let's see that again.

99
00:08:23,000 --> 00:08:25,520
OK, resume monitor has resumed.

100
00:08:29,830 --> 00:08:30,370
OK.

101
00:08:32,480 --> 00:08:32,950
Right.

102
00:08:33,080 --> 00:08:34,100
So that's all there is.

103
00:08:34,250 --> 00:08:36,660
Do you have any questions with regards to this?

104
00:08:37,340 --> 00:08:41,780
Just let me know in the questions and answers area if you have any feedback.

105
00:08:42,540 --> 00:08:44,630
Um, just let me know as well.

106
00:08:44,640 --> 00:08:49,250
And if you find any course useful, take some time off to leave a review or some feedback.

107
00:08:49,400 --> 00:08:50,210
I'll see you later.

108
00:08:50,240 --> 00:08:50,840
Have a nice day.
