调度整体过程
周期性调度过程我们从 在timer.c中开始分析
void update_process_times(int user_tick)
{
struct task_struct *p = current;
/* Note: this timer irq context must be accounted for as well. */
account_process_tick(p, user_tick);
run_local_timers();
rcu_check_callbacks(user_tick);
scheduler_tick();
run_posix_cpu_timers(p);
}
timer定时器每次都会调用 scheduler_tick();
void scheduler_tick(void)
{
int cpu = smp_processor_id();
struct rq *rq = cpu_rq(cpu);
struct task_struct *curr = rq->curr;
sched_clock_tick();
raw_spin_lock(&rq->lock);
update_rq_clock(rq);
curr->sched_class->task_tick(rq, curr, 0);
update_cpu_load_active(rq);
calc_global_load_tick(rq);
sched_freq_tick(cpu);
raw_spin_unlock(&rq->lock);
perf_event_task_tick();
rq_last_tick_reset(rq);
}
然后在 scheduler_tick(); 中会调度不同的任务。就是这么简单
而调用update_process_times 的情况大致流程如下图。