处理器处理中断的速度有多快 [英] how quick can the processor handle the interrupts

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

问题描述

我正在研究中断.所以大多数架构都是中断驱动的,如果一切都是中断驱动的,处理器处理所有这些的速度有多快.例如,当按下键盘上的某个键时,它会创建一个中断,要求内核寻找新字符的缓冲区,在这种情况下,处理器可以提供多快的服务,并且在放置中断时,处理器需要切换到内核空间,这在上下文切换方面成本很高.所以我假设,即使在所有这些之后,如果处理器具有良好的性能,那么我只能假设两次击键之间的时间就计算机速度而言是很多时间?平均一个,一分钟内发生多少次上下文切换?我想这会让我对我真正在学习的内容有所了解并获得真实的生活感觉......谢谢......

I was studying about interrupts. So most architecture are interrupt driven, if everything is interrupt driven, how fast the processor can handle all of those. For example, while pressing a key board keys, it creates an interrupt asking the kernel to look for the buffer for new characters, in that case, how fast the processor can serve, also when an interrupt is put, the processor needs to switch to kernel space and that costs a lot in terms of context switch. So I assume, even after all these if the processor has a good performance, then I can only assume that the time between two key strokes is lots of time in terms of computer speed? One an average, how many context switch happens in one minute? I guess that would give me some idea about what I am really studying and to get an real life feel.... Thanks....

推荐答案

多快取决于多个事情:

  1. CPU 硬件和中断控制器(如果有)的延迟
  2. CPU 时钟频率(通常,事件(或对它们的响应)发生的速度不会比这个速度快)
  3. CPU 访问所需内存的速度(系统表(例如中断向量表,但可能有段表和页表等)、堆栈(中断的代码指令指针通常会保存在堆栈,因此 ISR 可以返回给它)、ISR 代码本身及其使用的所有数据).显然,代码、数据和 TLB 缓存将在此发挥作用.
  4. ISR 完成其工作所需的时间,尤其是当 ISR 不能相互抢占而并发中断必须串行化时.
  5. 中断优先级.通常,不同的中断源被分配不同的优先级.例如,您希望不可屏蔽中断、机器检查中断(基本上是报告严重硬件问题的中断)和定时器中断具有比键盘中断更高的优先级.在基于优先级的中断处理中,所有优先级低于当前正在服务的中断的中断都必须等待".因此,如果您有很多高优先级中断,则低优先级中断可以在明显且不同的延迟下得到服务.极端情况是高优先级中断不断出现.这可能是由于设计不当或硬件故障所致.
  6. 与其他 CPU 的通信和交互.在 MP 系统中,中断处理程序有时可能会使用自旋锁来独占访问多个 CPU 之间共享的资源.如果存在争用,则 ISR 将等待并且所有其他中断(或所有较低优先级的中断)将不会得到服务,直到当前 ISR 完成其工作.

这是对一般问题的一般回答.

That's a general answer to a general question.

编辑:我忘了再提一件事.存在一些奇怪的 CPU,其中某些指令是可重复的(想想 x86 的 rep movsb),并且在重复指令完全完成之前无法开始服务中断,这可能需要相当于执行大约 1000 或更简单的个别说明.因此,尽管启用了中断,但可能会有一些 CPU 怪癖不让 ISR 开始运行.其中一种 CPU 是 TI 的 TMS320C54xx.有了它,您必须小心处理 FIR 滤波器代码.如果过滤器很长并且被实现为重复的 MAC 指令,则会在中断服务中引入延迟.

EDIT: I've forgot to mention one more thing. There exist some odd CPUs in which certain instructions are repeatable (think of x86's rep movsb) and interrupts can't start getting serviced until the repeated instruction fully finishes, which may take time equivalent to executing some 1000 or even more simple individual instructions. So, despite interrupts being enabled, there may be some CPU quirks not letting the ISRs to start running. One of such CPUs is TI's TMS320C54xx. With it you have to careful around FIR filter code. If the filter is long and is implemented as a repeated MAC instruction, it will introduce a latency in interrupt servicing.

这篇关于处理器处理中断的速度有多快的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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