CPU是否浪费等待键盘输入? (通用) [英] Is the CPU wasted waiting for keyboard input? (generic)

查看:146
本文介绍了CPU是否浪费等待键盘输入? (通用)的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

如果操作系统不需要等待键盘(或其他输入设备)的输入,并且有任何操作系统正在使用该操作,那么我就会徘徊。我无法相信我们确实需要浪费自行车才能等待输入,为什么一旦按下输入按钮就不会让机器等待操作。



长话短说:

当前如何处理键盘输入 - 轮询或中断?

解决方案

大多数现代程序都不会像您所描述的那样在循环中获得输入。您可以使用事件处理或中断避免浪费周期。


I was wandering if there's a way in which the OS doesn't need to cycle ad infinitum waiting for the input from keyboard (or other input device) and if there are any OS using that. I can't believe that we do need to waste cycling just to wait for input, why can't the input do something once is pressed instead of having the machine to wait for the action.

Long story short:

How keyboard input is currently handled - polling or interrupts?

解决方案

Most modern programs don't get input in a loop as you describe. You can use event handling or interrupts to avoid wasted cycles.

这篇关于CPU是否浪费等待键盘输入? (通用)的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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