当没有用户代码可以运行时,CPU中会发生什么? [英] What happens in the CPU when there is no user code to run?

查看:59
本文介绍了当没有用户代码可以运行时,CPU中会发生什么?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

操作系统/rtos安排空闲任务"听起来很合理.在那种情况下,会不会很耗电?(执行空闲任务听起来很合理:while(true){})

It sounds reasonable that the os/rtos would schedule an "Idle task". In that case, wouldn't it be power consuming? (it sounds reasonable that the idle task will execute: while (true) {} )

推荐答案

这取决于操作系统和CPU架构.在x86(与Intel兼容)上,操作系统可能会执行 HLT 指令,从而使CPU等待直到发生有趣的事情发生,例如硬件中断.据说这仅消耗很少的功率.操作系统将花费的时间报告为"空闲",甚至可以为其分配时间虚构的闲置"过程.

This depends on the OS and the CPU architecture. On x86 (Intel compatible) the operating system might execute HLT instructions, making the CPU wait until something interesting happens, such as a hardware interrupt. This supposedly consumes very little power. Operating systems report the time spent doing this as "idle" and may even assign it to a fictional "idle" process.

因此,在Windows任务管理器中,您会看到系统空闲进程正在消耗90%CPU的真正含义是,CPU没有实际的程序可以在90%的时间内运行.

So, when in Windows task manager you see that the System Idle Process is consuming 90% CPU what it really means is that the CPU does not have an actual a program to run 90% of the time.

关于此主题的一篇好文章:什么空闲的CPU会做什么?

Here's a good article on the subject: What does an idle CPU do?

这篇关于当没有用户代码可以运行时,CPU中会发生什么?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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