Scheduler Enhancements

So far, we have only considered scheduling on real-time systems — naturally, Linux can do slightly better. Besides support for multiple CPUs, the kernel also provides several other enhancements that relate to scheduling, discussed in the following sections. Notice, however, that these enhancements add much complexity to the scheduler, so I will mostly consider simplified situations that illuminate the essential principle, but do not account for all boundary cases and scheduling oddities.

2.8.1 SMP Scheduling

On multiprocessor systems, the kernel must consider a few additional issues in order to ensure good scheduling:

□ 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.

Continue reading here: Extensions to the Data Structures

Was this article helpful?

0 0