当前位置:网站首页>中断和轮询
中断和轮询
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。中断和轮询并不是完全相反。
边栏推荐
- quartus调用&设计D触发器——仿真&时序波验证
- Esp32-c3 introductory tutorial problem ⑦ - fatal error: ESP_ Bt.h: no such file or directory ESP not found_ bt.h
- Broadcast level E1 to aes-ebu audio codec E1 to stereo audio XLR codec
- Wallys/DR6018-S/ 802.11AX MU-MIMO OFDMA / 2* GE PORTS/WIFI 6e / BAND DUAL CONCURRENT
- In flinksql, the Kafka flow table and MySQL latitude flow table are left joined, and the association is made according to I'd. false
- Androd Gradle模块依赖替换如何使用
- R language uses matchit package for propensity matching analysis (set the matching method as nearest, match the control group and case group with the closest propensity score, 1:1 ratio), and use matc
- What are the conditions for a mature knowledge management?
- Go write permissions to file writefile (FileName, data, 0644)?
- The filter function of dplyr package in R language filters the data rows containing the specified string in the specified data column of dataframe data based on the grepl function
猜你喜欢

Filtre de texte en ligne inférieur à l'outil de longueur spécifiée

After the uncommitted transactions in the redo log buffer of MySQL InnoDB are persisted to the redo log, what happens if the transaction rollback occurs?

DBMS in Oracle_ output. put_ How to use line

串口、COM、UART、TTL、RS232(485)区别详解

Architecture design methods in technical practice

First exposure! The only Alibaba cloud native security panorama behind the highest level in the whole domain

实战监听Eureka client的缓存更新

Overview of national parks in the United States
![[Yunzhou said live room] - digital security special session will be officially launched tomorrow afternoon](/img/56/a6a9fbba0a9fc212883b469bb857c5.png)
[Yunzhou said live room] - digital security special session will be officially launched tomorrow afternoon

What is the principle of live CDN in the process of building the source code of live streaming apps with goods?
随机推荐
Quarkus+saas multi tenant dynamic data source switching is simple and perfect
2-optical-2-electric cascaded optical fiber transceiver Gigabit 2-optical-2-electric optical fiber transceiver Mini embedded industrial mine intrinsic safety optical fiber transceiver
Hanyuan hi tech 1-channel gigabit optical port to 4-channel Gigabit Ethernet electrical port Gigabit 1-optical 4-electric optical fiber transceiver
The R language inputs the distance matrix to the hclust function for hierarchical clustering analysis, uses the cutree function to divide the hierarchical clustering clusters, specifies the number of
Hanyuan high tech USB3.0 optical transceiver USB industrial touch screen optical transceiver USB3.0 optical fiber extender USB3.0 optical fiber transmitter
白皮书丨英特尔携手知名RISC-V工具提供商Ashling,着力扩展多平台RISC-V支持
How about stock online account opening and account opening process? Is it safe to open a mobile account?
Quartus II 13.1 安装步骤详解
串口、COM、UART、TTL、RS232(485)区别详解
Strengthen the sense of responsibility and bottom line thinking to build a "safety dike" for flood fighting and rescue
Online text entity extraction capability helps applications analyze massive text data
Meta said that the UK security law will "scan all private information", which risks infringing on users' privacy
能把SAP系统玩成鸡肋的公司,太有才了!
"Four highs" of data midrange stability | startdt Tech Lab 18
Filtre de texte en ligne inférieur à l'outil de longueur spécifiée
RestCloud ETL解决shell脚本参数化
4E1 PDH optical transceiver 19 inch rack type single fiber transmission 20km E1 interface optical network optical transceiver
Homekit and NFC support: smart Ting smart door lock SL1 only costs 149 yuan
有向图D和E
[Yunzhou said live room] - digital security special session will be officially launched tomorrow afternoon