All Exams Test series for 1 year @ ₹349 only
Question

Which of the following CPU scheduling algorithms is/are supported by LINUX operating system?

The correct answer is

Preemptive priority scheduling and time sharing CPU scheduling

Understanding Linux CPU Scheduling Algorithms

CPU scheduling is a fundamental concept in operating systems. It determines which process gets access to the CPU at any given time and for how long. The goal of CPU scheduling is to improve system performance, such as increasing throughput, minimizing response time, and ensuring fairness among processes. The Linux operating system, being a complex and versatile system, employs sophisticated CPU scheduling mechanisms to manage system resources efficiently.

What is Preemptive Priority Scheduling?

In preemptive priority scheduling, processes are assigned a priority level. The scheduler always selects the process with the highest priority to run. Preemptive means that if a new process arrives with a higher priority than the currently running process, the running process can be interrupted (preempted) and the higher-priority process is given the CPU.

What is Time-Sharing CPU Scheduling?

Time-sharing scheduling involves dividing the CPU time among multiple processes. Each process is allocated a small slice of CPU time, known as a time slice or quantum. After a process uses its time slice, it is preempted, and the CPU is given to another process. This cycle repeats, creating the illusion that all processes are running concurrently. Time-sharing is often used in interactive systems where users expect timely responses.

Linux Scheduling Mechanisms

Linux has evolved its CPU scheduling algorithms over time. Historically, it used schedulers like the O(1) scheduler. The modern Linux kernel primarily uses the Completely Fair Scheduler (CFS) for normal processes. While CFS is often described as a fair queuing scheduler, it essentially implements time-sharing by ensuring each process gets a fair proportion of the CPU time based on its 'niceness' value (which influences its effective priority). Higher priority processes get more CPU time or smaller wait times.

Linux schedulers are generally preemptive. This means that the scheduler can interrupt a running process if a higher-priority process becomes ready, or if a process exceeds its allocated time slice (in the case of time-sharing).

The combination of handling processes based on priority (even if implicitly through fairness mechanisms) and using time slices to share the CPU among many processes aligns with the concepts of preemptive priority scheduling and time-sharing.

Analyzing the Options

  • Option 1: Non-preemptive priority scheduling - Linux schedulers are primarily preemptive, meaning they can interrupt running processes. So, this option is not entirely accurate on its own.
  • Option 2: Preemptive priority scheduling and time sharing CPU scheduling - This aligns well with how modern Linux schedulers operate. They manage processes based on priority (or fairness derived from priority concepts) and use time-sharing to allow multiple processes to run concurrently. Preemption is a key characteristic.
  • Option 3: Time sharing scheduling only - While Linux uses time-sharing, it also incorporates priority concepts (like 'niceness' values influencing fairness), and importantly, it is preemptive. So, 'time sharing only' is incomplete.
  • Option 4: Priority scheduling only - This is also incomplete. Linux uses priority concepts but combines them with time-sharing and preemption to manage CPU resources effectively for various types of workloads.

Therefore, the description that best fits the nature of CPU scheduling supported by the Linux operating system, considering both its historical and modern implementations (like CFS which balances fairness with priority-like behavior) and its preemptive nature, is a combination of preemptive priority scheduling and time sharing.

Scheduling Concept Linux Implementation Relevance
Preemption Key characteristic of Linux schedulers. Running processes can be interrupted.
Priority Used to influence scheduling decisions (e.g., 'niceness' in CFS affects CPU share).
Time Sharing CPU time is shared among processes, often via time slices (conceptually in CFS via targeted latency).
Non-preemptive Not the primary mode for standard process scheduling in Linux.

Revision Table: Linux CPU Scheduling

Concept Description Linux Support
Preemptive Can interrupt running process Yes
Priority-based Processes scheduled based on priority level Yes (implicitly via 'niceness' in CFS)
Time-Sharing CPU time divided among processes Yes (Implemented via CFS fairness)
Non-Preemptive Process runs until completion or blocks No (for standard processes)

Additional Information: Linux CPU Schedulers

The Linux kernel has had several different CPU schedulers over its history.

  • O(1) Scheduler: Used in kernels 2.6.x before CFS. It aimed for constant time complexity for scheduling decisions regardless of the number of tasks. It also supported preemptive priority scheduling and time-sharing.
  • Completely Fair Scheduler (CFS): The default scheduler since kernel 2.6.23. CFS treats CPU time as a limited resource and aims to provide each process with a fair share of the CPU based on its priority (niceness value). It is a preemptive scheduler and implements time-sharing concepts through its fairness algorithm. It doesn't use fixed time slices but rather targets a latency for each process to run.
  • Real-Time Schedulers: Linux also supports real-time scheduling classes (like SCHED_FIFO and SCHED_RR) which are strictly priority-based and preemptive, designed for applications with strict timing requirements.

While CFS focuses on fairness, its behavior can be influenced by process priorities (niceness values), effectively incorporating aspects of priority scheduling. Combined with its preemptive nature and allocation of CPU time, it embodies both preemptive priority and time-sharing principles for normal processes.

Was this answer helpful?

Important Questions from Process Scheduling - Teaching

  1. Consider the following four processes with the arrival time and length of CPU burst given in milliseconds :

    ProcessArrival TimeBurst Time
    P 108
    P 214
    P 329
    P 435

    The average waiting time for preemptive SJF scheduling algorithm is

  2. Consider the following set of processes and the length of CPU burst time given in milliseconds:

    Process

    CPU Burst time (ms)

    P 1

    5

    P 2

    7

    P 3

    6

    P 4

    4

    Assume that processes being scheduled with Round-Robin Scheduling Algorithm with Time Quantum 4ms. Then the waiting time for P 4is _________ ms.

  3. Consider three intensive processes, which requires 10,20 and 30 units of time and arrive at times 0,2 and 6 respectively. how many context switches are needed if the operating system implements a shortest remaining time first scheduling algorithm? Do not count the context switches at time zero and at the end.

  4. Given CPU time slice of 2 ms and the following list of processes.

    Process

    Burst time (ms)

    Arrival time (ms)

    p 1

    3

    0

    p 2

    4

    2

    p 3

    5

    5

    Find average turnaround time and average waiting time using round-robin CPU scheduling?
  5. In which of the following scheduling criteria, context switching will never take place?

Need Expert Advice?

Start Your Preparation with Prepp Mobile App

Download the app from Google Play & App Store
Download the app from Google Play & App Store
Prepp Mobile App