This is a key point and requires some explanation.
Prioritization on the standard Linux OS goes from highest to lowest priority as follows (we'll suffix each bullet point with the context it runs in; it will be either process or interrupt. If you're unclear on this point, it's very important you understand this; do refer to the companion guide Linux Kernel Programming - Chapter 6, Kernel Internals Essentials – Processes and Threads, the Understanding Process and Interrupt Contexts section, for more information):
- Hardware interrupts: These preempt anything and everything. The hardirq handler runs atomically (to completion, without interruption) on the CPU; context:interrupt.
- Real-time threads (the SCHED_FIFO or SCHED_RR scheduling policy), both kernel and user space, with positive real-time priority (rtprio); context:process:
- A kernel...