Course contentsShow
← Linux
Lesson 500 of 1,8195. Process Management and SignalingFree lesson

Inter-Processor Interrupts (IPI)

Explain how multiple CPU cores coordinate during process migration and load balancing.

In this lesson, you will learn how Linux uses Inter-Processor Interrupts (IPIs) to force coordination between CPU cores when balancing the workload of processes.

The Problem of Multicore Coordination

When you have a multicore system, each CPU core maintains its own local runqueue—a list of processes waiting for execution time. However, these queues can quickly become unbalanced. One CPU might be overwhelmed with heavy tasks while another sits idle. To fix this, the Linux kernel periodically triggers load balancing, where it "steals" processes from a busy CPU and moves them to a quieter one.

Because CPU A cannot simply reach into the memory of CPU B and yank a process away (that would lead to total system instability), it must use an Inter-Processor Interrupt (IPI).

How IPIs Enable Migration

An IPI is a specialized hardware signal that one CPU uses to interrupt another. Think of it as a "digital tap on the shoulder." When the scheduler decides that a process needs to move from CPU A to CPU B, it performs these steps:

  1. Request: CPU A sends an IPI to CPU B.
  2. Interrupt: CPU B receives the hardware signal and immediately pauses its current activity to enter an IPI-handling routine.
  3. Synchronization: The handler on CPU B helps facilitate the migration, ensuring the process’s state is safely saved and handed over.
  4. Resumption: Once the handoff is complete, CPU B returns to its previous task.

This ensures that the two cores remain in sync without needing a global lock that would freeze the entire system.

A Conceptual View

You can imagine the kernel logic looking something like this:

// Triggering an IPI to balance the load
if (needs_load_balance()) {
    // Send an IPI to the target CPU to request a migration
    send_ipi_to_cpu(target_cpu_id, IPI_RESCHEDULE);
}

By using IPIs, the scheduler ensures that process migration is handled safely and effectively, keeping your system responsive even under heavy, fluctuating workloads.

Key Takeaway: Inter-Processor Interrupts provide the communication mechanism that allows busy CPUs to signal others to assist with process migration and maintain global scheduler fairness.