Process Concept in Operating System: Process and Process State Diagram

Today in this Computer Science Study Material for Gate we will discuss about process and process state diagram. SO let start with process meaning. 

What is Process ?

When we start to study the process in operating system then first question that come in mind is how process is different from a  program ?

So let me clear the answer of this question process is nothing but it is a program in execution, it means it is an active entity where as program is  a passive. The term program is used when user data or instruction is on disk, but as soon as it is loaded into memory for execution it becomes a process.
Now come to the further discussion . 

How a process can be represented in memory ?

So , when a program is loaded into the memory and it becomes a process, it Now in memory it can be represented by using  four sections ─ stack, heap, text, and data. The

Figure 1 represents layout of a process inside main memory.

operating system study materail

Let  see each part one by one - 

      Stack: Stack contains the temporary data, such as method/function parameters, return address, and local variables related to a process.
       Heap: Heap is a  dynamically allocated memory to a process when process is under execution.
Text: Text section of  the process tells about  the current activity which is  represented by the value of Program Counter and the contents of the processor’s registers.
Data: Data section contains the global and static variables.

Process States or Process State Transition Diagram or Process’s Life Cycle

When a process create and when it terminates, from beginning to end during its life cycle a process can remain in many states

Figure 2 represent State Transition diagram for a process

operating system study material

Let see these state one by one.

Start or New: First state is Start or new  state. A process is said to be in new state when it is  started or created.

Ready:It is the state next to new state .  The process is said to be in ready state when it is waiting to be assigned to a processor. Ready processes are waiting to have the processor allocated to them by the operating system so that they can run. A process may come into ready  state in  three situation first is just after the Start state, second situation may be  while running and getting interrupted by the scheduler to assign CPU to some other process in this situation it comes to ready state so that cpu can execute the new process. Third situation from wait state when I/O is completed or wait for an even is completed.

Running: Once the process has been assigned to a processor by the OS scheduler, the process state is set to running and the processor executes its instructions then process is said to be in running state.

Waiting: When a process is in running state then  process moves into the waiting state if it needs to wait for a resource, such as waiting for user input, or waiting for a file to become available.

Terminated or Exit: Once the process finishes its execution, or it is terminated by the operating system, it is moved to the terminated state where it waits to be removed from main memory.

I hope that this operating system study material will be beneficial for student to understand the basic concept of process.

Keywords: process concepts in operating system, difference between program and process, process states, process state diagram, process definition,process state transition diagram