L-1.5: Process States in Operating System| Schedulers(Long term,Short term,Medium term)
Estimated read time: 1:20
AI is evolving every day. Don't fall behind.
Join 50,000+ readers learning how to use AI in just 5 minutes daily.
Completely free, unsubscribe at any time.
Summary
This video by Gate Smashers delves into the intricacies of process states within operating systems, explaining the life cycle transitions that processes undergo from creation to termination. It covers primary states like ready, running, and waiting, and elaborates on schedulers—long-term, short-term, and medium-term—used in managing these states. The focus is on comprehending these concepts for academic and competitive exams, emphasizing the practical applications in systems like Windows and Linux.
Highlights
Process states explain a process's journey from start to end 🚀
Long-term scheduler's role in multiprogramming explained 🏗️
Short-term scheduler ensures CPU usage in running state 💡
Pre-emptive vs non-pre-emptive scheduling clarified 📊
Medium-term scheduler manages memory resources to prevent overload 💾
Key Takeaways
Understanding process states is crucial for exams 📚
Long-term schedulers load processes into memory 🧠
Short-term schedulers manage CPU execution 🖥️
Medium-term schedulers delay processes to manage resources ⏳
High-priority processes can pre-empt others 🚦
Overview
The journey of a process from inception to completion is akin to a roller coaster ride through various states, each with its own significance. The video starts by laying a strong foundation on what process states are and why they matter, especially for those gearing up for exams. It demystifies the model used to describe process life cycles, making complex ideas accessible and engaging.
Delving into the world of schedulers, the discussion moves to the realm of long-term schedulers, which are the unsung heroes that bring life to multiple processes by loading them into memory. Short-term schedulers come next, acting like the managers of a concert, ensuring each process gets its moment on the CPU stage, while balancing priority and efficiency.
Lastly, the video dives into the role of the medium-term schedulers, which step in when resources are stretched thin. They'll put processes on hold, swap them out, and bring them back, all in an effort to keep the system running smoothly. Real-world applications of these concepts are highlighted, drawing parallels with systems like Windows Task Manager and Linux's PS command.
L-1.5: Process States in Operating System| Schedulers(Long term,Short term,Medium term) Transcription
00:00 - 00:30 Hello friends... Welcome to Gate Smashers In this video we are going to discuss process states
or you can call it as process life cycle also And in this video we're going to discuss
all important points related to process states and life cycle that'll be beneficial for your competitive exams
even for your college\university level exams also so like the video quickly and subscribe the channel
if you haven't done until now and please press the bell button so
you can keep getting all latest notifications So let's start with something related to process states,
let me tell you first important point
00:30 - 01:00 if we'll talk in technical term, or you'd say
that kernal knows what are process states NO... This is a model created just to explain the user
that whenever we starts a process in our laptop, PC or mobile so in between from start to end, from which states it pass through
which of its status it changes so to understand this we've created
a model so you'll get an idea
01:00 - 01:30 that how process grows and moves from start to end so first we are talking about primary states here primary states means those which are mandatory
which are present by default so those are New, ready, running,
terminated and wait \ block other than this there are some additional states also
that we'll discuss further so first of all let's start with new state
New state means when we created the process Now creating a process means, that
let's suppose that you wrote a program in C language
01:30 - 02:00 Now right after writing let's suppose you stored it Right now you didn't run it, just stored it
means placed in secondary memory permanently Means it's staying in a stable state,
that's called a new state, or let's say you turned on an application You turned on Mozilla Firefox, or chrome,
or opened VMware in your laptop Or even if you turns on laptop, then by default
when your operating system gets mount in the memory
02:00 - 02:30 Then a lot of process starts running at the background
so in actual its a new state Means there was no process before that,
but now we created a new process right after creating we just poked it,
now it came in an active state, active state means ready state You can say ready state
or you can call it as ready queue also Ready queue means that
now that process came into RAM means now it came in faster memory,
before that it was staying stable
02:30 - 03:00 But the moment you poked it or turned it on now it came in ready state,
now it's staying in the RAM Now after coming in RAM, means here
it came in queue after first in, first out all these our process are coming in the queue but remember that there could be
many processes in the secondary memory Because we are considering
our secondary memory very big You can see these days your laptops are getting
secondary memory or hard disks of 1 terabits
03:00 - 03:30 that's more than sufficient... But... Talking about the RAM, then we have up to 4gb, 8gb.
Maximum we are using up to 16gb so here you can't bring
all processes in the ready state Out of all the "n" number of processes, Out of "n", we brings only
some no. of processes in the ready state but who brings these processes... it's long term scheduler who brings all the processes Yess... long term scheduler
and points related to scheduler,
03:30 - 04:00 I'm discussing all that in this video, because in next video
I won't tell any point related to it because all that will be covered in this same video Now what is the meaning or concept
of long term scheduler here the meaning is to bring
more and more processes in the ready state Which we call the concept of multi programming Multi programming means bringing
more and more concept in the ready queue I've already made a video
on what multi programming actually is And it's link is in the description box
Make sure to check it once
04:00 - 04:30 All the points that I'm using here
like multi programming, multi-tasking, you'll get its all detail there Now what we are trying is to keep bringing more and more process
in the ready queue or ready state Now after that... Let's suppose
we brought as much processes as possible Now what we have to do is
Our task is not to fill ready queue Now we have to execute those processes
Now every process wants to get CPU for some time
04:30 - 05:00 so it can get terminated after execution Now what we are doing is, now
all the processes that came in ready queue already we dispatched some of them from it Now what dispatch actually means,
or you can say we scheduled it we brought it in the running state Now how many processes
we'll bring in the running state This depends on how much CPU you have
05:00 - 05:30 Because running state means
we are executing that process Now we are providing it CPU to get executed But if you have uni processor system
then we have one CPU If you have multi-processor system, you have
grid computing or if you are using advance system then you can say you have multiple series
then you can use parallel processing But whatever syllabus of operating system we have at present,
we are assuming that we have uni processor system so you can say, out of
all the processes in the queue state,
05:30 - 06:00 means I just picked out one
from those which are in ready state And I scheduled and dispatched
that one on the CPU, Means now we gave it to CPU
allowing CPU to execute it Now where is that process staying?
Process is still in the RAM, but its status got changed and it got a new address at a new place
where CPU is executing it All the arithmetic logic and instructions
that we want to run in it,
06:00 - 06:30 we are giving that instructions to CPU
one by one and CPU is executing all that This is the running state, now in running state if there's
uni processor, I told you already, only one processor will run If it's multi-processor
then you can run multiple processes But we are assuming it as uni processor so out of all processes
we picked out one and gave to CPU Now CPU started doing execution on it
after doing one, two, three, four... instructions When it completed all the instructions,
means processor got terminated
06:30 - 07:00 and terminate means deallocation
Deallocation means.... when process came in ready state in the RAM
we provided it some address and resources Now when that process is going back
and completed, now take those resources back , as we have limited RAM so we can't
distribute resources freely, we have limited When we have something limited then we'll utilize it properly,
07:00 - 07:30 so now we deallocated with it, means
took all address and resources back that we provided it and it got terminated, means finished
and it's status got completed This is the normal phase we have, that process is coming and passing
though all these stages But... second concept here is,
let's suppose we shifted it from ready to running state Now that process was going on in running state
but suddenly a high priority process came in ready state
07:30 - 08:00 And we gave it to CPU to execute this process first, now executing this process means, that the process it was working on before,
that will be sent back in the ready queue Why we sent it back? One of the reasons is priority
priority means... Here the concept is of multi-tasking Multi-tasking means that you are
executing multiple processes at a time
08:00 - 08:30 Before that we talked about multi programming,
means bringing as much processes as possible Out of those, we gave one to CPU
But if the CPU is completing it whole then multi-tasking haven't been done here
but if we asked to stop the running process in the middle But a VIP process came for example,
08:30 - 09:00 we asked CPU to execute it first,
then execute the old one So when we gave that process to CPU
But CPU can do only one process at a time So it'll send back the old on process,
on which it was already working before Means we sent it back in the ready state
because a high priority process came It's other reason could be... time quantum Means, there's a scheduling method called round robin
in which we are talking about time quantum
09:00 - 09:30 In this we says that we gave one process to CPU
But CPU will run that process up to a fixed amount of itme The moment that time quantum got expired CPU will ask it to return back,
saying that it'll run next process But just for limited time quantum Let's suppose time quantum is 2 sec
then CPU will run every process up to 2 sec only then it'll send it back,
then it will again get its turn in future
09:30 - 10:00 But if the process got ended in 2 sec,
then it'll get terminated, but if not ended in 2 sec, then
we'll send it back again in the ready state and will keep running the new process
so the scheduler which is helping here is.... Short term scheduler So the next we have is short term scheduler whose responsibility is to pick a process
from ready state and send it in the running state Now if CPU is executing it completely,
then it means multi-tasking did not happened
10:00 - 10:30 which you can call non pre-emptive These topics gets used so much
Non pre-emptive and pre-emptive Non pre-emptive means if CPU will run a process completely, with no priority or time quantum in between
Means if this line is not there Then you can say it's non pre-emptive,
non pre-emptive means no process will get jumped in between
10:30 - 11:00 and the other concept we have is pre-emptive Here pre-emptive means that if
we are stopping running process in between because maybe a high priority came
or its time quantum got expired then it's called pre-emptive so if this line is attached then you'll say pre-emptive or if this line is not attached then
you'll say this is a non pre-emptive type of scheduling so these are very important points
these can directly come in your exam so just keep all these points in your mind
11:00 - 11:30 So now short term scheduling is clear to you,
it's responsibility is to dispatch Next, the third case that comes here is Let's suppose we gave a process to CPU
and CPU is continuously executing that process IN between process said that
it wants to give an IO request Io request means like if it said that
it wants to read a particular file And that file is in secondary memory
now if it wants to read from the secondary memory
11:30 - 12:00 then CPU will say, I can't help anything in this, I would
suggest you to go in the waiting state or get block... and waiting state is also in the RAM
But we changed its status saying to go in wait state Because reading secondary memory means... CPU works in MILLION instructions per second,
it complete works in micro seconds But our secondary memory is slow,
and if it'll wait for secondary memory
12:00 - 12:30 then other processes will keep waiting If we'll take a simple example,
let's suppose you went to a super market Then many times it happens that you are going to get bill,
some other bill is already processing before it And what they do is, they says to buy
other things also while bill is on its process They went somewhere else
leaving the bill in the mid-way If they went somewhere else, then
if the billing person will ask others to wait
12:30 - 13:00 Then obviously people would start cursing saying
what's wrong!.. do his billing later and attend us first So it's the same case here, process said here... before in these cases CPU said that
it'll run those with higher priority first or your process's time quantum is over
and you must go back But in this case, process is saying itself
that it wants to read some file
13:00 - 13:30 or wants to access monitor or any other hardware,
then CPU will ask it to go in wait state Means get block for some time,
that's called an I\O request Now when its IO request got completed,
file and data is done reading... Means its IO got completed Now it won't go back in the running state,
there would some other process already in the running state then we'll ask it to come back in the ready state
13:30 - 14:00 But now you won't go in running state, you just come here
in the ready queue, and we'll get your turn in ready queue So this is the wait/Block state, which is important
when any process demands for an IO like if it wants to read some secondary memory or hardware then CPU will say to wait aside and do the work,
and in future you'll get your turn in the ready state So these are all primary states
which are related to the process life cycle Other than this we have now additional states
additional states are those...
14:00 - 14:30 Let's suppose if we'll talk about worst case
Let's suppose the number of processes we had were 10 We created 10 processes,
and we brought all 10 in the ready state and then we gave first one to CPU to execute it That first one said it wants to do IO request
or wants to read secondary memory we allowed and sent it here
and gave second one to the CPU Second also said to do IO, we sent it
same with third one...
14:30 - 15:00 We gave the fourth one, then it also asked to go
so in worst cake they all may ask to do IO request Then what will happen is, this state which is also in RAM
So it is also a queue, a wait queue so this queue can get full, now
this queue got filled and we have limited RAM so we'll say to suspend for some time
we created a suspend wait or block state
15:00 - 15:30 And what we are doing here actually,
this queue is filled now we'll say that we've swapped out for sometime
Swap out means we sent in back in the secondary memory CPU said like, alright you can do there
because this queue that we have is already filled Now we don't have any other option
so we'll say fine... get suspended for some time Means you can go in the secondary memory
and can continue your work When it'll be completed,
then you can come back in the wait state
15:30 - 16:00 If there'll be space then it can come back
otherwise you can wait in suspend weight for some time And whose work it actually is? who handles all that actually?
this is done by medium turn scheduler Medium turn scheduler's work here is,
like if your RAM is getting filled due to ready state or anything else
that we discussed here, if there's any reason related to it
due to which RAM is getting filled then we'll ask it to go to
secondary memory for some time,
16:00 - 16:30 means we swapped it out with RAM
and sent it secondary memory One more reason that could be here
let's suppose you are filling new new processes You are bringing all of them
in ready state or ready queue in RAM It could be possible that your this queue also got filled so you asked other processes
to stop because ready queue got filled But that time some VIP process came
Means some system or kernel process
16:30 - 17:00 that says It has the highest priority, I have VIP tag...
But our ready queue is already full Now what we'll do... we'll place it in a
suspend ready state from ready queue or when its work will be done or
there'll be some space in the ready queue Then we'll resume it again, and
will bring it back in the ready state again
17:00 - 17:30 So suspend is possible here also but it's possible when your ready state got full
with new processes, that's our task and we have to do it But if some VVIP process arrived
then we have to make some space That work is also handled by the same one The way mid tern scheduler is working here,
same way it's working here also so the difference here is only that we sent it back from the ready state,
but here it was waiting and completing the IO work
17:30 - 18:00 CPU sent it here to do its IO work
But this also got filled then we sent it to secondary memory
that here you can do your IO work now Now from here, it's trying continuously to get into wait state If it went in wait state and
this queue gets empty, then it'll go there If it's not empty in case, there's
more processes coming in the block state Then we calls it backing store...
Backing store mean that we'll send it back here
18:00 - 18:30 Because what's its ultimate purpose?
Where it wants to go from here? Now it wants to reach from here to here
But i can't reach directly from here First we have to send it here,
and from here to ready state, but this is filled already, now either it'll just keep
sitting here. But it won't keep sitting here. If its work got completed then we backing store it
and sent it in ready state but if ready queue is also filled
then send it in suspend ready state
18:30 - 19:00 Just let it wait there... from there it'll get priority and
from here you'll get resume and moved in ready state So they've added some extra states, this is just
very simple concept like virtual memory, swap in- swap out Like we have some processes based on firm scheduler
like we have least frequently used or most frequently used Based on that we do filtering of some processes
so we can send few of them back
19:00 - 19:30 so we can create more space, so some more processes
or high priority processes can come in ready queue or some processes can come in wait block Because CPU is sending here continuously
But if it got filled then I have to use secondary memory lastly But which processes I'll send??
Based on some scheduler... That medium term scheduler will handle it own its own
Whether it'll send least frequently, or most or based on priority
19:30 - 20:00 It can use any logic here, so we were discussing what are those
all primary and secondary states So all these points will help you so much
in competitive exams So talking about window's
If you'll open Window's task manager Then there's a process tab where it shows a whole
list of all processes running in the system That what are system processes,
which one are user processes
20:00 - 20:30 And If we'd talk about UNIX or LINUX then there you can get all process information
through PS (process state) command Although there's a lot of variations in it
like PS-e, PS-u etc.. but in general, It's PS command through which you can get process ID
and which command the process is executing or until when it's been running on the CPU
So all these states will give you benefit here Long term scheduler, short term scheduler,
medium term scheduler pre-emptive, non pre-emptive
20:30 - 21:00 Here I have completed all the aspects So I already told you what is
multi tasking and multi programming You'll get a link in the description, Make sure to check once so you'll understand in detail
what pre-emptive, non pre-emptive, multi-tasking etc. is... Thank You!!