As has already been discussed in this chapter, Linux is not a real-time system. It is a good choice for soft real-time tasks, but despite the fact that it provides a real-time scheduler, its kernel is too complex to guarantee the level of determinism needed for hard real-time applications.
Time-critical applications require either a real-time operating system to run, or are designed and implemented to run on bare metal, with no operating system at all.
Real-time operating systems are usually much simpler than general-purpose operating systems such as Linux. Also, they require tailoring to the particular hardware platform, usually a microcontroller.
There are a number of real-time operating systems, with most of them being proprietary and not free. FreeRTOS is a good starting point to explore the capabilities of real-time operating systems...