Real-time Linux kernel

Real-time Linux Kernel Background[edit]

Since Linux v2.6.x, the real-time features are partially migrated into the mainline release of Linux kernel development, enabling the task preemption by setting CONFIG_PREEMPT=y. It enables all kernel codes outside of spinlock-protected regions and interrupt handlers can be eligible for non-voluntary preemption by higher priority kernel threads. With this option, worst case latency drops to (around) single digit milliseconds, although some device drivers can have interrupt handlers that will introduce latency much worse than that. If a real-time Linux application requires latencies smaller than single-digit milliseconds, use of the CONFIG_PREEMPT=y patch is highly recommended. More details can be found here.

The CONFIG_PREEMPT_RT is the rt-linux patch that maintained separatedly at rt.wiki.kernel.org. It introduces the following configuration options into kernel:

  • No preemption – Do as most possible with as little scheduling overhead. Use for server in Linux 2.4
  • Voluntary preemption – Schedule only at “preemption points”
  • Preemptible Kernel – CONFIG_PREEMPT. Preempt anywhere except within spin_locks
  • Preemptible Kernel (Basic RT) - CONFIG_PREEMPT_RT_BASE=y
  • Fully Preemptible Kernel – CONFIG_PREEMPT_RT_FULL. Preempts everywhere except from preempt_disable and interrupts disabled.


The Android's Linux kernel in RTDroid:[edit]

By default, Android's Linux kernel is a preemptible kernel (CONFIG_PREEMPT=y). Our previous work is on Nexus S (kernel version --- v3.0.50). Its kernel is patched with rt-patch, enabling CONFIG_PREEMPT_RT_BASE=y. For the latest Android M (v6.0.x), we use Nexus 5 with the stock kernel (v3.4.0), enabling CONFIG_PREEMPT.