Author: Michael Haberler

I did a few measurements with the Rpi, see below.

Errata notice Nov 21 2012

I have learned since I wrote this that the stock Raspbian kernel I used (Linux raspberrypi 3.2.27+ #102 PREEMPT Sat Sep 1 01:00:50 BST 2012 armv6l GNU/Linux) was not, in fact having the RT_PREEMPT patches applied, so it is a fairly vanilla kernel without provisions for improved realtime behaviour.

I would be interested about pointers to a Raspberry kernel with RT_PREEMPT patches applied.

Also, the reasons for the periodic increase in delay in 125uS intervals are clearer (originally this was under RT-Preempt Kernel - user process, C, now Raspbian kernel - user process, C).

Raspbian Kernel - Python GPIO

First try was to get gpio pin wiggling to work with the module, just to see what kind of timings one could expect for a Python user HAL component. Not very interesting except establish a baseline.

Kernel was Linux raspberrypi 3.2.27+ #102 PREEMPT Sat Sep 1 01:00:50 BST 2012 armv6l GNU/Linux.


Results from logic analyzer:


Raspbian Kernel - user process, C

I tried to find out how fast can we wiggle a GPIO from C. The answer - about every 250nS, if you busy-loop. So that’s the baseline for the IO path delay.


Results from logic analyzer


The clock_nanosleep() routine doesnt work below say 50uS, so the delays were done with a busy wait.

Periodic increases in latency

Note that every 125uS the scheduler intervenes and the signal stops for about 4.5uS, after which the CPU is returned to the test program.

The following thread sheds some light on the likely cause:

which is the dwc_otg driver (USB+Ethernet I/O) requiring this interrupt frequency. I understand that the interrupt service routine since has been recoded to use less resources ( so it might be worthwhile to re-run these tests.

Xenomai Kernel - user process, C

Kernel self-built, based on 3.2.21 and Xenomai 2.6. The source and config for this kernel can be found here: .

kernel: Linux raspberrypi 3.2.21-ipipe-mah1+ #1 PREEMPT Mon Sep 10 18:18:45 UTC 2012 armv6l GNU/Linux

Results from logic analyzer

Run on an otherwise idle CPU, interval 20uS:


Run on an otherwise idle CPU, interval 30uS:


adding load

I started to compiles, make libzmq and make in the xenomai-2.6 directory in parallel, then xgpio with 20uS timer as above, 3 independent runs (note: my LA only supports 2K samples):


Note the logarithmic scale on the Y axis.