Realtime testing

From Rsewiki
Revision as of 12:56, 20 May 2009 by Sh (talk | contribs)
(diff) ← Older revision | Latest revision (diff) | Newer revision → (diff)

RTAI Latency tests

To test the latency use RTAIs build in test program. On the computer to test, go to

/usr/realtime/testsuite/kern/latency

Then insert the module and run the 'display' program:

insmod latency_rt.ko
./display

The program should produce an ouput like this:

## RTAI latency calibration tool ##
# period = 100000 (ns) 
# avrgtime = 1 (s)
# do not use the FPU
# start the timer
# timer_mode is oneshot
RTAI Testsuite - KERNEL latency (all data in nanoseconds)
RTH|    lat min|    ovl min|    lat avg|    lat max|    ovl max|   overruns
RTD|       -682|       -682|       -178|       7826|       7826|          0
RTD|       -787|       -787|       -159|       8111|       8111|          0
RTD|       -667|       -787|       -183|       9802|       9802|          0
RTD|       -618|       -787|        -59|       9277|       9802|          0
RTD|       -517|       -787|        -78|       8651|       9802|          0
RTD|       -599|       -787|        -61|       9964|       9964|          0
RTD|       -716|       -787|        -88|       9442|       9964|          0
RTD|       -543|       -787|        -63|       9982|       9982|          0
RTD|       -671|       -787|        -94|       9521|       9982|          0
RTD|       -659|       -787|        -56|       8576|       9982|          0
RTD|       -551|       -787|        -87|       9397|       9982|          0
RTD|       -502|       -787|        -70|      10001|      10001|          0
RTD|       -671|       -787|        -81|       8006|      10001|          0
RTD|       -629|       -787|        -77|       9629|      10001|          0
RTD|       -607|       -787|        -74|       7799|      10001|          0
RTD|       -532|       -787|        -89|       8921|      10001|          0
RTD|       -532|       -787|        -89|       8921|      10001|          0

Watch the the overrun counter does not increase from zero. The program is stopped by SIGINT (ctrl+c). Remember to unload the module when done.

rmmod latency_rt.ko

CPU time test

In order to verify that rt_get_time_ns() and rt_get_cpu_time_ns() gives the same results use the program p13. The program is compiled by

gcc -Wall -o p13 p13.c -I/usr/realtime/include -L/usr/realtime/lib -llxrt -lpthread

The output should look like this:

[sh@rt15 controllab]$ ./p13
lxrt task connected
locked
soft-rt
Period set to 1000000000ns
Hard real time?y
tick 1,  0.999996
cpu time: 0.999992
tsc diff: 0.999941
RTAI tsc: 0.999941
tick 2,  1.000002
cpu time: 1.000002
tsc diff: 0.999951
RTAI tsc: 0.999951
tick 3,  1.000003
cpu time: 1.000003
tsc diff: 0.999953
RTAI tsc: 0.999953
tick 4,  0.999996
cpu time: 0.999996
tsc diff: 0.999945
RTAI tsc: 0.999945
tick 5,  1.000003
cpu time: 1.000003
tsc diff: 0.999952
RTAI tsc: 0.999952
tick 6,  0.999997
cpu time: 0.999997
tsc diff: 0.999947
RTAI tsc: 0.999947
tick 7,  1.000002
cpu time: 1.000002
tsc diff: 0.999951
RTAI tsc: 0.999951
tick 8,  0.999999
cpu time: 0.999999
tsc diff: 0.999949
RTAI tsc: 0.999949
tick 9,  1.000002
cpu time: 1.000002
tsc diff: 0.999951
RTAI tsc: 0.999951
tick 10,  0.999998
cpu time: 0.999998
tsc diff: 0.999948
RTAI tsc: 0.999948
min 999995810  max 1000003352 
Exiting

The program runs through a 1 second loop 10 times and measures the loop duration. Each sample outputs the time measured in 4 different ways.

tick 1, 0.999996 <-- Time measured by rt_get_time_ns()

cpu time: 0.999992 <-- Time measured by rt_get_cpu_time_ns()

tsc diff: 0.999941 <-- Time measured by reading the CPUs TSC directly

RTAI tsc: 0.999941 <-- Time measured by reading the CPUs TSC by the RTAI call

All measurements should be close to 1 second and alike. If 'cpu time' vary alot (more than 1 ms), especially when running an X server, try to unload and then load the RTAI modules.