Processes :

Process = executing program = program + execution state =  static file (image) + execution state .

Program contains the instructions to be executed by processor. The above suggests that a process is a program during execution. It is an entity which represents the basic unit of work to be implemented in the system. So, a program is a passive entity whereas a process is an active entity.

Components of processes :

  • Object Program : It is a code to be executed.
  • Data : Used for executing the program.
  • Resources : Requirements during execution.
  • Status : Confirms the status of execution.

Process Life Cycle :

While execution, a process changes its state (in part by current activity of that process ).

processStates

  • New/Created : Process is initiated here.
  • Ready : Process is waiting to be assigned to a processor.
  • Running : Instructions are being executed.
  • Waiting : Process is waiting for some event to occur and is not using the processor.
  • Destroyed/Terminated : Process is completed and job is killed.

Process Control Box (PCB) :

The PCB serves as the repository for any information which can vary from process to process.

Briefing each elements of PCB :

  • Pointer : Points to other PCB. It is used to maintain  scheduling list.
  • Process state : Any of the state described above.
  • Process number : Also called called process ID is unique no. alloted to process.
  • Program Counter : Address of next instruction to be executed for this process.
  • Registers or CPU Registers : This vary according to computer architecture and is consist of accumulators, index-registers, stack pointers etc.
  • Memory Allocations / Limits : Has the value of limit registers and base and is used in deallocation of memory after program termination.
  • Accounting info : Includes informations like time limits, process number, etc.
  • I/O status information : List of I/O devices allocated for the process.

Process Scheduling

When a system has more  processes than processors, extra processes should be scheduled. It uses the scheduling queue which consists of all processes in system.

Queue diagram

Points to be noted here :

  • Queue is represented by rectangular box.
  • Arrow indicates direction of process flow.
  • Oval represents resources that serves the queue.

Queues are of two types. :

Ready Queue : The queue consists of processes which are waiting in main memory and are ready and waiting for execution.

Device Queue : List of processes which are waiting for a particular I/O device constitutes this queue. Each I/O devices has its own device queue.

After the process is assigned to CPU any of the following mat occur :

  • Process can ask for I/O devices and can be send to Device queue.
  • Process can create a sub process and wait for its destruction.
  • Process can be forcefully removed and can be put back in ready queue again.

Schedulers :

The system software that handles the process scheduling is called scheduler.

  • Long term scheduler : It is the job scheduler which determines which process is to admitted for execution. It gives balanced mixed of I/O bound and CPU bound jobs. Time sharing OS has no longer this scheduler.
  • Short term scheduler : It is the CPU scheduler and is helpful in increasing system performance in defined constraints. It is the change from ready to running state of process.
  • Medium term scheduler : It is the in charge of swapping hence swapping scheduler  and removes process from memory hence reduces multiprogramming.

Context Switching :

This enables multiple processes to share same CPU and is important aspect of multitasking OS feature.

Context Switch

 

It saves the state of old process when CPU is assigned to new process and resumes back the old from saved state. The switching speeds range from 1 to 1000 microseconds. While context switching few information are stored such as program counter scheduling information, changed state etc.

Leave a Reply