Interrupt shielding
Using threaded interrupt handlers helps mitigate interrupt overhead by running some threads at a higher priority than interrupt handlers that do not impact real-time tasks. If you are using a multi-core processor, you can take a different approach and shield one or more cores from processing interrupts completely, allowing them to be dedicated to real-time tasks instead. This works either with a normal Linux kernel or a PREEMPT_RT
kernel.
Achieving this is a question of pinning the real-time threads to one CPU and the interrupt handlers to a different one. You can set the CPU affinity of a thread or process using the taskset
command-line tool, or you can use the sched_setaffinity(2)
and pthread_setaffinity_np(3)
functions.
To set the affinity of an interrupt, first note that there is a subdirectory for each interrupt number in /proc/irq/<IRQ number>
. The control files for the interrupt are in there, including a CPU mask in smp_affinity
. Write a bitmask...