Introduction

In an operating system, the CPU scheduler is responsible for determining which processes get access to the CPU and when CPU scheduling is a crucial component of operating systems, as it can significantly impact system performance and user experience. In this article, we will provide an overview of CPU scheduling, the different scheduling algorithms used by operating systems, and the factors that affect their performance.

Types Of CPU Scheduling

Two types of CPU Scheduling is:

  • Pre-emtive
  • Non-Pre-emptive
Diagram of CPU Scheduling and its Types by Learn Loner.
Diagram of CPU Scheduling and its Types: Learn Loner

Pre-emptive

In preemptive scheduling, the operating system sets priorities for each process and allocates CPU time based on those priorities. When a higher-priority process becomes ready to run, the operating system interrupts the currently running process and allocates the CPU to the higher-priority process.

It have Two main types also:

  • Priority Scheduling
  • Round Robin

Priority Scheduling

In priority scheduling, each process is assigned a priority, and the CPU is allocated to the process with the highest priority. This algorithm can be either preemptive or non-preemptive. Preemptive priority scheduling allows higher-priority processes to interrupt lower-priority processes, while non-preemptive priority scheduling does not allow for interruptions.

Round Robin (RR)

In RR (Round Robin), each process is allocated a fixed amount of time to run on the CPU, called a time slice. After the time slice expires, the process is preempted and moved to the back of the ready queue, and the next process gets access to the CPU.

Non-Pre-emptive

In non-preemptive scheduling, the operating system sets priorities for each process, but it only allocates the CPU to a new process when the current process has finished or blocked. The operating system does not interrupt the current process to allocate the CPU to a higher-priority process.

It have Two types:

  • First-Come, First-Served (FCFS)
  • Shortest Job First (SJF)

First-Come, First-Served (FCFS)

In FCFS, the CPU is allocated to the first process that arrives in the ready queue. The process runs until it completes or is blocked by an I/O request. The next process in the queue then gets access to the CPU.

Shortest Job First (SJF)

In SJF, the CPU is allocated to the process with the shortest expected execution time. This algorithm minimizes the average waiting time for all processes in the system.

Factors Affecting CPU Scheduling Performance

The performance of CPU scheduling algorithms can be affected by several factors, including:

CPU Utilization

CPU utilization is the percentage of time the CPU is busy executing processes. A high CPU utilization rate can lead to longer waiting times for processes in the ready queue.

Throughput

Throughput is the number of processes completed per unit time. A high throughput rate indicates that the system is processing a large number of processes efficiently.

Turnaround Time

Turnaround time is the time taken for a process to complete, from the time it enters the system to the time it finishes execution. A shorter turnaround time indicates that the system is processing processes efficiently.

Waiting Time

Waiting time is the amount of time a process spends in the ready queue before getting access to the CPU. A shorter waiting time indicates that the system is prioritizing processes efficiently.

Conclusion

CPU scheduling is a critical component of operating systems, and the choice of scheduling algorithm can significantly impact system performance and user experience. The different scheduling algorithms used by operating systems have different strengths and weaknesses, and the choice of algorithm depends on the system’s specific requirements. By understanding CPU scheduling and the factors that affect its performance, we can design more efficient and effective operating systems.

JOIN OUR NEWSLETTER
And get notified everytime we publish a new blog post.