1 / 24

RTAI & LTT

RTAI & LTT. Choi Sung Chul. What is the RTAI ?. Realtime Application Interface A patch to the Linux kernel which introduces a hardware abstraction layer A broad variety of services which make realtime programmers' lifes easier Working with POSIX compliant or native RTAI realtime tasks

vesna
Télécharger la présentation

RTAI & LTT

An Image/Link below is provided (as is) to download presentation Download Policy: Content on the Website is provided to you AS IS for your information and personal use and may not be sold / licensed / shared on other websites without getting consent from its author. Content is provided to you AS IS for your information and personal use only. Download presentation by click this link. While downloading, if for some reason you are not able to download a presentation, the publisher may have deleted the file from their server. During download, if you can't get a presentation, the file might be deleted by the publisher.

E N D

Presentation Transcript


  1. RTAI & LTT Choi Sung Chul

  2. What is the RTAI ? • Realtime Application Interface • A patch to the Linux kernel which introduces a hardware abstraction layer • A broad variety of services which make realtime programmers' lifes easier • Working with POSIX compliant or native RTAI realtime tasks • Linux application is able to execute without any modification

  3. What kind of functions does RTAI support? • real time scheduler module - Task functions- Timing functions- Semaphore functions- Mailbox functions- Intertask communication functions • Fifo services • Shared memory • Posix pthread and pqueue(msg queue)

  4. How to make a RTAI program • It is a similar to make linux kernel module • Use several functions for RTAI program • Example RTAI program int init_module(void) { RTIME tick_period; rt_set_periodic_mode(); rt_task_init(&rt_task, fun, 1, STACK_SIZE, TASK_PRIORITY, 1, 0); rtf_create(FIFO, 8000); tick_period = start_rt_timer(nano2count(TICK_PERIOD)); rt_task_make_periodic(&rt_task, rt_get_time() + tick_period, tick_period); return 0; } void cleanup_module(void) { stop_rt_timer(); rtf_destroy(FIFO); rt_task_delete(&rt_task); return; }

  5. What is the LTT? • Linux Trace Toolkit • Linux kernel tracing capabilities with 48 unique Trace Points • Variable-length events minimizing overall trace size • Minimal performance overhead (< 2.5 %). • Micro-second event time-stamps • graphical user interface with event graph, system and per-process analysis, and raw event descriptions. • Support for the Real-Time Application Interface

  6. Why LTT? • It is too hard to debug kernel like Real Time program • It isn’t able to be checked transmitting and receiving message or signal accuracy • We can see the kernel event and message transferring easily to use LTT • LTT can make user defined event(custom event)  it needs not use “printk”!! • LTT can dump selected event and message. So, we can save it and analysis anytime

  7. Install RTAI & LTT (1) • Need files - TraceToolkit 0.95a  http://www.opersys.com/LTT/ - linux kernel 2.4.16  http://www.kernel.org - RTAI 24.1.11  http://www.aero.polimi.it/RTAI/ • Compiler - gcc version 2.95.3

  8. Install RTAI & LTT (2) • Linux Kenel Patch & Compile Patch from LTT patchs directory - #~/linux>patch -p1 < ~/TraceToolkit-0.9.5a/Patches/patch-ltt-linux-2.4.16-rthal5f-020415-1.14 • Modify kernel source (2 files) - linux/arch/i386/kernel/irq.c ,linux/include/asm-i386/system.h • Kernel setting & compile - NO : Set version information on all module symbols - YES : Real-Time Hardware Abstraction Layer - Module : Kernel event tracing support - YES : RTAI event tracing support - APM : disable • Make boot image & Reboot - Add boot image to lilo or grub

  9. Install RTAI & LTT (3) • Install RTAI - #> Configure –menu  Menu Setting • Modify sources (2 files) - arch/i386/rtai.c , upscheduler/rtai_sched.c • Make & make install • Load modules $> modprobe -v rtai /sbin/insmod /lib/modules/2.4.16-rthal5trace/rtai/rtai_tracer.o Using /lib/modules/2.4.16-rthal5-trace/rtai/rtai_tracer.o Symbol version prefix 'smp_' /sbin/insmod /lib/modules/2.4.16-rthal5-trace/rtai/rtai.o Using /lib/modules/2.4.16-rthal5-trace/rtai/rtai.o $>lsmod Module Size Used by Tainted: P rtai 56320 0 (unused) rtai_tracer 9024 0 [rtai] binfmt_misc 7524 1 ….

  10. Install RTAI & LTT (3) • Configire –with-rtai & make install • Execute createdev.sh (make node /dev/tracer) - $> ./createdev.sh Deleting old tracer nodes: /dev/tracer and /dev/tracerU Found tracer device with major number: 253 Creating new tracer nodes: /dev/tracer and /dev/tracerU • Trace time(sec) - this records data(kernel and app trace event) for require time • Traceview - graphic tool for event graph, system and per-process analysis, and raw event descriptions

  11. LTT & Traceview Screenshot

  12. Example1 for using LTT in a RTAI program • Offered ex - /rtai-24.1.11/examples/msgsw • This example features NTASKS(8) real-time tasks running periodically • On each period a server task is messaged to set/reset a bit on the parallel port • By choosing an appropriate timing one can produce a rectangular wave which can be watched on an oscilloscope plugged into it

  13. Block diagram for example1

  14. Flow diagram for example1

  15. Traceview of example1

  16. Zoom function of Traceview

  17. Example2 for using LTT in a RTAI program • Simple wave actived generator simulation • Let’s wave factor = sin(t) • A sensor for wave height • Its pen of Turbine changes direction when height reaches max or min value • Turbine always rotate one side direction.

  18. Simplify model for wave actived generator

  19. Simple SDL for example2 program

  20. User defined custom event • When it can’t be used printk and must be checked variable • LTT support user define event int trace_create_event ( char* /* String describing event type */, char* /* String to format standard event description */, int /* Type of formatting used to log event data */, char* /* Data specific to format */); int trace_destroy_event( int /* The event ID given by trace_create_event() */); int trace_user_event( int /* The event ID given by trace_create_event() */, int /* The size of the raw data */, void* /* Pointer to the raw event data */);

  21. Custom event of example1 • Make event traceId = trace_create_event("WaveActivedGen", "%s", CUSTOM_EVENT_FORMAT_TYPE_STR, NULL); trace_std_formatted_event(traceId, "Trace init_module"); • Wave height value sprintf(dbgMsg, "height:%d", (int)wave_height); trace_std_formatted_event(traceId, dbgMsg); • Recv turn event trace_std_formatted_event(traceId, "Do Pen Turn Right!"); trace_std_formatted_event(traceId, "Do Pen Turn Left!");

  22. Dump event and message • Traceview -> menu -> file ->dump file • Select dump message or event • Example2 custom message dump Trace start time: (1097134998, 633202) Trace end time: (1097135001, 614397) Trace duration: (2, 981195) Number of occurences of: Events: 22029 Scheduling changes: 821 Kernel timer tics: 228 System call entries: 3006 System call exits: 3005 Trap entries: 0 Trap exits: 0 IRQ entries: 337 IRQ exits: 337 Bottom halves: 228 Timer expiries: 73 Page allocations: 417 Page frees: 415 Packets Out: 0 Packets In: 112

  23. ######################################################################################################################################## Event Time PID Length Description #################################################################### Event creation 1,097,134,998,633,204 N/A 391 NEW EVENT TYPE : WaveActivedGen; CUSTOM EVENT ID : 24 RT-Timer 1,097,134,998,633,860 N/A 16 TIMER EXPIRY WaveActivedGen 1,097,134,998,633,866 N/A 30 height:183 RT-Task 1,097,134,998,633,866 N/A 28 WAIT PERIOD RT-Timer 1,097,134,998,640,546 1138 16 TIMER EXPIRY RT-Task 1,097,134,998,640,551 1138 28 WAIT PERIOD WaveActivedGen 1,097,134,998,640,558 1138 30 height:185 RT-Task 1,097,134,998,640,558 1138 28 WAIT PERIOD RT-Timer 1,097,134,998,647,236 1138 16 TIMER EXPIRY WaveActivedGen 1,097,134,998,647,241 1138 30 height:187 RT-Task 1,097,134,998,647,242 1138 28 WAIT PERIOD RT-Timer 1,097,134,998,653,921 1253 16 TIMER EXPIRY RT-Task 1,097,134,998,653,925 1253 28 WAIT PERIOD WaveActivedGen 1,097,134,998,653,932 1253 30 height:189 RT-Task 1,097,134,998,653,933 1253 28 WAIT PERIOD RT-Timer 1,097,134,998,660,610 1138 16 TIMER EXPIRY WaveActivedGen 1,097,134,998,660,620 1138 30 height:190 RT-Task 1,097,134,998,660,620 1138 28 WAIT PERIOD RT-Timer 1,097,134,998,667,295 0 16 TIMER EXPIRY RT-Task 1,097,134,998,667,297 0 28 WAIT PERIOD WaveActivedGen 1,097,134,998,667,300 0 30 height:192 RT-Task 1,097,134,998,667,300 0 28 WAIT PERIOD RT-Timer 1,097,134,998,673,985 0 16 TIMER EXPIRY WaveActivedGen 1,097,134,998,673,987 0 30 height:193 RT-Task 1,097,134,998,673,987 0 28 WAIT PERIOD RT-Timer 1,097,134,998,680,670 0 16 TIMER EXPIRY RT-Task 1,097,134,998,680,672 0 28 WAIT PERIOD WaveActivedGen 1,097,134,998,680,676 0 30 height:194 RT-Task 1,097,134,998,680,676 0 28 WAIT PERIOD RT-Timer 1,097,134,998,687,359 0 16 TIMER EXPIRY WaveActivedGen 1,097,134,998,687,361 0 30 height:195 RT-Task 1,097,134,998,687,361 0 28 WAIT PERIOD RT-Timer 1,097,134,998,694,046 0 16 TIMER EXPIRY RT-Task 1,097,134,998,694,047 0 28 WAIT PERIOD WaveActivedGen 1,097,134,998,694,050 0 30 height:196 RT-Task 1,097,134,998,694,051 0 28 WAIT PERIOD RT-Timer 1,097,134,998,700,736 0 16 TIMER EXPIRY WaveActivedGen 1,097,134,998,700,739 0 30 height:197

  24. WaveActivedGen 1,097,134,998,754,238 0 30 height:199 RT-Task 1,097,134,998,754,239 0 28 WAIT PERIOD RT-Timer 1,097,134,998,760,923 0 16 TIMER EXPIRY RT-Message 1,097,134,998,760,924 0 24 SEND => TASK : 1; MSG : 1d WaveActivedGen 1,097,134,998,760,927 0 38 Do Pen Turn Right! RT-Message 1,097,134,998,760,927 0 24 RECEIVE => TASK : 2 RT-Task 1,097,134,998,760,928 0 28 WAIT PERIOD WaveActivedGen 1,097,134,998,760,931 0 30 height:199 RT-Task 1,097,134,998,760,932 0 28 WAIT PERIOD RT-Timer 1,097,134,998,767,612 0 16 TIMER EXPIRY WaveActivedGen 1,097,134,998,767,614 0 30 height:199 RT-Task 1,097,134,998,767,614 0 28 WAIT PERIOD RT-Timer 1,097,134,998,774,299 0 16 TIMER EXPIRY RT-Task 1,097,134,998,774,300 0 28 WAIT PERIOD WaveActivedGen 1,097,134,998,774,303 0 30 height:198

More Related