SMP Scheduling

On multiprocessor systems, the kernel must consider a few additional issues in order to ensure good
❑ The CPU load must be shared as fairly as possible over the available processors. It makes little
sense if one processor is responsible for three concurrent applications while another has only the
idle task to deal with.
❑ The affinity of a task to certain processors in the system must be selectable. This makes it possible,
for example, to bind a compute-intensive application to the first three CPUs on a 4-CPU system
while the remaining (interactive) processes run on the fourth CPU.

❑ The kernel must be able to migrate processes from one CPU to another. However, this option
must be used with great care because it can severely impair performance. CPU caches are the
biggest problem on smaller SMP systems. For really big systems, a CPU can be located literally
some meters away from the memory previously used, so access to it will be very costly.
The affinity of a task to particular CPUs is defined in the cpus_allowed element of the task structure
specified above. Linux provides the sched_setaffinity system call to change this assignment.