轮询或中断方式 [英] Polling or Interrupt based method

查看:314
本文介绍了轮询或中断方式的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

何时应该使用轮询方法,何时应该使用基于中断的方法?
是否有可以使用两种方式的情况?

When should one use polling method and when should one use interrupt based method ? Are there scenarios in which both can be used ?

推荐答案

如果感兴趣的事件是:


  1. 异步

  2. 紧急

  3. 不频繁

然后一个基于中断的处理程序就会有意义。

then an interrupt based handler would make sense.

如果感兴趣的事件是:


  1. 同步(即你知道什么时候在小窗口中预期)

  2. 不紧急(即慢轮询间隔没有不良影响)

  3. 频繁(即您的轮询周期中的大部分创建一个命中)

然后轮询可能更合适。

其他注意事项包括您是否为操作系统编写设备驱动程序,或者只是编写没有线程的裸机代码支持。在裸机情况下,当CPU不忙时,CPU通常只是循环,所以它也可能在轮询某些东西。

Other considerations include whether you are writing a device driver for an OS or just writing bare metal code with no thread support. In bare metal situations the CPU is often just looping when it isn't busy so it might as well be polling something.

这篇关于轮询或中断方式的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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