简体   繁体   English

什么是Linux本地计时器中断?

[英]What are Linux Local timer interrupts?

All is in the title. 全部都在标题中。 Any links to good documentations are welcome. 欢迎提供任何指向良好文档的链接。

The local timer interrupt is a timer implemented on the APIC that interrupts only a particular CPU instead of raising an interrupt that can be handled by any CPU. 本地计时器中断是在APIC上实现的计时器,该计时器仅中断特定的CPU,而不引发任何CPU可以处理的中断。 It's discussed in Bovet & Cesati's "Understanding the Linux Kernel". 在Bovet&Cesati的“了解Linux内核”中进行了讨论。 A snippet: 摘录:

The local APIC present in recent 80x86 microprocessors (see the section “Interrupts and Exceptions” in Chapter 4) provides yet another time-measuring device: the CPU local timer. 最近的80x86微处理器中存在的本地APIC(请参见第4章中的“中断和异常”部分)提供了另一个时间测量设备:CPU本地计时器。

The CPU local timer is a device similar to the Programmable Interval Timer just described that can issue one-shot or periodic interrupts. CPU本地定时器是类似于刚才描述的可编程间隔定时器的设备,可以发出单次或周期性中断。 There are, however, a few differences: 但是,有一些区别:

  • The APIC's timer counter is 32 bits long, while the PIT's timer counter is 16 bits long; APIC的计时器计数器为32位长,而PIT的计时器计数器为16位长。 therefore, the local timer can be programmed to issue interrupts at very low frequencies (the counter stores the number of ticks that must elapse before the interrupt is issued). 因此,可以将本地定时器编程为以非常低的频率发出中断(计数器存储发出中断之前必须经过的滴答数)。
  • The local APIC timer sends an interrupt only to its processor, while the PIT raises a global interrupt, which may be handled by any CPU in the system. 本地APIC计时器仅向其处理器发送中断,而PIT引发全局中断,该中断可由系统中的任何CPU处理。
  • The APIC's timer is based on the bus clock signal (or the APIC bus signal, in older machines). APIC的计时器基于总线时钟信号(或旧机器中的APIC总线信号)。 It can be programmed in such a way to decrease the timer counter every 1, 2, 4, 8, 16, 32, 64, or 128 bus clock signals. 可以这样编程:每1,2,4,8,16,32,64或128个总线时钟信号减少定时器计数器。 Conversely, the PIT, which makes use of its own clock signals, can be programmed in a more flexible way. 相反,可以利用其自己的时钟信号对PIT进行更灵活的编程。

A less technical answer than Michael Burr's: 比迈克尔·伯尔(Michael Burr)的技术答案少:

Some things need to be done every jiffy, doesn't matter on which CPU. 需要花些时间来做一些事情,与在哪个CPU上无关。
Other things need to be done every jiffy on each CPU. 每个CPU上的所有琐事都需要做其他事情。 For example, checking if we need to switch to another process. 例如,检查是否需要切换到另一个进程。

The local timer interrupt exists for the second type - whenever it's executed, we check them and do what's needed. 对于第二种类型,存在本地计时器中断-每当执行时,我们都会检查它们并执行所需的操作。

I feel the local timers are used for handling the IPI related functionality. 我觉得本地计时器用于处理IPI相关功能。 I might be wrong in this guess, need t look at the code on what they are configured for and what the handler contains. 在这种猜测中,我可能是错的,无需查看有关它们的配置内容以及处理程序所包含内容的代码。 But I feel the system timer and the jiffies are linked to one of the GP Timers and hence in SMP ARM for example, the interrupt from this timer is associated with one single core through the GIC affinity registration. 但是我感觉系统计时器和Jiffies链接到一个GP计时器,因此例如在SMP ARM中,该计时器的中断通过GIC相似性注册与一个内核相关联。 Will get back wit more on the local timers. 将更多地使用本地计时器。

On SMP systems apic timer is used for scheduler / rescheduling threads. 在SMP系统上,Apic计时器用于调度程序/重新调度线程。

On UP system pit timer is used for scheduler / rescheduling threads. 在UP系统上,pit计时器用于调度程序/重新调度线程。

Normaly the PIT is no longer used anymore in SMP systems. 通常,在SMP系统中不再使用PIT。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM