Linux内核多核问题

时间:2013-10-12 02:55:52

标签: linux linux-kernel interrupt scheduler multicore

我对某些Linux内核调度有些怀疑。

1) Does linux kernel(schedular to be specific) always runs on CPU-0?
2) One Scenario:    
   One kernel thread running on CPU - 0, goes into sleep with interrupts disabled.    
   In this case, will the schedular run on other CPU? 
   if Yes, how is the selection made out of the remaining core so as to which will run     
   the schedular, is this decision made while disabling interrupts on CPU - 0?

2 个答案:

答案 0 :(得分:3)

调度程序只是一段代码(特别是schedule()函数)。 与内核的大多数其他部分一样,它可以在任何CPU上运行。

当某个线程想要休眠或处理完中断后调用调度程序;这可能发生在所有CPU上。

答案 1 :(得分:1)

1)linux内核(特定的调度程序)是否总是在CPU-0上运行?     (不,调度程序可以在任何CPU核心上运行。)

2)一种情景:
   在CPU-0上运行的一个内核线程在禁用中断的情况下进入休眠状态    在这种情况下,调度程序是否会在其他CPU上运行?     (在CPU -0上运行的线程进入休眠状态。这意味着该线程 自动退出CPU。睡眠代码将调用linux调度程序,调度程序将选择另一个线程/进程来运行。这是与中断有关。禁用中断(例如,定时器中断),可以阻止线程被中断并根据其意愿安排到CPU。)

如果是,那么如何从剩余的核心中进行选择,以便选择哪个核心    调度程序是在禁用CPU-0上的中断时做出的决定?

(希望这会有所帮助!)