L-1.5: Process States in Operating System| Schedulers(Long term,Short term,Medium term)
Summary
TLDRIn this video from Gate Smashers, the concept of process states or the process life cycle is explained. It covers the primary states (new, ready, running, terminated, wait/block) and additional states (suspend wait/block, suspend ready). The video details how processes move through these states, the role of schedulers (long-term, short-term, medium-term), and concepts like multi-programming and multi-tasking. The explanation includes practical examples and mentions how to view processes in Windows and UNIX/Linux. This comprehensive guide is useful for competitive and university exams.
Takeaways
- π The video discusses the process states or life cycle, which is crucial for understanding how processes operate in systems like laptops, PCs, and mobiles.
- π The primary states of a process are New, Ready, Running, Wait/Block, and Terminated. These are essential stages a process goes through from start to end.
- π» The 'New' state refers to a process that has been created but not yet executed, typically stored in secondary memory.
- π When a process is 'Ready', it has been brought into RAM and is waiting to be executed by the CPU.
- πββοΈ The 'Running' state is when a process is actively being executed by the CPU, and it is in this state that the process performs its tasks.
- π The 'Wait/Block' state occurs when a process is waiting for an I/O request, such as reading from secondary memory, and is temporarily halted.
- π The 'Terminated' state signifies the end of a process's life cycle, where it has completed its execution and resources are deallocated.
- π The Long-term Scheduler is responsible for bringing processes into the Ready state, contributing to the concept of multi-programming.
- π The Short-term Scheduler picks processes from the Ready state and sends them to the Running state, managing the execution of processes on the CPU.
- π The Medium-term Scheduler handles processes that need to be swapped out of RAM to secondary memory due to limited resources or high priority processes needing execution.
- π The concepts of multi-tasking and pre-emptive scheduling are important for understanding how multiple processes are managed and prioritized in a system.
Q & A
What is the purpose of the process life cycle model?
-The process life cycle model is created to explain the various states a process goes through from its start to its end, helping users understand how a process evolves and changes its status during execution.
What are the primary states of a process according to the script?
-The primary states of a process are New, Ready, Running, Waiting/Block, and Terminated. These states are mandatory and present by default in the process life cycle.
What is the 'New' state in the context of process states?
-The 'New' state refers to the initial stage of a process's life cycle when it is created but not yet executed. It is stored in secondary memory and is in a stable state.
What is the role of the long-term scheduler in process management?
-The long-term scheduler is responsible for bringing processes from the secondary memory into the ready state in RAM, facilitating multiprogramming by managing how many processes are in the ready queue.
How does the script describe the 'Ready' state of a process?
-In the 'Ready' state, a process has been loaded into RAM and is waiting in the ready queue to be executed by the CPU. It is in an active state, ready to be scheduled for execution.
What is the significance of the 'Running' state in a process's life cycle?
-The 'Running' state signifies that the process is currently being executed by the CPU. It is in this state that the process performs its designated tasks and operations.
What does the script mean by 'Terminated' state?
-The 'Terminated' state indicates that a process has completed its execution. In this state, the process releases its allocated resources and exits the CPU's execution cycle.
What is the concept of multiprogramming as explained in the script?
-Multiprogramming is the concept of bringing as many processes as possible into the ready queue, allowing for efficient use of the CPU and memory resources, and enabling the system to handle multiple tasks concurrently.
What is the difference between non-preemptive and preemptive scheduling as described in the script?
-Non-preemptive scheduling means a process runs to completion without interruption, whereas preemptive scheduling allows for a process to be interrupted during its execution due to factors like higher priority processes or time quantum expiration.
What is the role of the short-term scheduler in process management?
-The short-term scheduler is responsible for selecting a process from the ready queue and dispatching it to the running state. It plays a crucial role in process execution and task switching.
What does the script imply by the 'Wait/Block' state?
-The 'Wait/Block' state is when a process is waiting for an I/O operation to complete, such as reading from secondary memory. During this state, the process is paused and will return to the ready state once the I/O request is fulfilled.
What are the additional states mentioned in the script, and what are they used for?
-The additional states mentioned are Suspend Wait/Block and Suspend Ready. These states are used when the respective queues for waiting processes or ready processes are full, and the process needs to be temporarily moved to secondary memory until space becomes available.
What is the function of the medium-term scheduler as per the script?
-The medium-term scheduler handles processes when the system's RAM or queues are full. It decides which processes to swap out to secondary memory based on certain scheduling algorithms, making space for new or high-priority processes.
Outlines
π Introduction to Process States and Life Cycle
This paragraph introduces the concept of process states and their life cycle, emphasizing their importance for understanding how processes operate within a system. The speaker invites viewers to engage with the content by liking, subscribing, and turning on notifications. The primary focus is on the primary states of a process: New, Ready, Running, Waiting/Blocked, and Terminated. These states are essential for understanding how a process evolves from creation to completion. The paragraph also hints at additional states that will be discussed later, setting the stage for a deeper dive into process management.
π Exploring the New and Ready States
The speaker delves into the specifics of the New and Ready states. The New state is described as the initial phase where a process is created but not yet executed, such as a program written in C language that is stored but not run. The Ready state is when a process is brought into RAM, making it eligible for execution. The paragraph explains the role of the long-term scheduler in moving processes from the New state to the Ready state, highlighting the concept of multi-programming, which involves loading multiple processes into the Ready queue to maximize CPU utilization.
πββοΈ Transitioning from Ready to Running State
This paragraph discusses the transition of a process from the Ready state to the Running state. The speaker explains that the process is moved to the CPU for execution, which is the Running state. The emphasis is on the execution of processes, with the CPU handling the instructions one by one. The paragraph also touches on the differences between uni-processor and multi-processor systems, and how these affect the execution of processes. The concept of deallocation is introduced when a process completes its execution and is terminated, freeing up resources.
π Understanding Pre-emptive and Non-Preemptive Scheduling
The speaker introduces the concepts of pre-emptive and non-preemptive scheduling, explaining how these affect the execution of processes. In non-preemptive scheduling, a process runs to completion without interruption, whereas in pre-emptive scheduling, a process can be interrupted and resumed later based on priority or time quantum. The paragraph also discusses the role of the short-term scheduler in picking processes from the Ready state and moving them to the Running state, emphasizing the importance of these concepts in operating systems.
π Handling IO Requests and Wait/Block State
This paragraph addresses the handling of IO requests by processes and the resulting Wait/Block state. When a process requests IO, such as reading from secondary memory, it is moved to the Wait state, which is still in RAM but with a changed status. The speaker uses an analogy of a supermarket to explain why processes are moved to the Wait state, highlighting the inefficiency of CPU waiting for slow IO operations. The paragraph also discusses the role of the medium-term scheduler in managing processes that need to be suspended due to full wait queues or full ready queues.
π Additional States and Schedulers in Process Management
The final paragraph covers additional states in the process life cycle, such as the Suspend Wait or Block state, which occurs when the wait queue is full and processes need to be moved back to secondary memory. The speaker explains the role of the medium-term scheduler in managing these states, deciding which processes to swap out based on criteria like frequency of use or priority. The paragraph also touches on the concept of backing store, where processes are temporarily stored in secondary memory before being moved back to the ready state. The speaker concludes by emphasizing the relevance of these concepts in competitive exams and system management.
Mindmap
Keywords
π‘Process States
π‘Process Life Cycle
π‘Kernel
π‘Multi-programming
π‘Long-term Scheduler
π‘Short-term Scheduler
π‘Pre-emptive Scheduling
π‘Non-preemptive Scheduling
π‘I/O Request
π‘Suspend State
π‘Medium-term Scheduler
Highlights
Introduction to process states and life cycle in the context of operating systems.
Explanation of process states as a model to understand how processes evolve from start to end.
Identification of primary states: New, Ready, Running, Wait/Block, and Terminated.
Description of the New state as the initial phase where a process is created but not yet executed.
Transition from New to Ready state when a process is loaded into RAM and becomes eligible for CPU time.
Role of the Long-term scheduler in bringing processes into the Ready state for multiprogramming.
Concept of multiprogramming explained as increasing the number of processes in the Ready queue.
Discussion on the Running state where a process is actively being executed by the CPU.
Impact of CPU type (uni-processor vs. multi-processor) on the number of processes that can be in the Running state.
Transition to the Terminated state when a process completes its execution and resources are deallocated.
Introduction of the concept of preemptive and non-preemptive scheduling in the context of process execution.
Explanation of the Wait/Block state when a process is waiting for IO operations to complete.
Role of the Short-term scheduler in picking processes from the Ready state to the Running state.
Discussion on the Round Robin scheduling method and its use of time quantum for process execution.
Introduction of additional states like Suspend Wait/Block and Suspend Ready for managing processes when queues are full.
Responsibility of the Medium-term scheduler in handling process suspension and resumption based on system needs.
Practical applications of process states in Windows Task Manager and UNIX/Linux systems for process management.
Summary of the importance of understanding process states for competitive exams and real-world applications.
Transcripts
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
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
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
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
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
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
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,
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
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
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
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,
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,
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
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,
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
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
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,
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
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
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
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
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
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
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
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
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
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
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...
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...
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
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
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,
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
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
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
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
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
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
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
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
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
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!!
Browse More Related Video
Process States | Process State Transition Diagram
What is a Process in an Operating System?
Difference between Multitasking, Multiprogramming and Multiprocessing | Operating system | CSE
L-1.11: Process Vs Threads in Operating System
Operating Systems 3 - Process Manager Part 1
SDLC Life Cycle for Beginners | Software Development Life Cycle with Real life example
5.0 / 5 (0 votes)