There are different states of a process as it executes. The state of a process is determined based on the current activity of the process.
- New: The process is being created.
- Running: The program instructions are being executed.
- Waiting: The process is waiting for some event to occur (such as an I/O completion or reception of a signal.
- Ready: The process is waiting in the ready queue to be assigned to a processor.
- Terminated: The process has finished execution.
It is important to realize that only one process can be in running state on any processor at any instant. Many processes may be ready and waiting, however.
The process is first admitted into the ready queue and stays there if the processor is busy. If the processor is idle, as soon as the process is admitted into the ready queue, it enters the processor immediately. The process in the CPU is said to be in a running state.
There are two scenarios where the process moves from the running state to the waiting state:
- The process is in need of any input goes back to the waiting state and waits for the input
- The process wants to access any output device such as a printer but the printer is busy with some other process then the process goes from running state to the waiting state.
As soon as the input/output or event is completed the process moves from the waiting state to the ready state and the sequence repeats.
If the process is taking time to complete its execution in the running state, then an interruption is called and the process is moved back to the ready queue to allow other processes to perform their tasks.