Hello, welcome back.
This lesson, we're going to see how to resume a suspended task, I'm going to make a copy of the last
project from the controversy to copy and paste over here.
I've changed this to number nine.
Resuming at task.
OK, I'm going to open this.
OK, so we have three tasks of the same priority level in our previous project where we did this in
in in red task, we suspended blue.
What I'm going to do is now I'm going to make red suspend itself.
Right.
So just to show you how to make a task, a task suspended.
So our personnel here and for those of you who did the assignment, you were able to do this, OK,
so we're going to make Red suspend itself and then we're going to let, let's say, green resume red.
Right, so once read suspense itself, I'm going to I'm going to have a like I'm going to have a flag
that tells us what a task is suspended or resumed.
I'm going to cut this that we have over here and put out a top, OK?
And then I'm also going to create a resume monitor, just like we have suspend monitor.
I'm going to have resume monitor here.
And then I'm also going to have a boolean called suspended.
I call this is suspended.
Initialize this to force.
OK, so what's going to happen is when we come in here, you know what, Red?
No air raid controller task when suspend monitors greater than 50, we're going to see suspended because
the truth was we would suspend over here.
OK.
So this is key, right?
So check this, if we put suspended Ecorse through here, this becomes unreachable because this very
line here would terminate this entire thread function, so this one to run.
So what we have to do is put it.
Before we actually suspend its OK, suspend the costume like this.
And perhaps we would wish to reset this or spend money to so set it to zero here.
OK.
Right.
So then what are we going to do is we're going to come to green this and green threat, al green threat,
it's going to check if the if suspended flying is set to try to come over here and see if it's suspended.
Then we want to increment our our resume monitor.
So let's say we want to wait for a while to resume, right.
So we say resume.
Monitor.
Plus, plus, then we're going to see if.
Resume monitor is greater than, let's say, greater than or equal to 30.
If you wanted to screech, I don't know, you got 30.
Let's make sure our.
We're missing one race.
OK, if this is greater than or equal to 30, what we want to do is.
We want to resume.
Red, which suspended itself, so I'm going to have to ask.
Resume read Hando.
And then resume.
Monita, we're going to set to resume monitor.
Equals zero, and then we're going to set it suspended back to force.
OK, so then you may wonder how come this time where we are assuming we didn't put it as the last line
in the block, but when we were suspended, we made sure we placed this at the last line.
The reason is that when we resumed this, when we resume read, this blog is going to continue running
because Red has the same priority.
I scream, so when we resume read is pull back at the back of the queue.
Ta ta ta run doesn't interrupt this if Fred had a greater priority than green and as soon as we resume
it, it's going to assume the the the running time.
OK, so that's the difference here.
So let's wait and see what we've got a click over here to build.
OK, we've gone through some of it, but as I say.
Multiple markets this point, but as I see.
It's suspended.
Let's see the name of our global frebel.
OK, OK, OK.
So perhaps we may need to include.
Come over here.
The.
They include SDD H.
They're not quick to run.
OK, the arrest disappeared, I'll get onto the boat by clicking here we are at number nine.
OK, over here.
Click here to switch.
And I'm going to suspend monitor.
Or resume monitor, a copy machine monitor added to our live expressions when the hits enter.
So let's observe the.
So what is the what is the configuration here?
Let's go through it.
We said when we start.
Red is going to be suspended, Red will suspend itself after suspend monitor reaches 50.
And then once that happens, resume monitor will start monitoring when the time is right to resume.
So as soon as Red goes into suspension, resume wanted to start counting and then resume when it reaches
30.
Redubbed resume.
Resume.
Wanted to hear.
Would make sure red is resumed and then Red goes back to execute until its reaches 50 again and then
resume when it kicks back in and then it continues like that.
I'm going to click here to run, as you can see, resume Moniteau Zero because Red hasn't suspended
yet.
Everyone is running.
All the tasks are running.
Suspend Monitor is running its race in here, so spend money to hits 50 now.
Resume Monitor is calculating.
The red is frozen.
Red is not running anymore, ok.
Red has woken up because as you monitor just hit 30.
OK, let's see that again.
OK, resume monitor has resumed.
OK.
Right.
So that's all there is.
Do you have any questions with regards to this?
Just let me know in the questions and answers area if you have any feedback.
Um, just let me know as well.
And if you find any course useful, take some time off to leave a review or some feedback.
I'll see you later.
Have a nice day.