您认为轮询对于其他设备(例如磁盘或网络接口)来说是一个好方法吗?
我正在学习 LC3,但有一些问题我无法清楚理解
Im learning LC3 but there are some problem i can not understand clearly
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
我正在学习 LC3,但有一些问题我无法清楚理解
Im learning LC3 but there are some problem i can not understand clearly
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
接受
或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
发布评论
评论(1)
如果程序没有比等待该设备更好的事情可做,那么轮询是与设备交互的合理方式。
简单系统可能就是这种情况,一些嵌入式系统也是这样工作的。
然而,随着我们增加系统的工作负载,轮询可能变得对设备和/或程序的响应不够充分,因此其他方法性能更好。
中断是轮询的替代方案。中断机制支持硬件和软件中的优先级。
当 I/O 设备同时/同时准备就绪时,硬件将根据设备速度有效地确定设备的优先级。这意味着快速设备可以快速引起 CPU 的注意,以响应数据准备就绪。
当 CPU 正在为低优先级设备提供服务并且较高优先级设备准备就绪时,通过中断,软件可以分层,以便允许较高优先级设备中断当前可能正在服务的较低优先级(较慢)设备。
当许多程序竞争 CPU 时,中断也能很好地工作。
总之,设备和程序越多,轮询的性能就越差,可能会减慢系统速度,甚至丢失设备中的数据。中断如果适当分层,可以缓解这些问题。
Polling is a reasonable way to interact with a device, if the program doesn't have anything better to do than wait for that device.
This can be the case on simple systems, and some embedded systems work that way.
However, as we increase the system's workload, polling may become insufficiently responsive to the devices and/or programs, so other methods perform better.
Interrupts are an alternative to polling. Interrupts mechanisms support prioritization both in hardware and in software.
When I/O devices are ready simultaneously/concurrently, the hardware will prioritize the devices, effectively by their device speed. This means that fast devices can get the attention of the CPU quickly in response to data being ready.
When the CPU is servicing a low priority device and a higher priority device becomes ready, with interrupts, software can layer so as to allow higher priority devices to interrupt lower priority (slower) devices that may be currently being serviced.
Interrupts also work well when many programs compete for the CPU.
In summary, the more devices and more programs, the worse that polling will perform, potentially slowing the system down and even loosing data from devices. Interrupts, when properly layered, can mitigate these issues.