CPU Scheduling in OS | Scheduler and Dispatcher

Process Scheduling in Operating System, CPU Scheduling
CPU Scheduling

CPU Scheduling

CPU Scheduling in operating system is a fundamental function, almost all computer resources scheduled before use. The CPU is also one of the primary resources. So, CPU scheduling before use. The Scheduling Algorithms determine how the CPU will be allocated to the process.

CPU Scheduling in Operating System

CPU scheduling in the operating system is the basis of the multi-programmed operating system. The idea of multiprogramming is relatively simple if a process(job) is waiting for an I/O request, then the CPU switches from the process to another through a dispatcher, so the CPU is always busy in multiprogramming.

But in a simple computer system, the CPU sits idle until the I/O request granted. By switching the CPU among process, the OS can make the computer more productive.

Types of CPU Scheduling

CPU scheduling has two types-Non-Preemptive and Preemptive

Non-Preemptive Scheduling

In the non-preemptive scheduling, once the CPU assigned to a process, the processor does not release until the completion of that process. The CPU will be assigned to another job only after the previous has finished.

Preemptive Scheduling

In the preemptive scheduling algorithm, the CPU can release the process even in the middle of the execution. For example, the CPU executing the process P1, in the middle of the execution the CPU receives a request signal from process P2. Then the OS compares the priorities of P1 and P2.

CPU Scheduler in OS

CPU schedulers in operating system are:

Long-term Scheduler

The function of a long-term scheduler is to select the jobs from the pool of jobs and load these jobs into main memory(Ready Queue) of that computer, so the long-term scheduler is also called job-scheduler.

Short-term Scheduler

The function of a short-term scheduler is to select a job from the ready queue and gives the control of the CPU to that process with the help of "Dispatcher". That's why the short-term scheduler is also said to be the CPU scheduler.

The method of selecting a process from the ready queue by the short-term scheduler is depending on the Scheduling algorithms.

Medium-term Scheduler

If a process requests an I/O in the middle of execution, then the process removed from the main memory is loaded into the waiting queue. When the I/O operation is completed, then the job moved from waiting queue to ready queue. These two operations are performed by the medium-term scheduler.

Dispatcher in OS

A dispatcher is a module, it connects the CPU to the process selected by the short-term scheduler. The main function of the dispatcher is switching, it means switching the CPU from one process to another process.

Another function of the dispatcher is jumping to the proper location in the user program and ready to start execution. The time taken by the dispatcher to stop one process and start another running is called the Dispatch Latency in OS.

The degree of multiprogramming is dependent on the dispatch latency. If the dispatch latency is increasing, then the degree of multiprogramming decreases.

CPU Scheduling Criteria in OS

Throughput in OS

It means how many jobs are completed by the CPU.

Turnaround Time in OS

The time interval between the submission of the process and the time of the completion is the turnaround time. This is the turnaround time formula in OS [Turnaround time=Waiting time in the ready queue + executing time + waiting time in waiting-queue for I/O].

Waiting Time in OS

Waiting time is the sum of the periods spent waiting by a process in the ready queue.

Response Time in OS

Response time is the time duration between the submission and the first response.

CPU Utilization in OS

This is the percentage of time that the processor is busy, CPU utilization may range from 0-100%.

I hope you have cleared about CPU Scheduling in OS, you also learned types of scheduling, Scheduling criteria, dispatcher and three kinds of schedulers i.e., long term, short term, and medium-term scheduler.

Practice MCQ Questions on SabQuiz

Practice Now