what is process state in os

1 year ago 65
Nature

In an operating system, a process can go through different states during its lifecycle, depending on its current activity and resource availability. The five states that a process may be in are:

  • New: When a process is created, it is in the new state. During this state, the operating system has allocated resources to it, and it is ready to be executed.

  • Ready: When the process creation gets completed, the process comes into a ready state. During this state, the process is loaded into the main memory and will be placed in the queue of processes that are waiting for CPU allocation.

  • Running: When the instructions of a process are being executed, the process is in the running state. One of the processes from the ready state will be chosen by the operating system depending upon the scheduling algorithm. If we have only one CPU in our system, the number of running processes for a particular time will always be one. If we have n processors in the system, then we can have n processes running simultaneously.

  • Waiting: When a process is waiting for an event to occur, such as receiving a data packet, waiting for the users input, or writing to secondary memory, the process is in the waiting state.

  • Terminated: When a process has finished its execution, it is in the terminated state.

The process state includes information about the program counter, CPU registers, memory allocation, and other resources used by the process. The operating system maintains a process control block (PCB) for each process, which contains information about the process state, priority, scheduling information, and other process-related data.