I am happy with the PREEMPT_RT patches (Real-time Linux). I need a timer to execute a task every 40 milliseconds. The base for this the timer is usleep(3) (let's not use nanosleep(3)).
Here is the source code of the test. The idea is to sample 10000 calls to usleep to check how long they take without the patches, with the patches, and with the patches and real-time priority. All the tests are run as root.
We care about the worst case and we want a good average.
- Laptop without patches (Intel Celeron CPU / 1.80GHz / 3593.27 bogomips)
System idle
$ ./test max:13.684 min:2.02 avg:2.10364
$ ./test max:13.993 min:2.016 avg:2.08508
Worst case: missed abut 12 milliseconds.
Heavy load.
Let's make the system busy with 10 instances of yes > /dev/null &. This will be our definition for heavy load.
$ ./test max:24.141 min:2.016 avg:2.07188
$ ./test max:12.711 min:2.017 avg:2.06129
$ ./test max:12.665 min:2.016 avg:2.0828
Worst case: missed abut 22 milliseconds.
- Board with the patches (Geode(TM) Integrated Processor by AMD PCS / 500MHz / 1000.62 bogomips).
System idle (no real-time priority).
$ ./test max:2.197 min:2.026 avg:2.0406
$ ./test max:2.085 min:2.026 avg:2.04062
$ ./test max:2.22 min:2.026 avg:2.04087
Just using the patches helps a lot. This systems is by far slower and in the worst case we missed the deadline for 0.197 milliseconds (197 microseconds) – compare 0.197 to 22 miliseconds!
System busy (no real-time priority).
$ ./test max:2.998 min:2.027 avg:2.02964
$ ./test max:2.129 min:2.027 avg:2.02938
$ ./test max:2.101 min:2.027 avg:2.02945
$ ./test max:2.116 min:2.027 avg:2.02944
In the worst case we lost one millisecond.
System busy (real-time priority 10).
$ ./test 10 Using realtime priority: 10 max:2.043 min:2.027 avg:2.02842
$ ./test 10 Using realtime priority: 10 max:2.092 min:2.027 avg:2.02842
$ ./test 10 Using realtime priority: 10 max:2.043 min:2.027 avg:2.02842
In the worst case we missed 92 microseconds (about 0.1 milliseconds). Not bad at all for this CPU.
You should not use a RT priority above 50 because signals don't get delivered and a program waiting for a signal can lock the machine.
In the worst (real) case we missed 92 microseconds (0.092 milliseconds).
As you can see the PREEMPT_RT patch helps a lot. I won't have issues with the timer I need.
Links:
- http://rt.wiki.kernel.org/index.php/Squarewave-example - This is a better test.
- Platforms tested and in use with CONFIG_PREEMPT_RT.
- http://del.icio.us/arhuaco/preempt_rt
- Link to recommend this product
Last update: 2008-02-19 (Rev 13703)

