Multi
Multi
A Multi-processor is a system that has more than one processor but shares the same
memory, bus, and input/output devices. In multi-processor scheduling, more than one
processors(CPUs) share the load to handle the execution of processes smoothly.
The scheduling process of a multi-processor is more complex than that of a single processor
system. The CPUs may be of the same kind(homogeneous) or different(heterogeneous).
The multiple CPUs in the system share a common bus, memory, and other I/O
devices. There are two approaches to multi-processor scheduling –
Processor Affinity
A process has an affinity for a processor on which it runs. This is
called processor affinity.
When a process runs on a processor, the data accessed by the process most recently is
populated in the cache memory of this processor. The following data access calls by
the process are often satisfied by the cache memory.
However, if this process is migrated to another processor for some reason, the content
of the cache memory of the first processor is invalidated, and the second processor's
cache memory has to be repopulated.
To avoid the cost of invalidating and repopulating the cache memory, the Migration
of processes from one processor to another is avoided.
There are two types of processor affinity.
Soft Affinity: The system has a rule of trying to keep running a process on the same
processor but does not guarantee it. This is called soft affinity.
Hard Affinity: The system allows the process to specify the subset of processors on
which it may run, i.e., each process can run only some of the processors. Systems
such as Linux implement soft affinity, but they also provide system calls such as
sched_setaffinity() to support hard affinity.
Load Balancing
In a multi-processor system, all processors may not have the same workload. Some may have
a long ready queue, while others may be sitting idle. To solve this problem, load
balancing comes into the picture. Load Balancing is the phenomenon of distributing
workload so that the processors have an even workload in a symmetric multi-processor
system.
In symmetric multiprocessing systems which have a global queue, load balancing is not
required. In such a system, a processor examines the global ready queue and selects a process
as soon as it becomes ideal.
However, in asymmetric multi-processor with private queues, some processors may end up
idle while others have a high workload. There are two ways to solve this.
Push Migration: In push migration, a task routinely checks the load on each processor. Some
processors may have long queues while some are idle. If the workload is unevenly
distributed, it will extract the load from the overloaded processor and assign the load to an
idle or a less busy processor.
Pull Migration: In pull migration, an idle processor will extract the load from an overloaded
processor itself.