Difference between revisions of "Real Time in Embedded Linux System"

From IGEP - ISEE Wiki

Jump to: navigation, search
 
(8 intermediate revisions by 3 users not shown)
Line 3: Line 3:
 
Based on free training materials from Free Electrons covering real-time (http://free-electrons.com/docs/realtime/)
 
Based on free training materials from Free Electrons covering real-time (http://free-electrons.com/docs/realtime/)
  
Learn how to handle real-time processes and practice with the different real-time modes. Measure scheduling latency.
+
The purpose of this article is measure scheduling latency in different conditions.
 
 
== Setup ==
 
  
 
== Using high-resolution timers ==
 
== Using high-resolution timers ==
  
Have a look at the rttest.c source file
+
Have a look at the [http://downloads.isee.biz/pub/files/examples/rttest.c rttest.c] source file
  
 
Now compile this program:
 
Now compile this program:
Line 17: Line 15:
 
Execute the program on the board
 
Execute the program on the board
  
=== Testing the non-preemption kernel ===
+
=== Testing the voluntary preemption kernel ===
  
=== Testing the voluntary preemption kernel ===
+
Test done with linux-2.6.35.y branch from  git://git.igep.es/pub/scm/linux-omap-2.6.git
  
 
Recompile your kernel with CONFIG_PREEMPT_VOLUNTARY enabled and test the program with nothing special
 
Recompile your kernel with CONFIG_PREEMPT_VOLUNTARY enabled and test the program with nothing special
Line 57: Line 55:
  
 
=== Testing the preemptible kernel ===
 
=== Testing the preemptible kernel ===
 +
 +
Test done with linux-2.6.35.y branch from  git://git.igep.es/pub/scm/linux-omap-2.6.git
  
 
Recompile your kernel with CONFIG_PREEMPT enabled and test the program with nothing special
 
Recompile your kernel with CONFIG_PREEMPT enabled and test the program with nothing special
Line 93: Line 93:
 
=== Testing the Xenomai scheduling latency ===
 
=== Testing the Xenomai scheduling latency ===
  
  $ wget http://download.gna.org/xenomai/stable/xenomai-2.6.0.tar.bz2
+
Test done with linux-2.6.35.y-rt branch from  http://git.isee.biz/?p=pub/scm/linux-omap-2.6.git;a=shortlog;h=refs/heads/linux-2.6.35.y-rt
 +
 
 +
Recompile your kernel with CONFIG_XENOMAI enabled and test the program with nothing special
 +
 
 +
# ./rttest
 +
Clock resolution (ns): 1
 +
Measurement, please wait 1 minute...
 +
Samples: 327833
 +
Min latency: 73 us
 +
Max latency: 9702 us
 +
Average latency: 80 us
 +
 
 +
Test your program and at the same time, add some workload
 +
to the board, by running
 +
 
 +
# stress --cpu 1 --io 2 --vm 2 --vm-bytes 128M --timeout 120s &
 +
# ./rttest
 +
Clock resolution (ns): 1
 +
Measurement, please wait 1 minute...
 +
Samples: 320301
 +
Min latency: 63 us
 +
Max latency: 10006 us
 +
Average latency: 85 us
  
=== rt-tests ===
+
Test your program again with the workload, but by running the program in the SCHED_FIFO scheduling class at priority 99
  
  $ git clone git://github.com/clrkwllms/rt-tests.git
+
  # stress --cpu 1 --io 2 --vm 2 --vm-bytes 128M --timeout 120s &
 +
# chrt -f -r 99 ./rttest
 +
Clock resolution (ns): 1
 +
Measurement, please wait 1 minute...
 +
Samples: 453705
 +
Min latency: 18 us
 +
Max latency: 395 us
 +
Average latency: 30 us
  
 
== Links ==
 
== Links ==
Line 107: Line 136:
 
** https://www.osadl.org/Latency-generator.latency-generator.0.html
 
** https://www.osadl.org/Latency-generator.latency-generator.0.html
 
** https://www.osadl.org/Visualize-the-temporal-relationship-of-L.taks-visualizer.0.html
 
** https://www.osadl.org/Visualize-the-temporal-relationship-of-L.taks-visualizer.0.html
 +
** http://elinux.org/Realtime_Testing_Best_Practices
 
* Other resources
 
* Other resources
 +
** http://www.osadl.org/Realtime-Linux.projects-realtime-linux.0.html
 +
** https://rt.wiki.kernel.org/index.php/Main_Page
 
** https://www.osadl.org/fileadmin/dam/rtlws/12/Brown.pdf
 
** https://www.osadl.org/fileadmin/dam/rtlws/12/Brown.pdf
 
** http://embedded.communities.intel.com/servlet/JiveServlet/download/4435-1248/xeno_intel.pdf
 
** http://embedded.communities.intel.com/servlet/JiveServlet/download/4435-1248/xeno_intel.pdf
 +
 +
 +
[[Category:Software distributions]][[Category:How to forge]][[Category:Software applications]]

Latest revision as of 10:17, 1 July 2015

Real-time - Timers and scheduling latency

Based on free training materials from Free Electrons covering real-time (http://free-electrons.com/docs/realtime/)

The purpose of this article is measure scheduling latency in different conditions.

Using high-resolution timers

Have a look at the rttest.c source file

Now compile this program:

# gcc -o rttest rttest.c -lrt

Execute the program on the board

Testing the voluntary preemption kernel

Test done with linux-2.6.35.y branch from git://git.igep.es/pub/scm/linux-omap-2.6.git

Recompile your kernel with CONFIG_PREEMPT_VOLUNTARY enabled and test the program with nothing special

Test the program with nothing special

# ./rttest 
Clock resolution (ns): 1
Measurement, please wait 1 minute...
Samples: 153046
Min latency: 113 us
Max latency: 7712 us
Average latency: 292 us

Test your program and at the same time, add some workload to the board, by running

# stress --cpu 1 --io 2 --vm 2 --vm-bytes 128M --timeout 120s &
# ./rttest 
Clock resolution (ns): 1
Measurement, please wait 1 minute...
Samples: 90233
Min latency: 83 us
Max latency: 28586 us
Average latency: 558 us

Test your program again with the workload, but by running the program in the SCHED_FIFO scheduling class at priority 99

# stress --cpu 1 --io 2 --vm 2 --vm-bytes 128M --timeout 120s &
# chrt -f -r 99 ./rttest
Clock resolution (ns): 1
Measurement, please wait 1 minute...
Samples: 210637
Min latency: 52 us
Max latency: 2219 us
Average latency: 181 us

Testing the preemptible kernel

Test done with linux-2.6.35.y branch from git://git.igep.es/pub/scm/linux-omap-2.6.git

Recompile your kernel with CONFIG_PREEMPT enabled and test the program with nothing special

# ./rttest
Clock resolution (ns): 1
Measurement, please wait 1 minute...
Samples: 154210
Min latency: 113 us
Max latency: 9085 us
Average latency: 288 us

Test your program and at the same time, add some workload to the board, by running

# stress --cpu 1 --io 2 --vm 2 --vm-bytes 128M --timeout 120s &
# ./rttest 
Clock resolution (ns): 1
Measurement, please wait 1 minute...
Samples: 113158
Min latency: 83 us
Max latency: 15921 us
Average latency: 421 us

Test your program again with the workload, but by running the program in the SCHED_FIFO scheduling class at priority 99

# stress --cpu 1 --io 2 --vm 2 --vm-bytes 128M --timeout 120s &
# chrt -f -r 99 ./rttest
Clock resolution (ns): 1
Measurement, please wait 1 minute...
Samples: 235302
Min latency: 83 us
Max latency: 296 us
Average latency: 150 us

Testing the Xenomai scheduling latency

Test done with linux-2.6.35.y-rt branch from http://git.isee.biz/?p=pub/scm/linux-omap-2.6.git;a=shortlog;h=refs/heads/linux-2.6.35.y-rt

Recompile your kernel with CONFIG_XENOMAI enabled and test the program with nothing special

# ./rttest
Clock resolution (ns): 1
Measurement, please wait 1 minute...
Samples: 327833
Min latency: 73 us
Max latency: 9702 us
Average latency: 80 us

Test your program and at the same time, add some workload to the board, by running

# stress --cpu 1 --io 2 --vm 2 --vm-bytes 128M --timeout 120s &
# ./rttest 
Clock resolution (ns): 1
Measurement, please wait 1 minute...
Samples: 320301
Min latency: 63 us
Max latency: 10006 us
Average latency: 85 us

Test your program again with the workload, but by running the program in the SCHED_FIFO scheduling class at priority 99

# stress --cpu 1 --io 2 --vm 2 --vm-bytes 128M --timeout 120s &
# chrt -f -r 99 ./rttest
Clock resolution (ns): 1
Measurement, please wait 1 minute...
Samples: 453705
Min latency: 18 us
Max latency: 395 us
Average latency: 30 us

Links