A process is an instance of a program in execution. The execution of a process must progress in a sequential fashion.
To put it simply, we write our computer program in a text file and when we execute this program, it becomes a process that meets all the tasks mentioned in the program.
When a program is loaded into memory and it becomes a process, it can be divided into four segments- stack, heap, text and data. The following image shows a simplified layout of a process inside the main memory –
|1.||Stack||This contains the temporary data such as method/function parameters, local variables and return address.|
|2.||Heap||This is dynamically allocated memory to a process during its run time.|
|3.||Data||This includes the current activity represented by the value of Program Counter and the contents of the processor’s registers.|
|4.||Text||This contains the global and static variables.|
Process state are those states which tells the status of of the process. Status of the process includes whether the Process has Executed or Whether the process is Waiting for Some input and output from the user and whether the Process is Waiting for the CPU to Run the Program after the Completion of the Process.
A Process has a five States:-
- New State
- Ready State
- Waiting State
- Running State
- Terminated State
Process Life Cycle
When a process is executed, it passes through different states. These steps may vary in different operating systems, and the names of these states are not standardized.
In general, a process can have one of the following five states at a time.
|Sr. No.||Process States||Description|
|1.||Start||This is the initial state when a process is first started/created.|
|2.||Ready||When the Process is Ready to Execute but he is waiting for the CPU to Execute then this is called as the Ready State. After the Completion of the Input and outputs the Process will be on Ready State means the Process will Wait for the Processor to Execute.|
|3.||Running||When the Process is Running under the CPU, or When the Program is Executed by the CPU , then this is called as the Running process and when a process is Running then this will also provides us Some Outputs on the Screen.|
|4.||Waiting||Process moves into the waiting state if it needs to wait for a resource, such as waiting for user input, or waiting for a file to become available.|
|5.||Terminated||Once the process finishes its execution, or it is terminated by the operating system, it is moved to the terminated state where it waits to be removed from main memory.|