Saturday, June 15, 2013
In the systems where multiple processors or multitasking is involved, a process has to go through a number of states. In this article we shall discuss about these states.
The kernel of the operating system may not recognize these states distinctly but still for the understanding of how the processes are executed they act as useful abstractions.
These various states can be looked up in a process state diagram for a systematic view. This diagram shows the transitions of the process between various states with arrows. Processes can be stored both in the secondary or virtual memory and in the main memory as per the situation.
- The primary process states occur in all types of the systems.
- Processes in these states are usually stored in the main memory.
Basically there are 5 major states of any process as discussed below:
- It is also known as the ‘new’ state.
- A process occupies this state up on it creation.
- While waiting for being admitted to the next ready state this process lies in this state.
- The admission scheduler will decide whether to admit the process to next state or to delay it on a short or long term.
- However, this admission is approved in an automatic way in most of the desktop computers.
- But in the systems with real time operating systems this is not true.
- Here, the admission might be delayed by a certain amount of time.
- If too many states are admitted to the ready state in a real time operating system, condition of over contention and over saturation might occur disabling the system to meet its deadlines.
Ø Ready or Waiting:
- This state is taken up a process when it has been loaded in to the physical memory of the system and is waiting to be executed by the processor or precisely waiting to be context switched by the dispatcher.
- At any instant of time there might be a number of processes waiting for their execution.
- Here the processes have to wait in a queue called the run queue out of which only one process will be taken up by a processor.
- Processes that are waiting for obtaining input from some event are not put in to this ready queue.
- When a process is selected by the CPU for execution, its state is changed to running.
- One of the processors executes the instructions of the process one by one.
- Only one process can be run by the process at a time.
- When a process is blocked because of some event such as I/O operations is put in to the blocked state.
- Another reason for a process being a blocked state can be its running out of the CPU time allocated to it.
- Termination of a process may occur when either its execution is complete or it has been explicitly killed.
- This state is called the terminated or halted.
- This process is called a zombie process if after coming in the terminated state it is not removed from the main memory.
There are two additional states for supporting the virtual memory. In these states the process is usually stored in the secondary memory of the system:
Ø Swapped out or Waiting:
- A process is said to be swapped out when it is removed from the primary memory and placed in the secondary memory.
- This is done by the mid - term scheduler.
- After this the state of this process changes to waiting.
Ø Swapped out and Blocked:
- In some cases, the processes that were in blocked state might be swapped out.
- The same process might be again swapped in providing the conditions remain the same.