scheduler_tick - 从哪里调用Linux?

ult*_*use 1 linux schedule interrupt

当处理器有机会获得内核代码并执行维护和调节工作时,我想了解中断机制.我所知道的是,定时器中断为操作系统提供了这种功能.

1)我想知道究竟什么是相关的中断号,以及在Linux情况下调用的第一个OS例程是什么.如果我知道文件和函数名称,那将会很好.

对于Linux,scheduler_tick是调用新任务的内核函数,但是未知的是谁调用scheduler_tick及其父代?

2)是否还有其他中断在Linux中调用scheduler_tick?他们是哪一个,如果有的话?

 /*
   This function gets called by the timer code, with HZ frequency.
   We call it with interrupts disabled.
 */

 void scheduler_tick(void)
 {
         int cpu = smp_processor_id();
         struct rq *rq = cpu_rq(cpu);
         struct task_struct *curr = rq->curr;
.......
Run Code Online (Sandbox Code Playgroud)

osg*_*sgx 6

当您可以访问交叉引用(x-ref)源浏览器时,这很容易回答.

点击这里:http://lxr.linux.no/#linux+v3.6.3/kernel/sched/core.c#L3214获取一个Linux Kernel的在线x-ref项目.(这个不会是x-ref汇编代码.)

此链接转到 scheduler_tick功能定义.单击函数名称,然后在右侧的新面板中选择"函数原型或声明"链接"用法..."后面.一段时间后,将列出提及此功能的所有代码:

 include/linux/sched.h, line 309  << declaration
 kernel/sched/core.c, line 3214   << definition
 kernel/timer.c, line 1373        << calling
Run Code Online (Sandbox Code Playgroud)

所以,timer.c:1373 http://lxr.linux.no/#linux+v3.6.3/kernel/timer.c#L1373update_process_times函数的一部分:

1355 /*
1356  * Called from the timer interrupt handler to charge one tick to the current
1357  * process.  user_tick is 1 if the tick is user time, 0 for system.
1358  */
1359 void update_process_times(int user_tick)
Run Code Online (Sandbox Code Playgroud)

该函数只能从定时器中断处理程序调用; 它应该在每个蜱上调用.

重复交叉引用搜索过程update_process_times以获取列表:

References:
 arch/alpha/kernel/smp.c, line 520 
 arch/arm/kernel/time.c, line 108 
 arch/cris/arch-v10/kernel/time.c, line 171 
 arch/cris/arch-v32/kernel/time.c, line 206 
 arch/h8300/kernel/time.c, line 40 
 arch/ia64/kernel/time.c, line 184 
 arch/m68k/kernel/time.c, line 38 
 arch/parisc/kernel/time.c, line 163 
 include/linux/sched.h, line 308 
 kernel/time/tick-sched.c, line 683 
 kernel/time/tick-sched.c, line 841
Run Code Online (Sandbox Code Playgroud)

相关的中断号码

中断号码与平台有关(有时甚至在启动时分配它们).您没有说出您感兴趣的平台.

2)是否还有其他中断在Linux中调用scheduler_tick?他们是哪一个,如果有的话?

有几种计时器实现,包括hrtimers(高分辨率计时器,这可能与通常的系统计时器不同).每个实现可以使用不同的中断.