Process Life Cycle in OS | Process State in Operating System

Hi Learner! Today, in this tutorial we are going to explain process life cycle in operating system with diagram in detail without any hindrance.

Introduction to Process in OS

A process refers to a program that is currently being executed. The concept of a process is central to the functioning of an operating system, as it allows the system to manage the execution of multiple programs simultaneously.

When a program is executed, the operating system creates a process for it, which includes a unique process identifier (PID), memory space, and other resources required for its execution. The OS also assigns a priority to each process, which determines the order in which they are executed.

The operating system uses various scheduling algorithms to manage the execution of processes, such as round-robin scheduling, priority scheduling, and multi-level feedback queue scheduling. These algorithms ensure that each process is given a fair share of CPU time and that the system remains responsive.

Processes can also communicate with each other through inter-process communication (IPC) mechanisms, such as pipes, message queues, and shared memory. This allows processes to exchange data and coordinate their activities.

A Process Control Block (PCB) is a data structure used by an operating system to store information about a process that is currently executing. Each process in an operating system has its own PCB.

The PCB contains various pieces of information about the process, including:

  • Process state
  • Program counter
  • CPU registers
  • CPU scheduling information
  • Memory management information
  • Accounting information
  • I/O status information

The PCB is managed by the operating system’s scheduler, which uses the information in the PCB to decide which process should be executed next, and when to switch between processes. When a process is suspended, its PCB is saved to memory so that it can be later restored when the process is resumed.

Hence, the PCB is a critical component of an operating system’s process management system, providing a way for the operating system to manage and track the execution of multiple processes simultaneously.

What is the Process Life Cycle in OS?

The process life cycle in an operating system refers to the different states that a process goes through during its execution. The process life cycle can be divided into five main states:

process-life-cycle

List of the Process States

Also Read: First Come First Serve (FCFS) Scheduling Algorithm in OS with Examples & Programs!!

New: In this state, the process is being created, and its resources are being allocated by the operating system.

Ready State: In the operating system, the ready state is a process state in which a process is waiting to be assigned to a processor by the operating system’s scheduler. In this state, the process is loaded into main memory and is ready to execute, but it is waiting for the CPU to become available.

When a process is in the ready state, it is typically waiting in a queue of other processes that are also ready to execute. The operating system’s scheduler determines which process should be executed next based on a variety of factors such as priority, available resources, and scheduling algorithms.

Once the operating system’s scheduler selects a process from the ready queue, the process moves to the running state, in which it is actually executing on a CPU.

Running: In this state, the process is actively being executed by the processor. The process is using the CPU to perform its task.

Waiting State: The waiting state, also known as the blocked state, is a state in which a process is not currently able to run, either because it is waiting for some event to occur, or because it has been suspended by the operating system. When a process enters the waiting state, it is removed from the CPU’s queue of running processes and moved to a queue of waiting processes.

While in the waiting state, the process remains inactive until the event it is waiting for occurs. Once the event occurs, the process is moved back to the ready state, where it can be scheduled for execution by the operating system.

Termination State: The terminated state is the final state in the process life cycle. When a process has completed its execution or has been terminated by the operating system, it enters the terminated state. In this state, the process’s resources, such as memory and CPU time, are released back to the system for other processes to use.

Once a process has entered the terminated state, it can no longer be scheduled for execution by the operating system. However, the process’s exit status (a value that indicates whether the process terminated successfully or not) can be obtained by the parent process using system calls.

The terminated state can occur for a process in several ways, including:

Normal Completion: The process completes its execution without any errors.

Abnormal Termination: The process terminates due to some error or exception, such as a segmentation fault or an unhandled exception.

Killed by the Operating System: The operating system terminates the process for some reason, such as exceeding its allocated resources or violating some security policy.

In any case, once a process has entered the terminated state, it has completed its life cycle in the operating system.

Process States Models

Whenever the user try to execute a process, then it will go via many phases before going to termination state. But, these phases can vary from OS to operating system. There are some common process lifecycles like as two, five, and seven states model.

