当前位置:网站首页>中断和轮询
中断和轮询
2022-06-23 12:59:00 【小小怪༻】
引言
串行接口(外文名:Serial Interface,简称:串口)是采用串行通信方式的扩展接口,指数据一位一位地顺序传送。串行接口的特点是通信线路简单,只要一对传输线就可以实现双向通信(可以直接利用电话线作为传输线),从而大大降低了成本,特别适用于远距离通信,但传送速度较慢。
外部设备与中央处理器交互一般有两种手段:中断和轮询。
中断(Interrupt)
中断就是由硬件或者软件发出的一种IRQ(中断信号),一旦CPU接收到中断信号,CPU就会暂停当前执行的任务,并且保留现场,去响应外设的中断请求。
中断通知机制通过硬件信号异步唤起处理器的注意,解决了外部设备与处理器之间速度不匹配导致的资源浪费问题。
轮询(Polling)
很多I/O设备都有一个状态寄存器,用于描述设备当前的工作状态,每当设备状态发生改变时,设备将修改相应状态寄存器位。通过不断查询设备的状态寄存器,CPU就可以了解设备的状态,从而进行必要的I/O操作。为了节约CPU资源,查询工作往往不是连续的,而是定时进行。
轮询方式具有简单、易实现、易控制等优势,在很多小型系统中有大量的应用。对那些敏感度不高、具有大量CPU资源的系统来说,轮询方式有很广泛的应用。
轮询方式存在的不足:
- 增加系统开销。无论是任务轮询还是定时器轮询都需要消耗对应的系统资源。
- 无法及时感知设备状态变化。在轮询间隔内的设备状态变化只有在下次轮询时才能被发现,这将无法满足对实时性敏感的应用市场。
- 浪费CPU资源。无论是设备是否发生状态改变,轮询总在进行,在实际情况中,大多数设备的状态改变通常不会那么频繁,轮询将白白浪费CPU时间片。
中断与轮询的区别
- 轮询方式存在空转损耗,它是可控并且实时的。消耗大量cpu的处理时间,周期连续检测外部事件的发生。
- 中断的高优先级和快速响应要求在极端条件下将造成“活锁”效应。各种各样的输入输出设备通过中断处理方式进行并行操作,使中断次数增加,会造成CPU无法响应中断;如果在缓冲区装满数据之后发生中断。那么在数据传送过程中,发生中断的机会较多,将耗去大量的CPU处理时间。
- 中断不是协议,而是一种硬件机制;轮询反之。
- 处理器在每个指令周期都会去查看中断寄存器,如果中断寄存器有效,也就是发生了中断,那么cpu会执行一系列与中断相关的操作。也就是说中断也是需要CPU check。中断和轮询并不是完全相反。
边栏推荐
- Technology sharing | wvp+zlmediakit realizes streaming playback of camera gb28181
- js: 获取页面最大的zIndex(z-index)值
- Qunhui 10 Gigabit network configuration and test
- Hanyuan high tech new generation green energy-saving Ethernet access industrial switch high efficiency energy-saving Gigabit Industrial Ethernet switch
- 深入剖析MobileNet和它的变种
- Online text entity extraction capability helps applications analyze massive text data
- #云原生征文#深入了解Ingress
- The way out after the development of Internet technology -- the birth of IVX
- Hanyuan high tech USB2.0 optical transceiver USB2.0 optical fiber extender USB2.0 optical fiber transmitter USB2.0 interface to optical fiber
- How to use sed -i command
猜你喜欢

MySQL single database and table splitting using MYCAT

Go写文件的权限 WriteFile(filename, data, 0644)?

How to enable the SMS function of alicloud for crmeb knowledge payment

快速了解常用的非对称加密算法,再也不用担心面试官的刨根问底

C语言的基本数据类型及其打印输出

腾讯的技术牛人们,是如何完成全面上云这件事儿的?

利用XtraDiagram.DiagramControl进行流程图形的绘制和控制

32-way telephone +2-way Gigabit Ethernet 32-way PCM telephone optical transceiver supports FXO port FXS voice telephone to optical fiber

#yyds干货盘点# 解决剑指offer: 判断是不是平衡二叉树

Stick to five things to get you out of your confusion!
随机推荐
[Yunzhou said live room] - digital security special session will be officially launched tomorrow afternoon
618's money saving technology strategy is coming - experience the scene and get a 10 yuan cat super card!
Homekit and NFC support: smart Ting smart door lock SL1 only costs 149 yuan
sed -i命令怎么使用
What are the conditions for a mature knowledge management?
Gradle Build Cache引发的Task缓存编译问题怎么解决
POW consensus mechanism
R language uses the polR function of mass package to build an ordered multi classification logistic regression model, and uses the summary function to obtain the summary statistical information of the
实战监听Eureka client的缓存更新
Generics, generic defects and application scenarios that 90% of people do not understand
< Sicily> 1001. Rails
Qunhui 10 Gigabit network configuration and test
1 channel 100m optical fiber transceiver 1 100m optical 1 100m electric desktop Ethernet optical fiber transceiver built-in power supply
Oracle中dbms_output.put_line怎么使用
Filtre de texte en ligne inférieur à l'outil de longueur spécifiée
Architecture design methods in technical practice
Can cold plate, submerged and spray liquid cooling lead the development of high-performance computing?
DBMS in Oracle_ output. put_ How to use line
Develop a powerful tool for increasing efficiency - vscode plug-in sharing in 2022
Hanyuan hi tech 1-way uncompressed 4k-dvi optical transceiver 4K HD uncompressed DVI to optical fiber 4k-dvi HD video optical transceiver