What is a Process in Operating System?


This topic comes under CPU Scheduling. During the whole course of operating system you will hear this term 'process' so understanding about process is very important. SO,let's get started, shall we?

Process

The basic definition of a process is that it is a program in execution which executes in a sequential manner. Now, many students confuses between a process and a program so let's see some basic differences between them:
                        Process                                                                 Program

1.  A Process is a program in execution.                   A program is a set of instruction to be executed.
2.  It is an active entity.                                             It is a passive entity.
3.  Process resides in the main memory.                   Program resides in the disk.
 
When a program is loaded into the main memory it becomes a process. A process can be sub-divided into 4 parts:

What is a Process in Operating System?


  • Stack : Stack contain temporary data such as local variables, function/methods, return address.
  • Heap : This part is reserved for dynamic allocation of variables during run time.
  • Text : This includes values of Program counter and content of Processor's registers.
  • Data : This part contain global and static variables.
States of a process

A process can have 5 states as given in the picture below:

What is a Process in Operating System?

  • New : When a process is being created then it is said to be in new state.
  • Ready : When a enters main memory for execution it is said to be in Ready state.
  • Run : When a process is being executed by CPU then it is in run state.
  • Wait : When a process request for an I/O operation then it is in wait state.
  • Complete/Terminated : When a process is done with its execution then it is terminated.
Note: If a process enters running state and then it wants to perform an I/O operation then it moves to the wait state. When it is done with its I/O operation then it moves back to ready state because there might be a process which is already being executed by the CPU.

Note: If a process is running in the CPU and it is taking more time to execute than expected or if it is blocked then there is a clock being installed between ready and run state which ensures that a process must execute its processing in the given time else it is stopped and pushed back to the ready queue again. 

Process Control Block 

A process has various attributes associated with it and these attributes are managed by a data structure called Process Control Block.
These attributes of a process are:

Process Control Block

  • Process Id : Every process has an id associated with it which uniquely identifies it.
  • State : It determines the current state of a process i.e new, ready, run...
  • Pointer : It is a pointer which points to the parent process.
  • Priority : It determines whether to allow/disallow access to system resources.
  • Program Counter : It contain address of next instruction to be executed for the process.
  • CPU registers : These are the registers where process need to be stored for execution.
  • I/O information : It includes list of I/O devices allocated to the process.
  • Accounting information: This includes amount of CPU used for program execution, time limits, execution ID etc.
Some other attributes of PCB are:
  • Memory management information: It includes information of page tables, memory limits etc.
  • CPU scheduling information : Process priority and other scheduling information which require to schedule the process.
CPU-bound Process and I/O-bound Process

A CPU-bound process is a process which requires more of CPU execution than I/O operations.
An I/O-bound process is a process which requires more of I/O execution than CPU execution.

Context-Switching

It is the process of saving the state of one process and loading the saved state of another process.
In layman terms it is like loading and unloading the process from running state to ready state.



Post a Comment (0)
Previous Post Next Post