Starting from the defects of Linux 2.4 scheduling system, this paper analyzes the principle and implementation details of Linux 2.6 scheduling system, and analyzes and evaluates the load balance, NUMA structure and real-time performance related to scheduling system. At the end of this paper, from the development and implementation of the dispatching system, the author puts forward his own views on the development characteristics and direction of Linux.
1. Preface
Linux has a very wide market, from desktop workstations to low-end servers, and it is a powerful competitor to any commercial operating system. Linux is now fully committed to embedded systems and high-end server systems, but its technical flaws limit its competitiveness: lack of support for real-time tasks and poor multiprocessor scalability. One of the key reasons for these two weaknesses in the 2.4 kernel is the design flaws of the scheduler.
2.6 Scheduling system from the beginning of the design of the development focus on better meet real-time and multiprocessor parallelism, and basically achieve its design goals. The main designer, legendary character Ingo Molnar the characteristics of the new scheduling system as follows:
Inherit and carry forward the features of version 2.4 Scheduler:
Interactive Job First
High performance of scheduling/wake-up under light load conditions
Fair sharing
Scheduling based on priority level
High CPU usage
SMP High Affinity
Scheduling methods such as real-time scheduling and CPU binding
New features on this basis:
O (1) Scheduling algorithm, scheduler cost is constant (regardless of current system load), real-time performance is better
High scalability, large reduction of lock granularity
New design of SMP affinity method
Optimizing scheduling of compute-intensive batch jobs
More smooth scheduler work under overloaded conditions
Other improvements such as child processes running before the parent process
In the 2.5.x test version, the development of the new scheduler has been widely concerned, and it is proved that the performance of the system has been greatly improved. In this paper, the new design of the data structure, around 2.6 for 2.4 of the improvement, the 2.6 Scheduling system principles and implementation details of the analysis. 2.6 Scheduler design is quite complex, there are many need to continue to study the place, especially the scheduling parameters, as the core version of the upgrade, may continue to amend.
2. The new data structure Runqueue
We know that in the 2.4 kernel, the Ready process queue is a global data structure, all operations of the scheduler will cause the system to wait between processors because of the global spin lock, making the ready queue an obvious bottleneck.
The 2.4 ready queue is a simple runqueue_head-headed two-way list, in 2.6, the ready queue is defined as a much more complex data structure struct runqueue, and, crucially, each CPU will maintain a ready queue of its own-- This will greatly reduce competition.
O (1) Many key technologies in the algorithm are related to Runqueue, so our analysis of the scheduler starts with the RUNQUEUE structure first.