Linux kernel has configuration options that affect it’s real-time capabilities. Default Raspbian kernel is compiled with CONFIG_PREEMPT option that allows all kernel code outside of spinlock-protected regions and interrupt handlers to be preempted by higher priority kernel threads. Real-time patch from Ingo Molnar adds CONFIG_PREEMPT_RT option that allows nearly all of the kernel code to be preempted, except for a few raw spinlock critical regions.
The histogram shows latency comparison between the default Raspbian kernel and the kernel with real-time patch.
We’ve used cyclictest program to obtain data with the following parameters:
cyclictest -l10000000 -m -n -a0 -t1 -p99 -i400 -h400 -q
Latencies for default Raspbian kernel (PREEMPT) in uS: Min: 00014 Avg: 00028 Max: 01247
Latency results for PREEMPT_RT patched kernel in uS: Min: 00012 Avg: 00027 Max: 00077
The most important characteristic here is the max latency which indicates the longest time it might take your Raspberry Pi to respond to an event. As it can be observed PREEMPT_RT kernel provides much lower latency thus making it more suitable for usage in time-sensitive embedded systems. It is important to remember that to make full use of real time capabilities of the kernel it is necessary to do proper prioritizing.
You can compile PREEMPT_RT real time kernel for Raspberry Pi by yourself or you can download modified Raspbian SD card image that we prepared. The image was tested for compatibility with Raspberry Pi Model B and Raspberry Pi Model B+. The image is not intended for general purpose use but rather for embedded electronics projects.
UPDATE (10 SEP 2014) – Raspbian with RT-kernel for Raspberry Pi Model B+ (also compatible with Model B) UPDATE (25 NOV 2014) – Raspbian with RT-kernel for Raspberry Pi Model A/B/A+/B+. Download links:
UPDATE (21 JAN 2015) – Raspbian with RT-kernel for Raspberry Pi Model A/B/A+/B+. SD card image downloads: