As promised, here’s my Part Two blog posting regarding the raspberrry pi.
The default kernel in Raspbian Jesse, the latest release of the raspberry pi’s official OS, could use a tune-up before being fit for duty running time-sensitive machine controls. On a vanilla Linux kernel program, latencies depend on everything running on the system making consistent and punctual tasks difficult to guarantee. The RT PREEMPT patch is a popular fix for this problem. The patch converts Linux into a fully preempt-able RTOS. If you want to control physical processes with your pi, as I intend to in DISTek’s training curriculum update, this is the way to go. But how big of a difference does it make on a pi?
To answer this, I turned to the high resolution test program cyclictest. Cyclictest measures a system’s latency response by running at regular intervals and measuring the time in between them. This simple algorithm accounts for everything that can delay a task and contribute to latency. Below is how you run this on the Raspberry pi:
pi@distekpi:~ $ git clone git://git.kernel.org/pub/scm/utils/rt-tests.git
pi@distekpi:~ $ cd rt-tests
pi@distekpi:~ $ make all
pi@distekpi:~ $ cp ./cyclictest /usr/bin/
pi@distekpi:~ $ sudo cyclictest -m -t1 -p 80 -n -i 500 -l 100000
Note: on the newer multi-core raspberry pi’s, the -t1 option should be -tn, where n is the number of cores.
Here are my before and after results on DISTek’s Raspberry pi B+:
All of those times are in μs. With this performance, 1ms tasks should be reliable and safe. For instructions on how to build and install a patched kernel to your pi, follow this tutorial on the real time Linux wiki.