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 executing. 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 get to execute, the operating system creates a process for it. This includes a unique process identifier (PID), memory space, and other resources. The OS also assigns a priority to each process  that determines the order in which they are executing.

The operating system uses various scheduling algorithms to manage the execution of processes. These algorithms ensure that each process assign 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 that helps 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

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 allow to allocation by the operating system.

Ready State: In the operating system, the ready state is a process state in which a process is waiting for assigning to a processor by the operating system’s scheduler. In this state, the process is loading 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 execute 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: 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 suspending by the operating system. When a process enters the waiting state, it allows to remove 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 will move back to the ready state, where it can schedule for execution by the operating system.

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

Once a process entered the terminated state, it can no longer for scheduling for execution by the operating system. However, the process exit status (a value that indicates whether the process terminated successfully or not) can obtain 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 using 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.

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 using 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.

Seven-State Model:

The Seven-State Model of the process life cycle in an operating system (OS) is a commonly using 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 get temporarily suspend.

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

Suspended Ready: This is a ready state where the process fully removed from memory but is waiting to assigne a processor by the OS.

Terminated: When a process completes its execution or terminated by the OS, it moves into the terminated state. In this state, the OS de-allocates the memory and resources that 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 *