- 论坛徽章:
- 0
|
smalloc 发表于 2012-09-27 19:49 ![]()
pause? x86只听过个halt啊
这个问题我最近也在找答案
嗯,应该是halt指令,halt指令使CPU进入空闲状态。我查看了内核在start_kernel之后调用的cpu_idle()的代码,里面调用到native_safe_halt(), native_safe_halt()就两条指令
sti
hlt
sti就开中断,我们来看下hlt指令(摘自Intel指令手册):
Description
Stops instruction execution and places the processor in a HALT state. An enabled
interrupt (including NMI and SMI), a debug exception, the BINIT# signal, the INIT#
signal, or the RESET# signal will resume execution. If an interrupt (including NMI) is
used to resume execution after a HLT instruction, the saved instruction pointer
(CS:EIP) points to the instruction following the HLT instruction
综上可以看到,kernel进程调度器在发现没有进程要调度的时候把cpu通过hlt指令切入空闲状态,但是在进入之前开启了中断,所以当有中断输入的时候CPU又回到之前的状态。
|
|