DEV Community

Cover image for Process Management
Ravi Sankar
Ravi Sankar

Posted on

Process Management

A process is an instance of a program that is currently being executed by the processor.While a program is a set of instructions for an Operating System to execute. So basically when we run a program,a new process is started.

  So there would be lots of processes running at the same time.This will include both system processes and user application processes.There must be a proper system for managing all these processes.A process requires adequate amount of resources of running. It is the job of the Operating System to allocate the necessary resources and rights for execution of the process. So process management involves various tasks like creation,scheduling,allocating resources and termination of processes.

  When a process executes it passes through different states,they are:

    1:New
      This is the state when a process is first created.

    2:Ready
      This is the state of the process when it is ready to be executed. It is waiting in a queue ready to be executed.When the OS allocates the processor to the process it starts running.

    3:Running
      When the process is assigned to a processor for executing its state is set to running. In this stage the process starts executing its instruction.
    4:Waiting
      A process moves to waiting stage when it needs to wait for another process to complete execution or when it is waiting for a some resource.

    5:Terminated
      This is the state of the process when it has completed its execution.

Image description

    The Operating System has to maintain all the necessary details regarding a process.For this purpose it uses constructs a data structure.This is called Process Control Block. It contains details like process ID,process state,priority and other essential data.Once the process is terminated the data structure is deleted.The OS also maintains different queues for each of the process states.These include Job Queue,Ready Queue and Waiting Queue.The Job Queue stores all the processes in the OS.Ready Queue contains all the processes which are ready to be executed and finally waiting queue contains all the processes in waiting state.These are processes waiting for some I/O operations in order to complete its execution.

    There may be many processes waiting to run so the OS has to choose which process to execute.This selection of process for executing is called process scheduling.This is very important because different processes have different priorities and may need different resources to run. So every process must need appropriate amount of resource and CPU for execution. So if not managed correctly there are chances of dead lock.Dead lock is a situation in which more than one process is blocked because it is holding some resource that is needed by some other process. So an OS must have good algorithms in order to schedule the processes correctly.There are six popular process scheduling algorithms which are as follows:

Image description
1) FIRST COME FIRST SERVE(FCFS)
Processes are executed in first come first serve basis.That is the simplest algorithm to implement.The process which is first in the queue gets executed first.This is not an effective algorithm because it does not consider the priority of the processes while executing.

2) SHORTEST JOB FIRST(SJF)
The process which requires the shortest amount of time to complete its execution is executed first.The time is milliseconds needed for a process to execute is called burst time. So the lesser the burst time the sooner the process would get executed.This is not practically feasible as it is not possible to predict the burst time of the processes.

3) SHORTEST REMAINING TIME FIRST
This is an another version of shortest job first. In this the OS schedules the job according to the remaining time of the execution.

4) PRIORITY BASED SCHEDULING
In this algorithm the priority will be assigned to every process.The higher the priority,the sooner the process would get executed.If the priority of two processes are same then the process would be scheduled according to its arrival time.

5) ROUND ROBIN SCHEDULING
In round robin each process if given a fixed time to execute. It is referred to as a quantum.Once the given time is finished other process starts executing in the same manner.The state of each process is saved using context switching.

6) MULTIPLE LEVEL QUEUES SCHEDULING
This is not an independent scheduling algorithm.They use other existing algorithms to group and schedule jobs with common characteristics.

This was brief overview of the process management system used by the OS.

Sources:

https://medium.com/@akhandmishra/operating-system-process-and-process-management-108d83e8ce60

https://www.javatpoint.com/process-management-in-os#:~:text=%E2%86%92%20%E2%86%90%20prev-,Process%20Management%20in%20OS,resource%20at%20the%20same%20time

https://www.tutorialspoint.com/operating_system/os_processes.htm

Top comments (0)