Issue
From what I understand, Linux features kernel preemption, meaning that a thread executing a system call can be preempted and rescheduled to run on the next epoch.
This leads me to wonder if a thread in a system call has any sort of elevated priority when they get rescheduled.
For example, say I have a userland process with SCHED_OTHER and a priority of 20 (0 is the lowest, 139 is the highest). The process reads an smbus device file from sysfs using the standard read system call. Now when it reads the smbus device, the smbus controller needs to receive each byte one at a time, and so timing is important, we cant wait too long in between receiving bytes otherwise the smbus transaction will timeout.
Now, while receiving bytes from the device the thread gets rescheduled (either it sleeps or gets preempted by a higher priority thread, etc). When the thread gets rescheduled, does it still have the initial low priority of 20? This seems like it would be an issue and it should be treated as higher, since it is interfacing with a device and timing is critical (it seems like I would it expect it to be treated as having a rt priority). I haven't found anything to indicate that threads get a "boosted" priority in these contexts.
Solution
To answer the question in the title, no, Linux userland threads don't get their priority boosted when making system calls.
The Linux kernel can be preemptible depending on compilation options. "Standard" kernels used by Linux distros tend to use the so-called 'voluntary preemption' option, where a thread running in the kernel occasionally checks whether a higher priority thread is runnable.
However, depending on how the actual low level I/O with the device is done, if it's done in IRQ handlers then the bottom half interrupt handler routines run at, in a sense, infinite priority. And the top half interrupt handlers run, depending on how that particular device driver is implemented, compilation options etc., again at similar "infinite" priority, or then as a separate interrupt handler thread, with an adjustable but by default very high priority.
Answered By - janneb Answer Checked By - Senaida (WPSolving Volunteer)