From: http://www.ibm.com/developerworks/cn/linux/l-scheduler/
The source code for the 2.6 version scheduler is well encapsulated in the/USR/SRC/LINUX/KERNEL/SCHED.C file. We summarize some useful functions that can be found in this file in table 1.
table 1. Features of the Linux 2.6 scheduler
function name |
functions Description |
schedule |
Scheduler main function. Scheduling the highest priority task execution. |
load_balance |
Check the CPU to see if there is an imbalance and attempt to migrate the task if it is unbalanced. |
effective_prio |
returns the effective priority of a task (based on a static policy, but can contain any rewards and penalties). |
recalc_task_prio |
determines the reward or penalty for a task based on the idle time of the task. |
source_load |
calculates the load of the source CPU (the CPU from which the task was migrated) properly. |
target_load |
calculates the payload of the target CPU (the CPU the task may migrate to) fairly. |
migration_thread |
A high-priority system thread that migrates tasks between CPUs. |
The structure of the running queue can also be found in the/usr/src/linux/kernel/sched.c file. The 2.6 version of the scheduler can also provide some statistics (if enabled CONFIG_SCHEDSTATS
). These statistics can be seen from/proc/schedstat in the/proc file system, which provides a lot of data for each CPU in the system, including load balancing and process migration statistics.
Linux kernel Source read Note 2-2.6 Version Scheduler SCHED.C features