Explain Process Scheduling in detail?

The process scheduling is the activity of the process manager that handles the removal of the running process from the CPU and the selection of another process on the basis of a particular strategy.

Long Term Scheduler

  • It is also called a job scheduler. A long-term scheduler determines which programs are admitted to the system for processing. It selects processes from the queue and loads them into memory for execution. Process loads into the memory for CPU scheduling.
  • It provides a balanced mix of jobs, such as I/O bound and processor bound. It also controls the degree of multiprogramming.
  • If the degree of multiprogramming is stable, then the average rate of process creation must be equal to the average departure rate of processes leaving the system.

Short Term Scheduler

  • It is also called as CPU scheduler. Its main objective is to increase system performance in accordance with the chosen set of criteria.
  • It is the change of ready state to running state of the process. CPU scheduler selects a process among the processes that are ready to execute and allocates CPU to one of them.
  • Short-term schedulers, also known as dispatchers, make the decision of which process to execute next. Short-term schedulers are faster than long-term schedulers.

Medium Term Scheduler

  • Medium-term scheduling is a part of swapping. It removes the processes from the memory. It reduces the degree of multiprogramming.
  • The medium-term scheduler is in-charge of handling the swapped out-processes.
  • A running process may become suspended if it makes an I/O request. A suspended processes cannot make any progress towards completion. In this condition, to remove the process from memory and make space for other processes, the suspended process is moved to the secondary storage.
  • This process is called swapping, and the process is said to be swapped out or rolled out. Swapping may be necessary to improve the process mix.

Next, we understand two types of scheduling:-

  1. Preemptive scheduling is used when a process switches from running state to ready state or from the waiting state to ready state. The resources (mainly CPU cycles) are allocated to the process for a limited amount of time and then taken away, and the process is again placed back in the ready queue if that process still has CPU burst time remaining.
  2. Non-Preemptive Scheduling is used when a process terminates, or a process switches from running to the waiting state. In this scheduling, once the resources (CPU cycles) are allocated to a process, the process holds the CPU till it gets terminated or reaches a waiting state.

In the final topic we study the types of process queues:-

1. Job Queue

In starting, all the processes get stored in the job queue. It is maintained in the secondary memory. The long term scheduler (Job scheduler) picks some of the jobs and put them in the primary memory.

2. Ready Queue

The ready queue is maintained in primary memory. The short-term scheduler picks the job from the ready queue and dispatches to the CPU for execution.

3. Waiting Queue

When the process needs some IO operation in order to complete its execution, OS changes the state of the process from running to waiting. The context (PCB) associated with the process gets stored on the waiting queue which will be used by the Processor when the process finishes the IO.