Skip to main content

CPU Scheduling

CPU Scheduling Algorithms in Operating System (OS)

CPU scheduling algorithms are a fundamental concept in the operating system. They determine how the CPU is allocated among multiple processes to ensure efficient system performance. A good scheduling algorithm improves CPU utilization, reduces waiting time, and ensures fairness among processes.

What is CPU scheduling?

CPU scheduling is the process by which the operating system decides which process in the ready queue will be executed next by the CPU. Since multiple processes may be in memory at the same time, scheduling is essential for multitasking systems.

Objectives of CPU Scheduling

  • Maximize CPU utilization
  • Increase system throughput
  • Minimize waiting time
  • Minimize turnaround time
  • Improve response time
  • Ensure fairness

Types of Scheduling

1. Preemptive Scheduling

In preemptive scheduling, the operating system can interrupt a running process and assign the CPU to another process.

  • Better response time
  • More context switching

2. Non-Preemptive Scheduling

In non-preemptive scheduling, once a process starts execution, it runs until completion or enters a waiting state.

  • Simple implementation
  • Poor response time

CPU Scheduling Algorithms

1. First Come First Serve (FCFS)

FCFS is the simplest CPU scheduling algorithm, where processes are executed in the order of their arrival.

Characteristics:
  • Non-preemptive
  • Simple and easy to implement
  • No starvation
Disadvantages:
  • Convoy effect
  • Poor average waiting time

2. Shortest Job First (SJF)

SJF selects the process with the smallest CPU burst time for execution.

Types:
  • Non-preemptive SJF
  • Preemptive SJF (Shortest Remaining Time First)
Advantages:
  • Minimum average waiting time
Disadvantages:
  • Burst time prediction required
  • Starvation of long processes

3. Shortest Remaining Time First (SRTF)

SRTF is the preemptive version of SJF. The CPU is allocated to the process with the smallest remaining execution time.

  • Excellent response time
  • High context switching overhead

4. Priority Scheduling

In priority scheduling, each process is assigned a priority. The process with the highest priority is executed first.

Types:
  • Preemptive Priority Scheduling
  • Non-preemptive Priority Scheduling
Problems:
  • Starvation
  • Priority inversion

Solution: Aging technique

5. Round Robin (RR)

Round robin scheduling assigns a fixed time quantum to each process and executes them in a cyclic order.

  • Preemptive
  • Fair scheduling
  • Used in time-sharing systems
Disadvantage:
  • Performance depends on time quantum size

6. Multilevel Queue Scheduling

Processes are divided into multiple queues based on their type, such as system processes, interactive processes, and batch processes.

  • Each queue has its own scheduling algorithm
  • Rigid structure
  • Starvation may occur

7. Multilevel Feedback Queue (MLFQ)

MLFQ allows processes to move between queues based on their behavior and CPU usage.

  • Dynamic priority
  • Prevents starvation
  • Used in modern operating systems

8. Real-Time Scheduling Algorithms

Rate Monotonic Scheduling (RMS)

A fixed-priority scheduling algorithm where tasks with shorter periods are given higher priority.

Earliest Deadline First (EDF)

A dynamic scheduling algorithm where the task with the earliest deadline is executed first.

Comparison of CPU Scheduling Algorithms

Algorithm Preemptive Starvation Response Time
FCFS No No Poor
SJF Yes / No Yes Good
Priority Yes / No Yes Good
Round Robin Yes No Very Good
MLFQ Yes No Excellent

Conclusion

CPU scheduling algorithms play a crucial role in determining system efficiency and performance. Different algorithms are suitable for batch systems, time-sharing systems, and real-time systems. Understanding these algorithms is essential for students and professionals studying operating systems.

Comments

Popular posts from this blog

A Comparative Study of Deep Learning Architectures for Chest X-Ray Image Classification

Comparative Analysis of Deep Learning Models for Chest X-Ray Image Classification Author: Akrash Noor, Saba Latif & Hifzun Nisa | Published: December 21, 2025 | Category: AI · Medical Imaging · Deep Learning Introduction Medical imaging has become an important aspect in the contemporary healthcare and especially the diagnosis of thoracic diseases utilizing the images of chest X-ray. In recent years, artificial intelligence has advanced significantly, and convolutional neural networks that are based on deep learning have demonstrated impressive results in the domain of automated disease detection and classification. This paper compares and contrasts several deep learning models that are trained on chest X-ray data with PyTorch and TensorFlow in their accuracy, generalization, and computational efficiency. Deep Learning Models Used Custom Convolutional Neural Networks (CNN) ResNet (Residual Networks) DenseNet VGG-styl...

AI-Driven Protein Designer for Cancer Therapy

Deep Learning Based Protein Design for Targeted Cancer Treatment Author: Akrash Noor & Saba  | Published: September 10, 2025 | Category: AI, Bioinformatics, Cancer Therapy This article presents a mathematical and computational overview of an AI-driven protein design framework for cancer therapy . It explains how artificial intelligence can assist in designing novel proteins that selectively target cancer-related biomarkers. 1. Protein Sequence Representation A protein can be represented as a sequence of amino acids: P = (a₁, a₂, a₃, …, aₙ), aᵢ ∈ A n is the length of the protein A represents the 20 standard amino acids Each amino acid is converted into a numerical vector using encoding techniques such as one-hot encoding or learned embeddings: aᵢ → xᵢ ∈ ℝᵈ 2. AI-Based De Novo Protein Generation Protein design is treated as a sequence generation problem: P* = arg max P p(P...

Process vs Threads

Process vs Threads in Operating Systems Process vs Threads in Operating Systems Operating System Course Article Introduction An operating system is responsible for managing system resources and ensuring that multiple programs run efficiently at the same time. Modern systems perform multitasking by executing several activities concurrently. To achieve this, operating systems rely on two fundamental execution units: processes and threads . Although both represent executing tasks, processes and threads differ in memory usage, execution speed, communication methods, and reliability. Understanding these differences is essential for learning CPU scheduling, concurrency, and parallelism. What is a Process? A process is a program that is cur...