空闲进程的代码是什么?
当CPU不执行任何操作时,它会运行空闲进程。我听说这个进程会寻找正在队列中等待的程序,以便CPU可以运行它们。这就是它的全部作用吗?它的代码是什么样的?我也有兴趣了解各种操作系统中系统空闲进程的文件名。
When the cpu isn't doing anything, it runs the idle process. I heard that this process looks for programs that are waiting in the queue so that the cpu can run them. Is that all it does? What does the code for it look like? I am also interested in knowing the file name of the system idle process in the various OSes.
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(5)
该问题包含几个错误的默认假设。以下是一些提示:
hlt
指令等效的指令,其目的一般来说是减少空闲处理器对系统总线的使用(因此,当然,非-空闲处理器可以使用该总线带宽)。因此,在许多架构上,无限循环会重复执行这些指令。一些处理器在执行此类指令时可以在总线上发出其“空闲”状态的信号,外部硬件可以识别这些指令并对其采取行动(例如,通过减慢总线时钟速度并消耗更少的功率)。同样,空闲指令可能会导致处理器本身执行诸如时钟减慢和节能之类的操作。The question contains several erroneous tacit assumptions. Here are some pointers:
hlt
instruction, the intent of which is in general terms to reduce the idling processor's use of the system bus (so that, of course, non-idle processors can use that bus bandwidth). So on many architectures the infinite loop repeatedly executes those instructions. Some processors can signal their "idle" state on the bus when they execute such instructions, which external hardware can recognize and act upon (such as by slowing bus clocks down and consuming less power, for example). Similarly, the idle instructions can cause the processors themselves to do things like clock-slowing and power-saving.在空间关键嵌入式系统中,空闲进程用于擦洗内存,以检查宇宙射线是否存在引入了位翻转。
In space critical embedded systems, the idle process is used to scrub memory in order to check whether cosmic rays have introduced bit flips.
Idle 进程不执行任何操作;操作系统本身负责调度进程运行。 Idle 进程本身只是循环 HLT 指令。 (来源:维基百科)
The Idle process doesn't do anything; the OS itself is responsible for scheduling processes to run. The Idle process itself just loops HLT instructions. (source: wikipedia )
每当进程处于其时间片末尾以及每当进程执行阻塞操作时,操作系统都会运行调度程序。然后调度程序选择下一个要运行的进程。在我所知道的平台上,将调度程序视为进程是没有意义的。
这里有更多关于调度的信息。
The OS runs the scheduler whenever a process is at the end of its time slice, and whenever a process has performed a blocking operation. The scheduler then picks the next process to run. On the platforms I know, it does not make sense to see the scheduler as a process.
Here is a little more about scheduling.
空闲进程用于调度程序在没有进程执行时运行某些内容。
这特别取决于操作系统。
为了简单理解,我们可以说空闲进程是一个无限循环,当没有进程运行时它将被调度
The idle process is for scheduler to run something when no process is executing.
It depends on the OS particularly.
For simple understanding we can say idle process is a infinite loop, which will get scheduled when no process is running