12.07.2015 Views

Understanding the Latest Open-Source Implementations of Real ...

Understanding the Latest Open-Source Implementations of Real ...

Understanding the Latest Open-Source Implementations of Real ...

SHOW MORE
SHOW LESS

You also want an ePaper? Increase the reach of your titles

YUMPU automatically turns print PDFs into web optimized ePapers that Google loves.

Technical ViewIt <strong>the</strong>refore allows all applications implementedon Xenomai skins to run directly on a monolithickernel. In o<strong>the</strong>r words, Xenomai 3.0 acts as anabstraction layer over <strong>the</strong> regular Linux kernel,providing this kernel’s real-time capabilities to itsapplications through <strong>the</strong> various skins. Xenomai3.0 only requires <strong>the</strong> standard POSIX API, sothat no patching or porting to particular kernelversions is needed.This gives <strong>the</strong> developer <strong>of</strong> applications for Xenomaia useful choice: to run <strong>the</strong> applications under asmall, lightweight and industry-proven real-timekernel, or under a preemptible Linux monolithickernel. It is important to understand, however,that <strong>the</strong> second choice means that all real-timecapabilities have to come from – and are only asgood as – <strong>the</strong> underlying Linux kernel itself.Dual Kernel Versus Native PreemptionEach method has its own benefits. The co-kernelapproach has <strong>the</strong> advantage that <strong>the</strong> real-timeapplication is totally independent <strong>of</strong> <strong>the</strong> Linuxkernel and only depends on <strong>the</strong> real-time kernel,scheduler and abstraction layers. There is a clearseparation between <strong>the</strong> real-time and non-realtimedomain. This simplifies maintenance, timingand safety certification.Porting to new CPU architectures is also easy,because only <strong>the</strong> abstraction layers have to beadapted. An interrupt abstraction layer patch,however, is always specific to a certain kernelversion, and patches are only available forselected versions <strong>of</strong> <strong>the</strong> <strong>of</strong> <strong>the</strong> mainline kernel.Under <strong>the</strong> single-kernel approach with <strong>the</strong> Linux/PREEMPT_RT patch, a POSIX real-time APIallows real-time applications to be developed in<strong>the</strong> GNU/Linux user-space, and to benefit fromall development, debugging and pr<strong>of</strong>iling toolsavailable <strong>the</strong>re.At some point in <strong>the</strong> future, <strong>the</strong> RT_PREEMPTpatch will be completely merged into <strong>the</strong> mainlinekernel, and <strong>the</strong>n it will be simple to compile areal-time kernel for any supported system. Then,however, every modification to <strong>the</strong> operatingsystem, such as kernel patches or new drivers,might influence <strong>the</strong> system in a perhapsundesired way. Therefore <strong>the</strong> system will haveto be re-qualified and possibly re-certified aftersuch modifications.Ano<strong>the</strong>r drawback is that <strong>the</strong> Linux/PREEMPT_RTentails higher worst-case latencies than adual-kernel system.In <strong>the</strong> author’s opinion, using <strong>the</strong> POSIX real-timeAPI is <strong>the</strong> best answer to <strong>the</strong> problem <strong>of</strong> decidingbetween <strong>the</strong> two approaches. Depending on <strong>the</strong>specific requirements <strong>of</strong> <strong>the</strong> end product, POSIXreal-time applications can ei<strong>the</strong>r run on Xenomai’sdedicated real-time kernel or on a single Linux/PREEMPT_RT kernel.Performance Evaluation in <strong>the</strong> <strong>Real</strong> WorldSo just how ‘real’ is <strong>the</strong> real-time performance<strong>of</strong> Linux? Below is a method to get a quick firstimpression <strong>of</strong> <strong>the</strong> latency <strong>of</strong> any given system.The tool cyclictest is used to schedule a task with<strong>the</strong> highest priority every 10ms. The tool knowswhen this task is expected to run and calculates<strong>the</strong> latency or deviation from this expected time.Table 1 shows <strong>the</strong> results <strong>of</strong> a test run on aFreescale i.MX53 ARM Cortex-A8 processoroperating at 1GHz. It ran Linux kernel 2.6.38 from<strong>the</strong> DENX Linux tree. Two different test systemswere set up.S_CPRE: standard kernel withCONFIG_PREEMPT (“Preemptible Kernel(Low-Latency Desktop)) enabled./cyclictest –m -n -p99 -t1 -i10000 -1360000S_XENO: Kernel + Xenomai 2.6.0-rc4 + I-Pipe1.18-03./cyclictest -n -p99 -t1 -i10000 -1360000SystemLatency/µsS_XENOS_CPRE1st runS_CPRE2nd runMinimum 2 27 13Average 43 88 81Maximum 58 415 1829Table 1: Cyclic test <strong>of</strong> single- and dual-kernel Linux systemsThe average latency shows <strong>the</strong> typical values thatcan be expected from this system. For developers<strong>of</strong> hard real-time applications, however, only <strong>the</strong>maximum latency is <strong>of</strong> interest. The table clearlyshows <strong>the</strong> superior performance <strong>of</strong> a dual-kernelsystem.ConclusionWhen <strong>the</strong> entire PREEMPT_RT patch has goneinto mainline Linux, it will be <strong>the</strong> method <strong>of</strong> choicefor ordinary real-time applications. Xenomai 3.0will <strong>the</strong>n allow easy porting <strong>of</strong> existingapplications to a single, real-time Linux kernel.A dual-kernel approach will continue to be mostappropriate for hard real-time requirements.For developers <strong>of</strong> new applications, <strong>the</strong> use <strong>of</strong> <strong>the</strong>POSIX API is highly recommended whe<strong>the</strong>r <strong>the</strong>yare implementing a single- or dual-kernel system.In <strong>the</strong> near future, <strong>the</strong> trend to use multi-coreprocessors will allow for new solutions to <strong>the</strong>problems discussed in this article. For example,it is already possible in mainline GNU/Linux toassign interrupts to a CPU core and to keep nonreal-timetasks away from this core. Interestingly,<strong>the</strong>refore, a multi-core system nullifies <strong>the</strong>performance advantage <strong>of</strong> <strong>the</strong> dual-kernelapproach. An asymmetric CPU such asFreescale’s Vybrid processor family (using acombination <strong>of</strong> ARM Cortex-A5 and Cortex-M4cores) <strong>of</strong>fers <strong>the</strong> option <strong>of</strong> running multipleoperating systems, each optimised for differentfunctions, to even fur<strong>the</strong>r improve hard or s<strong>of</strong>treal-time performance.* POSIX is a series <strong>of</strong> IEEE standards that helpensure compatibility across operating systems bydefining a series <strong>of</strong> application program interfaces(APIs), functions and command-line shells foruse by <strong>the</strong> OS. Many embedded OSs are POSIXcompliant,including VxWorks, Linux, MQXand QNX.1.800.FUTURE.1 • www.FutureElectronics.com27

Hooray! Your file is uploaded and ready to be published.

Saved successfully!

Ooh no, something went wrong!