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
It has nothing to do with Linux (directly).
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.
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.
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.
与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…