简体   繁体   中英

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. It's discussed in Bovet & Cesati's "Understanding the Linux Kernel". 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.

The CPU local timer is a device similar to the Programmable Interval Timer just described that can issue one-shot or periodic interrupts. 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; 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.
  • The APIC's timer is based on the bus clock signal (or the APIC bus signal, in older machines). 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. Conversely, the PIT, which makes use of its own clock signals, can be programmed in a more flexible way.

A less technical answer than Michael Burr's:

Some things need to be done every jiffy, doesn't matter on which CPU.
Other things need to be done every jiffy on each 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. 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. Will get back wit more on the local timers.

On SMP systems apic timer is used for scheduler / rescheduling threads.

On UP system pit timer is used for scheduler / rescheduling threads.

Normaly the PIT is no longer used anymore in SMP systems.

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

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