CPU Scheduling in OS

Scheduling : Scheduling is a fundamental operating system function. Almost all computer resources are scheduled before use.

CPU Scheduling : CPU Scheduling is is the basis of the multi-programmed operating system. If a process (job) is waiting for an I/o request, then the cpu switches from that job to another job. So, CPU is always scheduled before use.

Types of CPU Scheduling : There are mainly two types of CPU Scheduling Scheme.

  • Non-Preemptive Scheduling
  • Preemptive Scheduling
  • 1. Non-Preemptive Scheduling : In the Non-Preemptive Scheduling, the CPU assigned to a process, the processor does not release until the completion of that process. The CPU will be assigned to some other job only after the previous job has finished.

    2. Preemptive Scheduling : In the Preemptive Scheduling, the CPU can release the processes even in the middle of executing. Some running task is interrupted for some time and resumed it later when the priority task has finished its execution.

    Some following schedulers are given :

  • Short-term scheduler
  • Long-term scheduler
  • Medium-term scheduler
  • 1. Short-term scheduler : The function of Short-term scheduler is that select a job from the ready queue and it gives the control of CPU to that process with the help of ‘Dispatcher’. That’s why the Short-term scheduler is also called CPU Scheduler.

    2. Long-term scheduler : The function of the Long-term scheduler is that selects the job from the pool of jobs and loaded these jobs into main memory (ready queue) of the computer. So, the Long-term scheduler is also called job scheduler.

    3. Medium-term scheduler : If a process requests an I/O in the middle of the execution, then the process removed from the main memory and loaded into waiting for a queue. When the I/O operation completed, then the job moved from waiting for the queue to ready queue that is called Medium-term scheduler.