Process and Process State:

  • In this article, we are going to discuss about process, process state diagram and process control block (PCB).
  • A process is a program which is currently in execution. A program by itself is not a process but it is a passive entity just like content of a file stored on disk, while a process is an active entity.
  • A process also includes the process stack, which contains temporary data (such as local variables, function parameters, return address), and a data section, which contains global variables and a heap-memory allocated to a process to run and process state that defines its current state.
  • A process changes its state during its execution. Each process may be in one of the following states:
  1. New: when a new process is being created.
  2. Running: A process is said to be in running state when instructions are being executed.
  3. Waiting: The process is waiting for some event to occur (such as an I/O operation).
  4. Ready: The process is waiting for processor.
  5. Terminated: The process has finished execution.
Process State Diagram

Process State Diagram

Only one process can be in running state on any processor at a time while multiple processes may be in ready and waiting state. The process state diagram shown below describes different process states during its lifetime.

Process Control Block (PCB):

  • Operating system maintains one special data structure called Process Control Block (PCB).
  • All the information about each process is stored in the process control block (PCB) which is maintained by operating system. It contains following information associated with a specific process.
  • Process state: It represents current status of the process. It may be new, ready, running or waiting.
  • Program counter: It indicates the address of the next instruction to be executed for this process.
  • CPU Registers: They include index registers, stack pointer and general purpose registers. It is used to save process state when an interrupt occurs, so that it can resume from that state.
  • CPU-scheduling information: it includes process priority, pointer to scheduling queue.
  • Memory management information: value of the base and limit registers, page tables depending on the memory system.
  • Accounting information: it contains an amount of CPU and real time used, time limits process number and so on.
  • I/O status information: It includes a list of I/O devices allocated to the process, a list of open files and so on.
  • Normally, operating system stores PCBs of processes into the ready queue for the process scheduling instead of the process itself .