如何Linux内核醒来​​时,新的任务创建空闲处理器最多? [英] How does linux kernel wake idle processor up when new task created?

查看:243
本文介绍了如何Linux内核醒来​​时,新的任务创建空闲处理器最多?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我在Linux内核新手。
目前,我看着闲置codeS和有quesition。
当处理器没有在自己的运行队列任何TAKS话,那可就
进入空闲模式,具体WFI(瓦亭中断)。
(所有我提到的是关于ARM架构不是X86,所以什么是错误的X86。)
住在WFI状态后,也许其他处理器(未空闲)要发$ P $垫
他们的任务这一点,空闲处理器(由负载均衡)。当时繁忙的处理器
做任务imigrated。在我的角度来看,当任务imigrated,空闲处理器
应该醒来immidiatley处理任务。对?但是,我找不到
任何codeS唤醒闲置的处理器但只找到codeS有关注册任务空闲处理器的运行队列。

I'm newbie on Linux Kernel. Currently, I looked into idle codes and had a quesition. When processor doesn't have any taks in their own runqueue then it may go into idle mode, specific WFI(wating for interrupt). (All I mentioned is about ARM architecture not X86. So something is wrong for X86.) After staying in WFI state, maybe other processor(not idle) want to spread their task to this, idle processor(by load balance). At that time a busy processor makes task imigrated. In my point of view, when the task is imigrated, the idle processor should wake up immidiatley to process the task. right? However, I couldn't find any codes waking up idle processor but only found codes about registering task to idle processor's runqueue.

我想知道的是,当被赋予新的任务醒来处理器最多的背后究竟机制。
或者,它只是从一个队列移动任务到其他的不是让它直到被唤醒
一些未predictable IRQ?

I'd like to know what mechanism is behind of waking processor up when new task is given. Or it just move task from one queue to other's than let it be until woken up by some unpredictable IRQ?

请告诉我真相:)

推荐答案

WFI 为ARM特殊的协处理器指令。例如,

WFI is a special co-processor instruction for the ARM. For example,

 ENTRY(cpu_arm946_do_idle)
         mcr     p15, 0, r0, c7, c0, 4           @ Wait for interrupt
         mov     pc, lr

它无关的Linux(直接)。

It has nothing to do with Linux (directly).

有是运行在ARM上的 WFI 指令,如果没有工作,一个特殊的空闲任务做。在空闲的任务是非常最低优先级Linux任务,预定如果有没有别的。如果 WFI 完成闲置,有些司机会中断(可能是计时器)没有工作做的时候。在SMP情况下,也不会去空闲如果有可以迁移的其他进程;调度程序来做这个。如果负载变高,则忙处理器需要唤醒他人;在 ARM 与中断的情况。通常这个处理是在弓/的的/kernel/process.c 。例如,的 86 的有<一个href=\"http://git.kernel.org/?p=linux/kernel/git/torvalds/linux.git;a=blob;f=arch/x86/kernel/process.c;hb=HEAD\"><$c$c>default_idle().我不知道具体的怎样的 86 的工作,但你可以看看源。

There is a special idle task that runs the WFI instruction on the ARM, if there is no work to do. The idle task is the very lowest priority Linux task, scheduled if there is nothing else. If WFI is done by idle, some driver will interrupt (maybe a timer) when there is no work to do. In the SMP case, it will not go to idle if there are other processes that can be migrated; the scheduler checks this. If a load gets high, then the busy processor needs to wake the others; In the case of an ARM with an interrupt. Usually this handling is in arch/arch/kernel/process.c. For example the x86 has default_idle(). I don't know specifics of how the x86 works, but you can look at the source.

对于你的问题如何做linux内核唤醒闲置的处理器了新的任务创建时?,答案是没有。只有叉()(和一些类似的功能),可以创建一个新的任务;最初是从的init 任务,然后它的一个孩子。如果你有一个的cron 工作,它会已经计划了的定时器它去之前睡眠/空闲。该定时器将唤醒系统,重新规划的cron 然后的cron 将调用叉( ),创建新的任务。

For your question How does linux kernel wake idle processor up when new task created?, the answer is it doesn't. Only fork() (and some similar functions) can create a new task; originally from the init task and then one of it's children. If you have a cron job, it will have scheduled a timer before it goes to sleep/idle. This timer will wake the system, re-schedule cron and then cron will call fork(), to create the new task.

其他相关机制是<一个href=\"http://git.kernel.org/?p=linux/kernel/git/torvalds/linux.git;a=tree;f=drivers/cpufreq;hb=HEAD\"><$c$c>cpufreq, <一href=\"http://git.kernel.org/?p=linux/kernel/git/torvalds/linux.git;a=tree;f=drivers/cpuidle;hb=HEAD\"><$c$c>cpuidle, <一href=\"http://git.kernel.org/?p=linux/kernel/git/torvalds/linux.git;a=tree;f=kernel/power;hb=HEAD\"><$c$c>kernel/power等等。

Other related mechanisms are cpufreq, cpuidle, kernel/power etc.

真相永远是客观/主观的肯定不是全球即可。让我看看指标真相,我可以告诉你在真相

The truth is always objective/subjective and certainly is not global. Show me the metric for the truth and I can show you the truth.

这篇关于如何Linux内核醒来​​时,新的任务创建空闲处理器最多?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