Process and Process States

Have you ever executed a process? Have your process changed states? In this post, we going to cover the notion of a process and process states. We will understand: what is a process? How to convert your program into a process? What are the different states of a process? and Where all the information related to a process is stored?

What is a Process?

After you write a program in any language, two steps follow:
1. Compiling
2. Running/Executing
The second step is what makes that program a process. You double-click any software in your computer system or you tap on any application your mobile or you write a command like $./a.out, all these convert the application(program) into a process. Every application is a program until you execute it by double click or a tap or a command, after which it becomes a process.
So, a process is a program in execution

Now, once you initiate a process, the operating system loads it into the memory (RAM). Inside the RAM the structure of the process looks like as shown below:

  1. Text – program code
  2. Data – contains global variables
  3. Stack – contains temporary data
    • function parameters
    • return addresses
    • Local variables
  4. Heap – memory allocated dynamically during run time
Layout of a process

The text section contains the program or the code, the data section contains the global variables. These two sections have fixed size because neither the code is going to change nor the variables used in the program. Heap is used for dynamic memory allocation. Now, we use dynamic memory allocation when we can not determine the memory required. Hence the heap section can grow in size if required.

Lastly, the stack section is used for functions. Again, the size of this section is also variable. Because it is difficult to determine the number of function calls required. Consider a program for factorial calculation which uses recursive functions. If the number is 5 then the function call is 5 times. If the number for factorial is 20, then the function call is 20 times. So the system does not know what exactly will be the stack size. Hence, the stack size is variable.

Points to Remember

Program: is a passive entity
Process: is a active entity


Q1.Can two processes be associated with the same program?


Share you answers in comments section below

Process States

A process can change its state during its lifetime. The various states of a process are:

  1. New – when a process is created
  2. Ready – when the process is in the RAM and is waiting for CPU allocation.
  3. Running – the process gets the CPU and is executing in this state
  4. Waiting – the process is waiting for some I/O device
  5. Terminated – the process finishes its execution either normally or forcefully

For best visualization and better understanding of process states visit this link:

Process states

Note: the link may not work in Chrome. Use Microsoft Edge. Also, it might require to allow the use of flash.

Process Control Box(PCB)

Sometimes a running process changes its state to waiting or ready and then back to running. In this case all the related information of a process needs to saved so that it can be later loaded when the process starts to execute again. This information is saved in Process Control Box(PCB). Another name pf PCB is Task Control Box. The most common information stored is:

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

Video Link for Process and Process States

PPT on Process

Note: Clicking on the “next” slide button will not display any animation. Hence, Click within the slide area for animations.

Previous                                                Next
OS Services and System Calls       Process Schedulers

Leave a Reply

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