Also Read: What is Process in OS? Types of Process in Operating System!!

Two-State Model:

The Two-State Model is a common model used to describe the life cycle of a process in an operating system. In this model, a process can be in one of two states: the running state or the waiting state.

2-state-model-of-process-life-cycle

Running State: The process is actively executing and using CPU resources.

Waiting State: The process is waiting for a specific event to occur before it can continue executing. This could be waiting for input/output (I/O) operations to complete or waiting for a particular signal or event.

When a process is created, it starts in the waiting state. The operating system then schedules the process to run on a CPU, and it transitions to the running state. While the process is running, it can use CPU resources to execute its instructions.

If the process encounters an I/O operation or other event that requires it to wait, it transitions back to the waiting state. The operating system then schedules other processes to run on the CPU until the waiting process can continue executing.

This cycle of transitioning between the running and waiting states continues until the process completes its task and is terminated by the operating system.

The Two-State Model is a simplified representation of the process life cycle, and many operating systems use more complex models that include additional states, such as the suspended state or the blocked state. However, the Two-State Model provides a useful framework for understanding the basic behavior of processes in an operating system.

Five-State Model:

The Five-State Model is a process life cycle model used in operating systems. It is also known as the Five-State Process Model and was first introduced by David D. Clark in his 1973 paper “The Structure of the Multics Supervisor”.

The Five-State Model defines the different states that a process can be in during its lifetime in an operating system. These states are:

5-state-model-of-process-life-cycle

New: This is the state when a process is first created but has not yet been admitted into the system.

Ready: In this state, the process is waiting to be assigned to a processor. It has all the necessary resources to run but is waiting for its turn to use the CPU.

Running: The process is currently executing on a CPU.

Waiting State: The process is waiting for a specific event to occur before it can continue executing. This could be waiting for input/output (I/O) operations to complete or waiting for a particular signal or event.

Terminated: The process has completed its execution and is no longer active.

The transitions between these states are controlled by the operating system scheduler. When a process is created, it enters the New state, and then moves to the Ready state when it is ready to be executed. The scheduler then assigns a CPU to the process, and it enters the Running state. When a process is blocked, it moves to the Blocked state and waits for the resource it needs to become available. Finally, when a process completes its execution, it moves to the Terminated state.

Seven-State Model:

The Seven-State Model of the process life cycle in an operating system (OS) is a commonly used model to describe the different states that a process can be in during its execution. The seven states are as follows:

7-state-model-of-process-life-cycle

New: This is the initial state of a process when it is first created. In this state, the OS has allocated memory and other resources for the process, but it has not yet started executing.

Ready: In this state, the process is waiting to be assigned to a processor by the OS. It is in a queue along with other processes that are ready to execute.

Running: When the OS assigns a processor to a process, it moves into the running state. In this state, the process is actively executing instructions on the processor.

Blocked: Sometimes, a process needs to wait for some event to occur, such as input/output (I/O) completion or a resource becoming available. In such cases, the process moves into the blocked state and is temporarily suspended.

Suspended Wait: This is a waiting state where the process has been removed from memory and is waiting for the event to occur. When the event occurs, the process can be moved back into memory.

Suspended Ready: This is a ready state where the process has been removed from memory but is waiting to be assigned a processor by the OS.

Terminated: When a process completes its execution or is terminated by the OS, it moves into the terminated state. In this state, the OS de-allocates the memory and resources that were allocated to the process.

The Seven-State Model is a useful tool for understanding the behaviour of processes in an operating system and for designing efficient process scheduling algorithms.

Final Remarks

Making ensure, in this post, you have been completely aware about process life cycle in operating system with diagram. If this content is useful for you, then share it along with your friends, family members or relatives over social media platforms like as Facebook, Instagram, Linked In, Twitter, and more.

Also Read: Multiprogramming Operating System: Example, Types, and Advantage!!

If you have any experience, tips, tricks, or query regarding this issue? You can drop a comment!

Have a Nice Day!!

Leave a Reply

Your email address will not be published. Required fields are marked *