I think there is a little confusion here over what Linux is. Linux is the exact opposite of a a realtime OS. The job of the Linux kernel is not to coerce everything into proceeding in a perfectly orderly way. The job of the Linux kernel is to "boot up and get the hell out of the way", and then just keep everything else from colliding by handling interrupts at an amazing rate. Context switching and interrupt latency are not related anymore. The context switching frequency is only pertient for legacy hardware that is practically non-existant.
A lot of Linux kernel developers have done nothing more than map a hex value to a string, so that when a USB device is plugged in it can announce it's presence in the logs:
[1729871.060298] usb 1-3.4.4.4: new full-speed USB device number 103 using xhci_hcd
[1729871.152936] usb 1-3.4.4.4: New USB device found, idVendor=303a, idProduct=4001, bcdDevice= 1.00
[1729871.152944] usb 1-3.4.4.4: New USB device strings: Mfr=1, Product=2, SerialNumber=3
[1729871.152946] usb 1-3.4.4.4: Product: Espressif Device
[1729871.152947] usb 1-3.4.4.4: Manufacturer: Espressif Systems
[1729871.152949] usb 1-3.4.4.4: SerialNumber: e4b323f93cbc0000
[1729871.163725] cdc_acm 1-3.4.4.4:1.0: ttyACM0: USB ACM device
There. Faster than you can get your fingers back to the keyboard after plugging in the USB cable, a Microcontroller has been interfaced to your desktop computer. A remarkable feat considering that thousands of other things were going on at the same moment.
Slightly more adept programmers might write Serial/UART interfaces to make the relationship between the desktop and the MCU more cosy. Even more adept coders might code user interfaces that don't suck... Someday.
Linux is slightly misplaced on embedded hardware. But Linux is uniquely able to be coerced into managing vast arrays of network connected embedded systems. The CIA used a bespoke system with a Linux desktop managing an array of IBM System 360 systems-on-a-card for their world-class security-through-obscurity model that relied on the lack of real-time clocks on the slave systems to hide the order of communications!
I was a Linux kernel developer in the 1990's. The kernel today has 0 lines of the code that was present in those kernels, and is architecturally another beast altogether. In general, when you see Linux falling down at some task, you are seeing the result of a coding or architectural error, not a shortcoming in Linux. Linux is a much, much bigger thing than you think. I have built and deployed multi-thousand core Linux clusters, some of which managed thousands of VME crates. I watched the Crays, HP-X's and Intel Paragons carted out to the trash heap, replaced by Linux on commodity hardware. I haven't touched a Windows or Apple computer since 1994.