←Back to Subject
Notes
Notes
Study material and explanations
Diagrams
Diagrams
Visualize concepts easily
Mnemonics
Mnemonics
Tricks to remember faster
One Night Prep
One Night Prep
Short and focused revision
Revision
Revision
Quick summary and key points
Important Questions
Important Questions
Practice most relevant questions
Notes

Multiple-Processor, Real-Time, Multilevel Queue & Multilevel Feedback Queue Scheduling

Study material and explanations for Unit 2

Multiple-Processor, Real-Time, Multilevel Queue & Multilevel Feedback Queue Scheduling

Two CPU cores may run two ready jobs at once. A real-time scheduler must also consider deadlines. In a multilevel feedback queue, a job can move between queues as its behaviour changes, unlike fixed queue membership.

1. Multiple-Processor Scheduling

When a computer system has multiple CPUs (or a Multi-Core Processor), scheduling becomes more complex because multiple processes can run in parallel at the same time.

Two Approaches to Multiple-Processor Scheduling:

  1. Asymmetric Multiprocessing (AMP): A single processor (the Master Server) handles all scheduling decisions, I/O processing, and system activities, while the other processors (Slaves) execute only user code. It is simple because only one core accesses kernel data structures, but the Master CPU can become a bottleneck.
  2. Symmetric Multiprocessing (SMP — Standard Today): Every processor is self-scheduling. All CPUs either share a single common Ready Queue (protected by locks) or each CPU has its own private Ready Queue.

Two Key Issues in SMP Scheduling:

  • Processor Affinity: When a process runs on CPU Core 1, its data fills up Core 1’s high-speed Cache Memory. If the process is migrated to Core 2, Core 1’s cache is wasted and Core 2 must reload everything from RAM! Therefore, SMP systems try to keep a process running on the same processor (Soft Affinity or strict Hard Affinity).
  • Load Balancing: Ensures that one CPU core isn’t sitting idle while another core has 10 processes waiting in its queue. Achieved via Push Migration (busy CPU pushes tasks to idle CPU) or Pull Migration (idle CPU pulls waiting tasks from a busy CPU).

2. Real-Time CPU Scheduling

In Real-Time Operating Systems (RTOS), processes have strict Deadlines by which they must complete:

  • Soft Real-Time Scheduling: Guarantees that critical real-time processes are given higher priority than non-critical processes, though it does not guarantee when they will be scheduled.
  • Hard Real-Time Scheduling: A process must be serviced before its deadline expires; once admitted, the OS guarantees on-time completion using two famous algorithms:

Rate-monotonic scheduling gives shorter-period tasks higher fixed priority. Earliest-deadline-first changes priority according to the nearest deadline.

  • 1. Rate-Monotonic (RM) Scheduling — Static Priority algorithm for periodic tasks
  • 2. Earliest-Deadline-First (EDF) — Dynamic Priority algorithm

View diagram · Figure 2.7: Two Classical Hard Real-Time Scheduling Algorithms


3. Multilevel Queue (MLQ) Scheduling

In real operating systems, all processes are not alike! For example, System processes (kernel tasks), Interactive GUI processes (foreground apps), and Batch jobs (background backups) have completely different response-time needs. Putting all of them into a single Ready Queue with one algorithm does not work well.

How Multilevel Queue (MLQ) Scheduling Works:

  1. The Ready Queue is partitioned into several separate, permanent queues based on the type/priority of processes.
  2. A process is permanently assigned to one queue when it enters the system (based on process type, memory size, or priority) and CANNOT move to another queue!
  3. Each queue has its own independent scheduling algorithm (e.g., Interactive queue uses Round Robin, while Batch queue uses FCFS).

A multilevel queue places jobs in classes with their own scheduling rules. A separate rule decides which queue gets the processor.

  • System Processes Queue — Kernel & OS tasks — Scheduled using Priority / RR
  • Interactive Processes (Foreground) — GUI & User apps — Scheduled using Round Robin (RR)
  • Interactive Editing Processes — Text editors & IDEs — Scheduled using RR / SJF
  • Batch Processes (Background) — Backups & Long jobs — Scheduled using FCFS

Scheduling Between the Queues in MLQ:

How does the CPU divide its time among the different queues? Using one of two methods:

  1. Fixed-Priority Preemptive Scheduling: No process in the Batch queue can run unless the System and Interactive queues above it are 100% empty! (Drawback: Can cause Starvation of lower queues).
  2. Time-Slicing Between Queues: Each queue gets a guaranteed percentage of CPU time—for example, the Foreground Interactive queue gets 80% of CPU time (using Round Robin), and the Background Batch queue gets 20% of CPU time (using FCFS).

View diagram · Figure 2.8: Multilevel Queue (MLQ) Scheduling Architecture


4. Multilevel Feedback Queue (MLFQ) Scheduling

Why Was MLFQ Invented?

In standard Multilevel Queue (MLQ) scheduling, processes are permanently locked into one queue (inflexible) and low-priority queues can starve.

Multilevel Feedback Queue (MLFQ) Scheduling solves this by allowing a process to move (migrate) UP or DOWN between queues dynamically based on its actual runtime CPU burst behavior!

Feedback allows a process to move between priority queues as it runs or waits. Its recent behaviour can therefore affect the next time it receives CPU service.

How Multilevel Feedback Queue (MLFQ) Works:

  1. New Process Entry: Every new process enters at the top Queue 0 and is given a short time quantum of 8 ms (Round Robin).
    • If it is a short/interactive I/O process, it finishes within 8 ms and leaves immediately!
  2. Demotion (Punishing CPU Hogs): If the process does not finish within 8 ms, it is preempted and moved down (demoted) to Queue 1, where it gets a larger quantum of 16 ms.
  3. If it still does not finish in 16 ms, it is demoted to Queue 2 (FCFS) at the bottom.
  4. Promotion (Preventing Starvation via Aging): If a process waits too long in a lower queue (Queue 2) without getting the CPU, the OS promotes (upgrades) it back up to a higher-priority queue!

View diagram · Figure 2.9: Multilevel Feedback Queue (MLFQ) — Processes Move Between Queues


5. Comparison: Multilevel Queue (MLQ) vs Multilevel Feedback Queue (MLFQ)

This is a favorite 5- to 8-mark comparison question in DAVV BCA exams!

Basis Multilevel Queue (MLQ) Multilevel Feedback Queue (MLFQ)
1. Process Movement Processes are permanently assigned to one queue and cannot move between queues. Processes can move freely UP and DOWN between different queues based on CPU behavior.
2. Flexibility Rigid and Inflexible (requires knowing process nature in advance). Highly Flexible and Adaptive (learns whether a job is CPU-bound or I/O-bound automatically).
3. Starvation Risk High risk of Starvation for lower-priority queues under fixed priority. Prevents Starvation by promoting (aging) processes that wait too long in lower queues.
4. Design Complexity Simple to implement with low overhead. The most general and complex scheduling algorithm (used in Windows, macOS, and Linux variants).

💡 Exam Preparation Tips for DAVV BCA

  • Always draw Figure 2.8 for Multilevel Queue and Figure 2.9 (Q0: q=8ms → Q1: q=16ms → Q2: FCFS) for Multilevel Feedback Queue! That classic 8 ms → 16 ms → FCFS diagram is straight from Silberschatz (Galvin) and examiners love it.
  • Remember the 1-line difference: MLQ = No movement between queues; MLFQ = Processes move between queues based on feedback.