Multiprocessor Scheduling in Operating System Explained With Examples

Operating System · Chapter 17

Multiprocessor Scheduling in Operating System Explained With Examples

In a single-processor system, the operating system mainly decides which ready process should use the CPU next. But modern computers may have several processor cores or logical CPUs available at the same time. Now the operating system has an extra problem: it must decide not only which task should run, but also which processor should run that task.

This is called Multiprocessor Scheduling in Operating System. Important topics include Asymmetric Multiprocessing, Symmetric Multiprocessing, global and per-CPU run queues, processor affinity, load balancing, push migration, pull migration, multicore scheduling, NUMA and processor migration. We will connect all of them step by step in very simple language.

Quick Answer: Multiprocessor scheduling is the method used by an operating system to distribute runnable processes or threads across multiple processors, cores or logical CPUs. The scheduler tries to keep processors usefully busy while also considering load balance, CPU affinity, cache locality, migration cost and hardware topology. In asymmetric multiprocessing, one processor may control important scheduling work, while in symmetric multiprocessing, processors participate more equally in scheduling and task execution.
MULTIPROCESSOR SCHEDULING CONTROL CENTER
Runnable Tasks
P1
P2
P3
P4
P5
OS
SCHEDULER
Choose CPU
Available CPUs
CPU 0
CPU 1
CPU 2
CPU 3

What Is Multiprocessor Scheduling in Operating System?

Multiprocessor Scheduling in Operating System Explained With Examples

Multiprocessor Scheduling in Operating System means scheduling processes or threads when more than one processor or processing unit is available.

The system must decide which runnable task should execute and on which processor that task should run.

Simple Definition:
Multiprocessor scheduling is the process of assigning and scheduling runnable tasks across multiple CPUs or cores so that processor resources are used efficiently.

Why Is Multiprocessor Scheduling More Difficult?

Task Selection Which process or thread should run next?
CPU Selection On which processor should that task run?
Load Balance Are some processors overloaded while others are idle?
Affinity Should a task remain on the processor it used earlier?
Topology Are all processors and memory locations equally close?
Migration Cost Will moving the task improve performance enough to justify the cost?

Single-Processor vs Multiprocessor Scheduling

Single Processor

Only one CPU execution resource is considered in the basic model.

The scheduler mainly decides: Which ready task should run next?

VS

Multiprocessor System

Several processors, cores or logical CPUs may execute tasks.

The scheduler must decide: Which task should run and where should it run?

The Main Multiprocessor Scheduling Problem

Suppose a system has four processors.

If CPU 0 and CPU 1 are extremely busy while CPU 3 has almost no work, the hardware is not being used efficiently.

Example CPU Load
CPU 0
90% Load
CPU 1
75% Load
CPU 2
35% Load
CPU 3
10% Load

A multiprocessor scheduler may try to redistribute runnable tasks so that the processors are used more effectively.

Asymmetric and Symmetric Multiprocessing Scheduling

Two important approaches traditionally used to explain multiprocessor scheduling in OS are Asymmetric Multiprocessing (AMP) and Symmetric Multiprocessing (SMP).

AMP

Asymmetric Multiprocessing

In asymmetric multiprocessing, processors do not necessarily perform the same operating-system responsibilities.

One processor may act as a master and handle scheduling or other system tasks, while other processors execute work assigned to them.

SMP

Symmetric Multiprocessing

In symmetric multiprocessing, processors participate more equally.

Each processor may execute operating-system code and participate in scheduling, subject to the operating system's implementation.

Asymmetric Multiprocessing Example

MASTER CPU
Scheduler + Control
CPU 1 · Worker
CPU 2 · Worker
CPU 3 · Worker

Symmetric Multiprocessing Example

Scheduling / Runnable Work
CPU 0
CPU 1
CPU 2
CPU 3

Asymmetric vs Symmetric Multiprocessing

Point Asymmetric Multiprocessing Symmetric Multiprocessing
Control One processor may have a special master/control role Processors can participate more equally
Scheduling Master processor may control task assignment Scheduling work can be distributed
Complexity Conceptually simpler central control Requires coordination among CPUs and shared kernel data
Scalability Master can become a bottleneck Better suited to general multiprocessor scaling

Global Run Queue vs Per-CPU Run Queue

A major design question in multiprocessor scheduling is: Where should runnable tasks wait?

Global Run Queue

All runnable tasks can conceptually wait in one shared queue or shared scheduling structure.

P1
P2
P3
P4
P5
CPU 0
CPU 1
CPU 2

This can make work distribution conceptually easy, but a heavily shared scheduling structure may create contention as the processor count grows.

Per-CPU Run Queues

Each CPU keeps its own runnable-task queue.

CPU0: P1 P2
CPU1: P3
CPU2: P4 P5

This can reduce contention and improve locality, but now the operating system must make sure the queues do not become badly unbalanced.

Processor Affinity in Multiprocessor Scheduling

Suppose a process runs on CPU 2. While it runs, useful instructions and data may enter CPU 2's caches.

If the scheduler immediately moves that process to CPU 0, CPU 0 may not have the same useful cached data.

For this reason, operating systems often try to keep a task on the same CPU when practical. This idea is called processor affinity or CPU affinity.

Processor Affinity Definition:
Processor affinity is the tendency or restriction that keeps a process or thread running on a particular CPU or set of CPUs.
Task P1 Affinity
CPU 0
CPU 1
✓ preferred
CPU 2
CPU 3
Why keep P1 on CPU 1?
Its useful code and data may already be present in CPU 1's cache.
Why move P1?
CPU 1 may become overloaded while another allowed processor is idle.
The scheduler must balance:
cache locality vs load balancing.

Soft Affinity vs Hard Affinity

Soft Processor Affinity

The scheduler tries to keep a task on the same processor when practical, but the task may still migrate if scheduling conditions require it.

Hard Processor Affinity

A task is explicitly restricted to a selected CPU or set of CPUs through an affinity mask or similar mechanism.

On Linux, an affinity mask defines the CPUs on which a thread is eligible to run. Restricting execution can improve locality in suitable workloads, but it also limits the scheduler's freedom to move the task.

Why Can Processor Migration Be Expensive?

Stay on CPU 1

The process may reuse useful data already stored in CPU 1's cache.

Warm Cache
→

Move to CPU 3

CPU 3 may need to fetch the process's working data again.

Possible Locality Cost

Therefore, moving a process simply because another CPU is slightly less busy is not always free.

Multiprocessor scheduling is a trade-off between load distribution and locality.

Load Balancing in Multiprocessor Scheduling

Load balancing in Operating System means distributing runnable work across processors so that some CPUs do not remain heavily overloaded while others remain unnecessarily idle.

LOAD BALANCING MONITOR
CPU 0 P1 P2 P3 P4
CPU 1 P5 P6
CPU 2 P7
CPU 3 IDLE
LOAD
BALANCE
CPU 0 P1 P2
CPU 1 P5 P6
CPU 2 P7 P3
CPU 3 P4
Important: Perfectly equal task counts do not automatically mean perfectly equal load. Two processes can require very different amounts of CPU time.

Push Migration and Pull Migration

Textbooks commonly explain multiprocessor load balancing using two ideas: push migration and pull migration.

Push Migration

A scheduler or balancing mechanism notices that one processor is overloaded and moves some runnable work away from it.

Busy CPU
Less Busy CPU

The work is effectively pushed away from the busy processor.

Pull Migration

An idle or lightly loaded processor looks for runnable work available on another processor.

Busy CPU
Idle CPU

The idle processor effectively pulls work toward itself.

Push Migration vs Pull Migration

Point Push Migration Pull Migration
Triggered By Overloaded side / balancing mechanism Idle or underloaded processor
Main Idea Move tasks away from busy CPU Bring runnable tasks to idle CPU
Goal Improve distribution of runnable work

Multiprocessor Scheduling Example With Two CPUs

Let us understand the basic idea with a simple example.

Assume all four processes arrive at time 0 and we have two identical CPUs.

TWO-PROCESSOR SCHEDULING EXAMPLE
P1 Burst = 6
P2 Burst = 4
P3 Burst = 3
P4 Burst = 2

Step 1

At time 0, both CPUs are free. CPU 0 can start P1 while CPU 1 starts P2.

Step 2

P2 finishes at time 4, so CPU 1 can immediately start P3.

Step 3

P1 finishes at time 6. P4 can then run on CPU 0.

CPU 0
P1 · 0–6
P4 · 6–8
CPU 1
P2 · 0–4
P3 · 4–7
Idle · 7–8
Both processors perform useful work at the same time. All four processes finish by time 8 in this simple assignment.

This simple example is not meant to represent every real multiprocessor scheduler. It only shows the important idea: different tasks can execute simultaneously on different processors.

Multiprocessor Scheduling and Multicore Processors

Modern systems often contain several CPU cores inside one physical processor package.

From a scheduling point of view, these cores provide multiple execution resources, although their caches and hardware topology may differ.

Multicore Processor

One physical processor package may contain several execution cores.

Core 0
Core 1
Core 2
Core 3

Logical CPUs / SMT

Some physical cores can expose more than one hardware execution context. This is commonly called Simultaneous Multithreading (SMT).

Core 0 · T0
Core 0 · T1
Core 1 · T0
Core 1 · T1

How SMT Affects Scheduling

Two logical CPUs that belong to the same physical core may share some underlying core resources.

Therefore, two logical CPUs are not always equivalent to two completely independent physical cores in performance.

A topology-aware scheduler can consider relationships between:

  • logical hardware threads,
  • physical cores,
  • shared caches,
  • processor packages,
  • and NUMA nodes.

NUMA and Multiprocessor Scheduling

On larger systems, memory access time may depend on which processor accesses which memory.

This architecture is called Non-Uniform Memory Access (NUMA).

NUMA Node 0
CPU 0
CPU 1
Local Memory A
NUMA Node 1
CPU 2
CPU 3
Local Memory B

CPU 0 may access memory in Node 0 more efficiently than memory attached to another NUMA node.

Therefore, a scheduler may try to keep a task near the memory it frequently uses. This is called maintaining NUMA locality.

In real systems, multiprocessor scheduling is not only about keeping every CPU busy. Where a task runs can also matter.

Processor Affinity and NUMA Locality

Processor affinity becomes even more important on NUMA systems.

Moving a process from one NUMA node to another may place the process far from the memory pages it frequently accesses.

A scheduler therefore has to consider:

CPU Load Is the current processor overloaded?
Cache Locality Does the current CPU have useful cached data?
NUMA Locality Is the task close to its frequently used memory?
Migration Cost Is moving the task actually worth it?

Linux documentation notes that its scheduler understands NUMA topology and tries to reduce unnecessary movement across distant scheduling domains, while administrators can also use affinity and NUMA policies to influence placement. :contentReference[oaicite:1]{index=1}

What Is Gang Scheduling?

Some parallel applications contain a group of related threads that frequently communicate or synchronize with each other.

Gang scheduling is the idea of scheduling related threads to execute at the same time on different processors when possible.

Parallel Application Gang
Thread 1
→ CPU 0
Thread 2
→ CPU 1
Thread 3
→ CPU 2
Thread 4
→ CPU 3

The purpose is to reduce situations where one related thread is running while another thread it depends on is waiting for CPU time.

Homogeneous vs Heterogeneous Multiprocessor Scheduling

Homogeneous Processors

Processing units have similar capabilities. A task can usually run on any suitable processor.

Heterogeneous Processors

Processing units may have different performance, power or instruction capabilities. The scheduler may need to choose a processor that matches the task.

This becomes important in modern systems containing combinations of performance-oriented and efficiency-oriented cores.

Goals of Multiprocessor Scheduling

Utilization Avoid leaving useful processors idle when runnable work exists.
Balance Avoid severe overload on one CPU while another is mostly idle.
Locality Preserve useful cache and memory locality when possible.
Fairness Give eligible tasks reasonable access to processor time.
Scalability Scheduling itself should not become a major bottleneck as CPU count grows.
Low Overhead Avoid unnecessary migrations and synchronization work.

Load Balancing vs Processor Affinity

These two goals can sometimes conflict.

Load Balancing Says

Move a task from an overloaded CPU to an idle CPU.

VS

Affinity Says

Keep the task on its current CPU because its cache and memory locality may be useful.

A good multiprocessor scheduler tries to find a useful balance between even work distribution and keeping execution local.

Task Migration in Multiprocessor Scheduling

When a task moves from one processor's scheduling context to another processor, this is called task migration or processor migration.

Migration may happen because:

  • the current CPU is overloaded,
  • another CPU becomes idle,
  • affinity rules change,
  • system topology or power policy changes,
  • or a scheduler decides another placement is better.
Migration can improve load balance, but excessive migration can damage cache locality and create extra scheduling overhead.

How Real Operating Systems Handle CPU Placement

Real schedulers are much more advanced than simple classroom diagrams.

For example, Linux organizes CPUs into scheduling domains that represent groups across which load balancing can occur. The scheduler can redistribute tasks when processors become unevenly loaded, while affinity and cpuset rules restrict where a task is allowed to run. :contentReference[oaicite:2]{index=2}

