CPU如何空闲(或低于100%运行)? [英] How does a CPU idle (or run below 100%)?

查看:139
本文介绍了CPU如何空闲(或低于100%运行)?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我首先了解了计算机是如何在原始的单个存储程序机器方面工作的.

I first learned about how computers work in terms of a primitive single stored program machine.

现在,我正在学习多任务操作系统,调度,上下文切换等.除了一件事,我认为我对这一切都有很好的了解.我一直认为CPU只是不断向前充电.它总是知道下一步要执行的内容(程序计数器),并且会无限制地转到该指令等.

Now I'm learning about multitasking operating systems, scheduling, context switching, etc. I think I have a fairly good grasp of it all, except for one thing. I have always thought of a CPU as something which is just charging forward non-stop. It always knows where to go next (program counter), and it goes to that instruction, etc, ad infinitum.

显然不是这样,因为我的台式机CPU并非总是以100%的速度运行.那么,CPU如何关闭自身或关闭自身,操作系统在其中扮演什么角色呢?我猜想CPU上会有一个输入,可以关闭电源...如果没有什么可安排的时间,操作系统可以设置它,但是下一个逻辑问题是如何重新启动?我猜是以下两件事之一:

Clearly this is not the case since my desktop computer CPU is not always running at 100%. So how does the CPU shut itself off or throttle itself down, and what role does the OS play in this? I'm guessing there's an input on the CPU somewhere which allows it to power down... and the OS can set this if it has nothing to schedule, but the next logical question is how does it start back up again? I'm guessing either one of two things:

  • 它永远不会完全关闭,只是以非常低的频率运行,等待调度程序再次繁忙
  • 它完全关闭,但被中断唤醒

我到处搜索有关此问题的信息,然后空手而归.任何见识将不胜感激.

I searched all over for info on this and came up fairly empty-handed. Any insight would be much appreciated.

推荐答案

答案是取决于硬件,操作系统以及操作系统的配置方式.

The answer is that is depends on the hardware, the operating system and the way that the operating system has been configured.

它可能涉及您建议的一种或两种策略.

And it could involve either or both of the strategies you proposed.

基于x86架构的计算机的另一种可能性是,x86具有 HLT指令导致内核停止,直到接收到外部中断为止.因此,空闲"任务可以简单地在紧密循环中执行HLT.

Another possibility for machines based on the x86 architecture, is that x86 has an HLT instruction that causes the core to stop until it receives an external interrupt. So the "Idle" task could simply execute HLT in a tight loop.

这篇关于CPU如何空闲(或低于100%运行)?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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