What is a process? in OS

Process in Operating System

In Operating system we define any process as a program in execution or instance of a program of the system, program is a static term however process means a running or active entity.

On batch systems, it is called as a “job” while on time sharing systems, it is called as a “task”.

A user who writes code for printing hello world. Before execution it is called program and after execution once it is in its binary form and is running and executed by system it gets broken down into multiple processes interacting with computing power and OS.

Process in Operating System What is
What is a process in the operating system
Process Life-Cycle

States of Processes

A process can be in the following states –

  1. New
  2. Ready
  3. Run
  4. Wait
  5. Running
  6. Terminated

Apart from this a process in modern system can also be stated in the following two states –

  1. Suspended Ready
  2. Suspended Block

We will discuss these in detail below

Real life Scenario –

Let us consider we write a program to play a sound, when we execute this program this program creates a process for operating system. The operating system now queues up the command to implement and music is played. Simple !!!

Well, its not that simple even for a process to run in a modern OS there are many other stages in the life-cycle of a process, let’s discuss those in details.

Process in Operating System What is

Process Life Cycle

Process life cycle consists of the following stages –

  1. New – Whenever, a fresh process is created it gets available in the new state, it can collect relevant resources like data, I/O access etc in the mean time
  2. Ready – It gets assigned to ready stage where it waits to be assigned to a processor. This is a sort of a queue for all processes which are waiting for processor, such queue is called the Ready Queue.
  3. Running – The process is being executed by processor it gets into running stage.
  4. Waiting – Sometimes, cases happen when a process has to accept an additional input from user or maybe a higher priority process needs processor, in such cases the process goes to wait stage or waiting queue where all the processes are waiting for processor and complete their execution.
  5. Terminated – When process has completed executing its all instructions or when it’s ended by the user directly it goes to terminated stage.

Apart from this new age system also classify –

  1. Suspended Ready – If ready queue is full and has no space for new process then entry level process is in suspended Ready State
  2. Suspended Block – If the waiting queue is full
Process in Operating System What is

Process Elements

Every process has a process memory, which is generally divided into 4, this is done to make the most efficient functioning as possible –

  1. Stack – This houses all the temporary data and local variables like function parameters and addresses.
  2. Heap – When the process is in its run time, for dynamic memory allocation, for operations such as new(), delete(), malloc(), etc heap is used for fastest access at the run time.
  3. Text – Contains value of Program Counter and the contents of the processor’s registers which just the most low level instructions of the compiled program
  4. Data – Has static and global variables. 
What does a process look like in memory in Operating System

Process Control Block or PCB

To identify all active and blocked processes in the system the OS maintains a database of these. Read more about Process Control block here.