Linux also exposes CPU affinity controls. An affinity mask specifies the CPUs on which a thread is eligible to execute, and changing the mask can cause a thread to migrate if it is currently running on a disallowed CPU. :contentReference[oaicite:3]{index=3}

For semester exams, you do not need to memorize Linux kernel internals. Use them only to understand that affinity, topology and load balancing are real scheduling concerns—not just textbook words.

Why Doesn't the OS Keep Every CPU Exactly Equally Loaded?

Perfect equality can actually cost more than it saves.

Imagine CPU 0 has slightly more work than CPU 1. Moving a process just to make the load numbers identical may:

Lose Cache Data The process may leave useful cached information behind.
Create Migration Work The scheduler must update placement and scheduling state.
Reduce NUMA Locality The process may become farther from its memory.
Create Scheduler Overhead Constant balancing itself uses CPU time.

So the goal is normally useful balance, not mathematical perfection.

Performance Factors in Multiprocessor Scheduling

CPU Utilization How well are available processing resources being used?
Throughput How much useful work completes over time?
Response Time How quickly does interactive work receive CPU service?
Migration Rate Are tasks moving more often than necessary?
Cache Locality Can tasks reuse useful cached data?
Scalability Does scheduling remain efficient as CPU count increases?

Common Mistakes Students Make

×
Thinking multiprocessor scheduling only means running more processes.
The scheduler also has to decide processor placement.
×
Thinking SMP means one master CPU controls everything.
That description belongs more closely to asymmetric multiprocessing.
×
Thinking load balancing means equal process count.
Different processes can create very different CPU loads.
×
Thinking moving a process between CPUs is free.
Migration can reduce cache and memory locality.
×
Thinking hard affinity and soft affinity are identical.
Soft affinity is a preference; hard affinity explicitly restricts eligible CPUs.
×
Thinking multicore and SMT are the same.
Multiple physical cores and multiple hardware threads on one core are different concepts.
×
Ignoring NUMA.
On larger systems, memory location can affect the quality of CPU placement.

Complete Multiprocessor Scheduling Flow

1. Runnable A process or thread becomes ready.
2. Select Scheduler decides which task should run.
3. Place Scheduler chooses an allowed CPU.
4. Execute The processor runs the task.
5. Balance Scheduler checks whether processors are unevenly loaded.
6. Migrate A task may move if the benefit is worth the cost.

Multiprocessor Scheduling Exam Preparation

OPERATING SYSTEM · CHAPTER 17 · EXAM MODE

For a 2-Mark Question

Answer: Multiprocessor scheduling is the process of scheduling runnable tasks across two or more processors or CPU cores. The operating system decides which task should execute and on which processor.

For a 5-Mark Question

Explain:

  1. definition of multiprocessor scheduling
  2. Asymmetric Multiprocessing
  3. Symmetric Multiprocessing
  4. processor affinity
  5. load balancing

For a 10-Mark Question

Write in this order:

  1. meaning of Multiprocessor Scheduling in Operating System
  2. single-processor vs multiprocessor scheduling
  3. AMP and SMP
  4. global vs per-CPU run queues
  5. processor affinity
  6. soft and hard affinity
  7. load balancing
  8. push migration
  9. pull migration
  10. multicore and SMT scheduling
  11. NUMA locality
  12. migration cost
  13. simple multiprocessor example

Important Diagram

In a long-answer question, draw either:

  • AMP master-worker diagram,
  • SMP CPU scheduling diagram,
  • processor affinity diagram,
  • or push/pull load balancing diagram.

Multiprocessor Scheduling Practice Questions

Q1. What is Multiprocessor Scheduling in Operating System?
Q2. Why is multiprocessor scheduling more difficult than single-processor scheduling?
Q3. What is Asymmetric Multiprocessing?
Q4. What is Symmetric Multiprocessing?
Q5. Differentiate AMP and SMP.
Q6. What is a global run queue?
Q7. What are per-CPU run queues?
Q8. What is processor affinity?
Q9. Differentiate soft and hard processor affinity.
Q10. Why can CPU migration reduce cache performance?
Q11. What is load balancing?
Q12. What is push migration?
Q13. What is pull migration?
Q14. Why can load balancing conflict with processor affinity?
Q15. What is task migration?
Q16. What is NUMA scheduling?
Q17. What is gang scheduling?
Q18. How does multicore hardware affect scheduling?
Q19. What is SMT in multiprocessor scheduling?
Q20. Why is perfect load balance not always desirable?

Multiprocessor Scheduling Quick Revision

Multiprocessor Scheduling: schedules work across multiple processing units.
AMP: one processor can have a special master role.
SMP: processors participate more symmetrically.
Global Queue: runnable work shares a common scheduling structure.
Per-CPU Queue: each CPU keeps its own runnable tasks.
Processor Affinity: preference or restriction for CPU placement.
Soft Affinity: scheduler tries to preserve CPU placement.
Hard Affinity: task is restricted to allowed CPUs.
Load Balancing: redistributes runnable work across CPUs.
Push Migration: busy side moves work outward.
Pull Migration: idle CPU pulls available work.
Task Migration: task moves from one CPU to another.
Cache Affinity: staying on a CPU can preserve useful cached data.
Multicore: several cores exist within a processor package.
SMT: a physical core exposes multiple hardware execution contexts.
NUMA: memory access cost depends on processor-memory location.
Gang Scheduling: related threads are scheduled together.
Main Trade-Off: balance vs locality.

Frequently Asked Questions About Multiprocessor Scheduling

What is Multiprocessor Scheduling in Operating System?

Multiprocessor scheduling is the operating-system process of assigning and scheduling runnable tasks across multiple processors, cores or logical CPUs.

Why is multiprocessor scheduling needed?

It is needed because when several processors are available, the operating system must decide not only which task should run but also where that task should run.

What is Asymmetric Multiprocessing?

In asymmetric multiprocessing, one processor may have a special master or control role, while other processors perform work assigned to them.

What is Symmetric Multiprocessing?

Symmetric multiprocessing is a design in which processors participate more equally in running tasks and operating-system work.

What is processor affinity?

Processor affinity is the preference or restriction that keeps a process or thread on a particular processor or set of processors.

What is soft processor affinity?

Soft affinity means the scheduler tries to keep a task on the same processor for locality, but the task may still move when required.

What is hard processor affinity?

Hard affinity explicitly restricts a task to a defined CPU or set of CPUs.

What is load balancing in multiprocessor scheduling?

Load balancing is the process of distributing runnable work across CPUs so that some processors do not remain heavily overloaded while other eligible processors remain unnecessarily idle.

What is push migration?

Push migration happens when work is moved away from an overloaded processor toward another processor.

What is pull migration?

Pull migration happens when an idle or underloaded processor takes runnable work from another processor.

What is the difference between processor affinity and load balancing?

Processor affinity tries to preserve useful task placement, while load balancing may move a task to improve distribution of processor load.

What is task migration in Operating System?

Task migration means moving a runnable process or thread from one processor's scheduling context to another processor.

What is a global run queue?

A global run queue is a shared scheduling structure from which multiple processors can obtain runnable work.

What are per-CPU run queues?

Per-CPU run queues mean each CPU maintains its own runnable-task queue, with load balancing used when work becomes unevenly distributed.

Why is CPU affinity useful?

CPU affinity can preserve cache and memory locality by reducing unnecessary migration between processors.

What is NUMA in multiprocessor scheduling?

NUMA stands for Non-Uniform Memory Access. In NUMA systems, memory access cost can depend on which CPU accesses which memory node, so the scheduler may consider memory locality when placing tasks.

What is gang scheduling?

Gang scheduling is a technique in which related threads of a parallel application are scheduled to run together on different processors when possible.

Why is task migration not always good?

Migration can improve load balance, but it may also reduce cache locality, worsen NUMA locality and create additional scheduler overhead.

What is SMT in multiprocessor scheduling?

SMT stands for Simultaneous Multithreading. It allows one physical processor core to expose multiple hardware execution contexts that the operating system can see as logical CPUs.

Conclusion

Multiprocessor Scheduling in Operating System is more than simply giving work to several CPUs. The operating system must decide which task should run, which processor should run it, and whether moving the task will actually improve performance.

In Asymmetric Multiprocessing, one processor may perform a special control role. In Symmetric Multiprocessing, processors participate more equally. Modern systems commonly need additional ideas such as global or per-CPU run queues, processor affinity, load balancing, push migration and pull migration.

Processor affinity helps preserve cache locality, while load balancing tries to avoid overloaded and idle processors. These goals can conflict, which is why task migration must be used carefully.

On modern multicore and NUMA systems, the scheduler may also consider physical cores, logical CPUs, shared caches and memory locality. So the easiest way to remember the complete chapter is: multiprocessor scheduling = task selection + CPU placement + balance + locality.

Post a Comment

0 Comments
* Please Don't Spam Here. All the Comments are Reviewed by Admin.
Join Telegram Exam updates and free resources