70 likes | 240 Views
Example of RTEMS Lab. Controls Department June 24, 2010 Kukhee Kim. Hello World!. Just use printf (). Execute my function. Cexp@ioc-b34-cd15> helloWorld () >>>> Hello World! <<<< 0x0000000a (10) Cexp@ioc-b34-cd15>. Print out from the function. Return from the function. Hello World2.
E N D
Example of RTEMS Lab. Controls Department June 24, 2010 Kukhee Kim
Hello World! • Just use printf() Execute my function Cexp@ioc-b34-cd15>helloWorld() >>>> Hello World! <<<< 0x0000000a (10) Cexp@ioc-b34-cd15> Print out from the function Return from the function
Hello World2 • Print out “Hello World2” and Sweep the LED array • User function has infinite loop to sweep the LED array • When the switch:MSB turns off, the loop will be finished Execute the user function Cexp@ioc-b34-cd15>helloWorld2() >>>> Hello World2 <<<< 0x0000007f (127) Cexp@ioc-b34-cd15> Print out “Hello World” and Sweeps the LED array continuesly When turns off the toggle switch:MSB Take out from the function
Turtle & Rabbit • Two tasks run: Turtle & Rabbit • Turtle sweeps slowly on the LED array • Rabbit sweeps fast on the LED array • Need to consider MUTUAL EXCLUSION • Need to consider SHADOW register • When turns off toggle switch (bit 0), the Turtle will be finished • When turns off toggle switch (bit 1), the Rabbit will be finished Execute user function Cexp@ioc-b34-cd15>tr_init() >>>> Init for turtle and rabbit <<<< >>> Finish Init <<<< 0x0000000a (10) >>>> start turtle <<<< >>>> start rabbit <<<< >>>> finish turtle <<<< >>>> finish rabbit <<<< Cexp@ioc-b34-cd15> The user function generates two tasks and Return to the Cexp Turtle sweeps slowly, and Rabbit sweeps faston the LED array Switch bit0 turned off, and turtle finished. Switch bit 1 turned off, and rabbit finished.
Turtle & Rabbit with Watchdog • Two tasks run: Turtle & Rabbit • Both are almost identical • Infinite loop to sweep the LED array • Shadow register & Mutual Excusion • Hardware watchdog: High-Resolution Timer on the CPU Board • Every 1 msec, watchdog wakes the ISR • Why choose 1 msec? hardware limitation on the interval (~ 2msec) • The ISR re-implement the timer immediately • ISR (1kHz) down convert the frequency • Every 50 msec, sends event to the Rabbit task • Every 200msec, sends event to the Turtle task • Diagnostic Task runs • Monitor ISR counter, Rabbit/Turtle counter • Monitor the event delay between ISR and individual tasks
Turtle & Rabbit with Watchdog Sends a RTEMS event,every 200msec Turtle Task Interrupt ISR 1kHz rates LED array Sends a RTEMS event,every 50msec Re-implement timer Rabbit Task 3 usec delay measured Protecting Shared Object Mutual Exclusion & Shadow register Diagnostic Task Monitoring ISR and each tasks Measure delay between ISR and individual tasks (sub-usec resolution) Report every 2 seconds
Turtle & Rabbit with Watchdog Cexp@ioc-b34-cd15>watchdog_tr_init() >>>> Init for turtle and rabbit <<<< >>>> start turtle <<<< >>>> start rabbit <<<< >>> Finish Init <<<< 0x0000000a (10) ISR counter: 0, Turtle calls: 0, Rabbit calls: 0 Turtle delay: 0.000 usec, Rabbit delay 2.880 usec Cexp@ioc-b34-cd15>ISR counter: 2270, Turtle calls: 11, Rabbit calls: 45 Turtle delay: 3.630 usec, Rabbit delay 2.880 usec ISR counter: 4347, Turtle calls: 21, Rabbit calls: 86 Turtle delay: 3.660 usec, Rabbit delay 2.880 usec ISR counter: 6424, Turtle calls: 32, Rabbit calls: 128 Turtle delay: 3.660 usec, Rabbit delay 3.030 usec ISR counter: 8501, Turtle calls: 42, Rabbit calls: 170 Turtle delay: 3.660 usec, Rabbit delay 2.880 usec ISR counter: 10578, Turtle calls: 52, Rabbit calls: 211 Turtle delay: 3.660 usec, Rabbit delay 2.880 usec ISR counter: 12655, Turtle calls: 63, Rabbit calls: 253 Turtle delay: 3.660 usec, Rabbit delay 2.880 usec ISR counter: 14732, Turtle calls: 73, Rabbit calls: 294 Turtle delay: 3.630 usec, Rabbit delay 2.880 usec ISR counter: 16809, Turtle calls: 84, Rabbit calls: 336 Turtle delay: 3.690 usec, Rabbit delay 3.030 usec