The real-time Linux kernel (PREEMPT_RT)

There is a long-standing effort to reduce latencies still further which goes by the name of the kernel configuration option for these features, PREEMPT_RT. The project was started by Ingo Molnar, Thomas Gleixner, and Steven Rostedt and has had contributions from many more developers over the years. The kernel patches are at https://www.kernel.org/pub/linux/kernel/projects/rt and there is a wiki, including an FAQ (slightly out of date), at https://rt.wiki.kernel.org.

Many parts of the project have been incorporated into mainline Linux over the years, including high resolution timers, kernel mutexes, and threaded interrupt handlers. However, the core patches remain outside of the mainline because they are rather intrusive and (some claim) only benefit a small percentage of the total Linux user base. Maybe, one day, the whole patch set will be merged upstream.

The central plan is to reduce the amount of time the kernel spends running in an atomic context, which is where it is not safe to call the scheduler and switch to a different thread. Typical atomic contexts are when the kernel:

  • is running an interrupt or trap handler
  • is holding a spin lock or in an RCU critical section. Spin lock and RCU are kernel locking primitives, the details of which are not relevant here
  • is between calls to preempt_disable() and preempt_enable()
  • hardware interrupts are disabled

The changes that are part of PREEMPT_RT fall into two main areas: one is to reduce the impact of interrupt handlers by turning them into kernel threads and the other is to make locks preemptible so that a thread can sleep while holding one. It is obvious that there is a large overhead in these changes, which makes average case interrupt handling slower but much more deterministic, which is what we are striving for.

..................Content has been hidden....................

You can't read the all page of ebook, please click here login for view all page.
Reset
3.144.28.80