Process State Transition

By | September 10, 2021

Process State Transition

Definition of Process

  • In most systems, a process is a unit of work done.
  • A process is a set of sequential steps that are required to do a particular task.
  • A process is an instance of a program in execution.

Process State Transition

  • For example, in the windows environment, if we edit two text files, simultaneously, in notepad, then it means we are implementing two different instances of the same notepad program. For an operating system these two instances are separate processes of the same application.
  • A process needs certain resources such as CPU time, memory files, and I/O devices to accomplish its task. These resources are allocated to the process either when it is created or while it is executing.
  • A process can be identified in an operating system environment by its following components :
  1. The object program (or code) to be executed.
  2. The data on which the program will execute (obtained from a file or interactively from the user of the process).
  3. The status of the process execution.
  4. The resources that a process is utilizing.

Process Context

  • The process context is represented by the value of CPU registers (such as PC, SI, 1SW and other relevant registers) used by the process, address space of process, process state, profiling and accounting information, and associated kernel data structures.
  • This context information is usually contained in a data structure called process control block or process descriptor.
  • As discussed earlier, a process is an active entity, whereas a program is a passive entity. A program is an executable entity that describes how input is to be transformed to produce output.
  • A process actually carries out transformation by executing instruction from the program.
  • The CPU then executes the program on behalf of the process.
  • These executions done by CPU are managed by the operating system.
  • The operating system needs to know the state of the program execution.
  • The state of program includes :
  1. What program CPU is executing.
  2. Where this program and its data is residing in main memory.
  3. Which instruction CPU is executing at a given time.
  4. What resources used for this execution.
  • The system needs the state information of all ongoing program executions to manage the program execution effectively and run the computer system smoothly.
  • When the system executes a process, the value of the PC register in the CPU determines which instruction from the process’s program the CPU will execute next. Thus all the control information related to a process (i.e. one program execution) collectively defines an execution context called process context.
  • A process’s context divided into two parts:
  1. Hardware context. It includes the processor (general purpose and special purpose) registers, i.e. PC, SP, PSW etc.
  2. Software context. It includes open files, memory regions etc.

Process States

  • A process goes through a series of discrete process states for performing its task.
  • As a process executes it changes state. The state of a process defined by the current activity of that process. Thus a process’ state is indicative of the activity that it is currently performing.
  • Various events can cause a process to change state.
  • The notion of process state used by an operating system to simplify process scheduling.

The various states of a process are:

  1.  New. A process that has just created but has not yet admitted to the pool of executable processes by the operating system.
  2.  Ready. These processes prepared to execute when given the opportunity. A ready process has all the resources needed for its execution, except the processor. Processes usually take the ready state immediately upon creation. All ready processes are waiting to have the processor so that they can run.
  3.  Running. The process whose instructions executed, called running process. A running process possesses all resources needed for its execution including the processor.
  4.  Waiting/Blocked. The process waiting for some event to occur or blocked until some event occurs such as the completion of I/O operation. Such a process cannot execute even if a CPU is available.
  5. Terminated. The process has finished its execution. All the tasks in a process completed.

A terminated process removed from the pool of executable processes by the operating system.

A process terminated :

(i) if it has reached its natural completion point

(ii) when it aborts due to an unrecoverable error

(iii) or when another process with appropriate authority causes the process to abort.

  • The operating system may retain information on a terminated process for a variety of reasons:-
  1. The process has an I/O operation pending completion.
  2. It has child processes that are still executing and the system needs to retain information about the process that created them.
  3. It has a parent or related process that in the future may request information about the terminated process.
  • At any time any number of active processes occupies different states. The collective state of all processes and resources (free, busy) in the system called global system state.
  • In response to events, the processes may rapidly change their states and form another global state of the system.
  • Only one process can be running on any processor at any instant. However there can be many processes in ready and waiting states.
  • A process state includes all the information necessary to resume it, if temporarily stopped.
  • Thus, it defines the value of variables associated with the process at any instant of tine This information includes content of general purpose registers, value of PC, value o PSW as well as program’s static and dynamic data.

 Process State Transition

 Process State Transition

  • A state transition is a change from one state to another. A state transition caused by the occurrence of some event in the system.
  • A process has to go through various states for performing its task.
  • The transition of a process from one state to another occurs depending on the flow of the execution of the process. It is not necessary for a process to undergo all the states.
  • A new process is added to a data structure called a ready queue, also known as ready pool or pool of executable processes. This queue stores all processes in a first-in first-out (FIFO) manner. A new process added into the ready queue from its rear end and the process at the front of the ready queue sent for execution.
  • If the process does not voluntarily release the CPU before the time slice expires, the interrupting cycle generates an interrupt, causing the operating system to regain control. An interrupt is a request to processor usually activated by a task needing attention.
  • Each process assigned a time slice for the execution. A time slice is a very short period of time and its duration varies in different systems.
  • The CPU executes the process at the front end of the ready queue and that process makes a state transition from ready to the running state. The assignment of the CPU to the first process on the ready queu called dispatching.

Process State transition indicated as

dispatch (processname) : ready → running

  • The operating system then adds the previously running process to the rear end of ready queue and allocates CPU to the first process on the ready queue.

These state transitions indicated as:

timerunout (processname): runningready


dispatch (processname) : ready running

  • If a running process initiates an input/output operation before its time slice expires, the Funning process voluntarily releases the CPU. Sent to the waiting queue and the process state marked as waiting blocked.

This state transition indicated as :

block (processname) : running – blocked

After the competition of I/O task, the blocked or waiting process restored and placed back in the ready queue and the process state marked as ready.

When the execution of process ends, the process state marked as terminated and the operating system reclaims all the resources allocated to the process.

A process terminated after its successful completion. Called normal exit of a program. In certain cases, a process terminates or stops its execution prematurely. For example, a process killing another process or an error occurring results in abnormal termination.