Introduction to Process || Process and Thread Management || Bcis Notes

Introduction to Process || Process and Thread Management || Bcis Notes

Introduction to Process

Program
A program is a piece of code which may be a single line or millions of lines. A computer program is usually written by a computer programmer in a programming language. A computer program is a collection of instructions that performs a specific task when executed by a computer. When we compare a program with a process, we can conclude that a process is a dynamic instance of a computer program.

Process
A process is an instance of a program in execution. A program becomes a process when an executable file is loaded in the main memory. A process is defined as an entity that represents the basic unit of work to be implemented in the system. Each process has its own address space and process control block (PCB).

  Program Process
Basic The program is a set of instructions. When a program is executed, it is known as the process
Nature It is Passive in nature. It is Active in nature.
Lifespan Its lifespan is longer. Its lifespan is Limited.
Required resources The program is stored on disk in some files and does not require any other resources. The process holds resources such as CPU, memory address, disk, I/O, etc.

Process states and their transition
When a process executes, it passes through different states. These stages may differ in different operating systems, and the names of these states are also not standardized. In general, a process can have one of the following five states at a time.

  • Start: This is the initial state when a process is first started/created.
  • Ready: The process 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. The process may come into this state after the Start state or while running it by but interrupted by the scheduler to assign CPU to some other process.
  • 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.
  • Waiting: 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.

    Process Control Block (PCB)
    A Process Control Block is a data structure maintained by the Operating System for every process. The PCB is identified by an integer process ID (PID). The PCB is maintained for a process throughout its lifetime and is deleted once the process terminates. A PCB keeps all the information needed to keep track of a process as listed in the figure:

    Introduction to Process || Process and Thread Management || Bcis Notes

  • Process ID: Unique identification for each of the processes in the operating system.
  • Process State: The current state of the process i.e., whether it is ready, running, waiting, or whatever.
  • Pointer: A pointer to the parent process.
  • Priority: Contains the priority numbers of each process.
  • Program Counter: Program Counter is a pointer to the address of the next instruction to be executed for this process.
  • CPU registers: Various CPU registers where processes need to be stored for execution for running state.
  • IO status information: This includes a list of I/O devices allocated to the process.
  • Accounting information: This includes the amount of CPU used for process execution, time limits, execution ID, etc.
  • CPU Scheduling Information: Process priority and other scheduling information which is required to schedule the process.
  • Memory management information: This includes the information of the page table, memory limits, Segment table depending on the memory used by the operating system.

    You may also like: Types and Evolution of Operating System 

Be the first to comment

Leave a Reply

Your email address will not be published.


*