在Windows中,阻塞时CPU会做什么? [英] In windows, what does the CPU do while blocking

查看:305
本文介绍了在Windows中,阻塞时CPU会做什么?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

每当CPU等待某个系统响应时,一个人就会阻塞呼叫,例如等待互联网请求. CPU在这些调用期间实际上是在浪费时间吗(我不知道除no-op之外是否还有其他机器指令会与CPU实际在浪费时间相对应).如果没有,它在做什么?

One has blocking calls whenever the CPU is waiting for some system to respond, e.g. waiting for an internet request. Is the CPU literally wasting time during these calls (I don't know whether there are machine instructions other than no-op that would correspond to the CPU literally wasting time). If not, what is it doing?

推荐答案

当操作系统调度程序查找要移交给核心的工作时,仅跳过该线程.由于非常普遍的结果,因此无需执行任何操作.然后,处理器内核执行HLT指令.

The thread is simply skipped when the operating system scheduler looks for work to hand off to a core. With the very common outcome that nothing needs to be done. The processor core then executes the HLT instruction.

在HALT状态下,它几乎不消耗功率.需要中断才能使其恢复活动.最典型的情况是时钟中断,默认情况下每秒滴答64次.可能是设备中断.然后,调度程序再次查找要执行的工作.冲洗并重复.

In the HALT state it consumes (almost) no power. An interrupt is required to bring it back alive. Most typically that will be the clock interrupt, it ticks 64 times per second by default. It could be a device interrupt. The scheduler then again looks for work to do. Rinse and repeat.

这篇关于在Windows中,阻塞时CPU会做什么?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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