In this article, we will mainly learn about the Process in Operating System, Process State Transition diagram and the types of schedulers.
There are mainly 6 states of a Process in operating system –
- New – process in secondary memory.
- Ready – process in main memory, ready to run.
- Run – process runs in main memory.
- Block or wait – process in main memory asking for I/O requests.
- Termination or completion – every trace about the process is deleted else it is a wastage of memory.
- Suspend ready – we move an unimportant process from the main memory to secondary memory from ready state, in order to accommodate a more priority process in main memory. (Secondary memory)
NOTE: There are 2 types of multiprogramming –
- with pre-emption – process can be stopped, multi tasking, time sharing
- without pre-emption – process cannot be stopped
Operations on Process
There are four stages of operations on a process –
Process State transition diagram
- Minimum no. of states that a process has to go through is 4
- If a process asks for I/O in the running state, you end it to wait/block state. Placing it in the ready state would lead to repetition of the asking for I/O when it get back again to the running state. Hence, we are trying to make sure that a process that is comes to the running state is always ready to run.
- When a high priority process enters the ready state, we can shift back the process in the running state and let the high priority process to run. Even in case, where we try to maintain an interval of time between the processes, running state process is shifted back for the other processes.
- Suspended ready is the state that stores the processes shifted from the ready state due to insufficient memory in the ready state in order to accommodate a highly important process. Similarly, if the pushing of process is occurring from the wait/block state, then they will go to suspend wait. Note: New, Suspend ready, Suspend wait are in the Secondary memory.
- Once a process in the Suspend Ready/Wait state is ready, it resumes back to their respective states.
- When you are pushing a process from wait/block state to suspend wait, it will keep processing its I/O. Once the I/O is over, it is now ready, so we move it from suspend wait to suspend ready, so that next time it comes directly to ready. If we let a process to wait/block state even after completing it’s I/O, the process will still have to wait , i.e., why we push it to the suspend ready state.
- There are 3 types of decisions we are talking,
- no. of processes we have to create and once we decide this, we have to live with it. The no. of processes that has to be created is taken by long term schedular and are called long term decisions.
Types of Schedulers
There are 3 types of schedulers:-
- Long-term schedulers: takes decision for no. of processes to be taken.
- Short-term schedulers: once we have a pool of processes, the decision about which process to run is taken. Also called dispatcher.
- Medium-term scheduler: whenever the memory is full, we suspend the process. The suspension decision is made by medium term schedulers.
Degree of multiprogramming – no. of processes that can be present in ready state at max. It is decided by long-term processor.
LT processor decisions are going to have significant impact on the performance of the system. Suppose, LT takes all processes that requires I/O to be performed, then most of the time CPU remains ideal. Therefore, LT should have a mix of both CPU bound and I/O bound processes.
- ST schedular will decide which proces to be executed next. After deciding that it will call dispatcher. Dispatcher is a software responsible for moving a process from running state to ready state and from ready state to running state. This process is called context switching. The time taken for CS depends on the size of the context. Therefore, the size of the context has to be as minimal as possible so that the time is less.
- We should have a very good short term processor so that it will pick up the processes in such a way that there will be less no. of context switches.
- Mid-term schedular is going to affect something called swapping. Swapping is a process of to affect something called process of moving a process from the main memory to secondary and then back to main memory.
- Impacts –
- Long-term schedulers: overall performance
- Short-term schedulers: context-switching time
- Mid-term schedulers: swapping time