Introducing a robust multitasking operating system for real-time demands 06.05.2013 Introducing a robust multitasking OS Michael Fritscher 1
Agenda • Introduction • Architecture • Function tests • Benchmarks • Conclusion • Outlook 06.05.2013 Introducing a robust multitasking OS Michael Fritscher 2
Introduction Status before • Robot platform (Merlin) existent • New Microcontroller (XE167) and the IDE already working • BUT: The used OS had neither the performance nor the support functions which were needed by many tasks 06.05.2013 Introducing a robust multitasking OS Michael Fritscher 3
Introduction Goals Design and Implementation of a new foundation for many different applications for the future Needed attributes: • Containment and abstraction • Preemptive multitasking • Real time • Detection and Reaction of error states • Easy to develop with (It will be used by students) 06.05.2013 Introducing a robust multitasking OS Michael Fritscher 4
Tasks Task prototype: „Sensing -Processing- Reaction“ Wait for signals Signals fired (releasing control) Get the control React back Prozess the Which signals signals were fired? 06.05.2013 Introducing a robust multitasking OS Michael Fritscher 5
Architecture Overview Communication Task 1 Task … Task n Frameworks (actuators, sensors, streams) IPC Data pre/post I2C processing Common data structures Scheduler / Stacks Signals Heap Drivers Memory (Stack, RTC Timer / IRQs UART (COM, CAN A/D Digital Page pointers, MPU) Counters I2C, SPI) Convertors I/O XE167 Core 06.05.2013 Introducing a robust multitasking OS Michael Fritscher 6
Architecture: Scheduler Normal operation Task1 Task n Get control (preempted by scheduler) Loose control Scheduler Get control skipped Task2 Release control (release control by Task … itself) (waiting for event) 06.05.2013 Introducing a robust multitasking OS Michael Fritscher 7
Architecture: Scheduler Incoming signal Task1 Task n (preempted by scheduler) Loose control Scheduler Task2 Task … Get control (release control by (waiting for event itself) which fired) 06.05.2013 Introducing a robust multitasking OS Michael Fritscher 8
Architecture: Memory • Stack Checksum Checksum Checksum Canary Canary Canary Stack 1 Stack 2 Stack n … • Heap Canary Canary Object 1 Obj. n Bitmap empty 3 … … End 1 End 06.05.2013 Introducing a robust multitasking OS Michael Fritscher 9
Architecture: IPC Inter Process Communication IPC management list List 1 List 2 List … List n „double linked lists “ Number Size Signal IPC message list Msg 1 Msg 2 Msg … Msg n 06.05.2013 Introducing a robust multitasking OS Michael Fritscher 10
Architecture: Frameworks Sensors, Actuators, Streams, I2C Sensors Actuators Streams I2C Task Task Task Task Framework Framework Framework Framework Filter Driver Device driver Filter Driver FIFO I2C driver Driver Hardware Hardware Hardware Hardware 06.05.2013 Introducing a robust multitasking OS Michael Fritscher 11
Architecture Communications task • Connection to the outside world • Normal task • Uses the IPC system • Connection orientated (with keep alives) • Every packet is acked • CRC-16 • No escaping of the payload 06.05.2013 Introducing a robust multitasking OS Michael Fritscher 12
Function tests Overview • Integrity tests: During the normal operation – Helps a lot against programmer’s mistakes • Initialization tests: During booting – Tests almost every component very thoroughly (almost no time issue here) – Helps a lot against regressions or undesired side effects of alterations • System tests: Manually triggered – Performance & usably tests 06.05.2013 Introducing a robust multitasking OS Michael Fritscher 13
Function tests: Integrity • During the normal operation • Crucial components: Scheduler, Memory, IRQ-Handlers • “Test as much as possible and feasible regarding performance” • Helps a lot against programmer's failures – Invalid parameters – Invalid memory access (despite of having only a simple MMU!) – Abuse of system functions Reactions : Useful error messages, restart to regain a safe state or halt 06.05.2013 Introducing a robust multitasking OS Michael Fritscher 14
Function tests: during initialization • During booting • Very thoroughly test of all components of the system – Heap/Stack – Queues – Scheduler – also with a set of test tasks • Detection of hardware failures, regressions and undesired side effects of alterations • Duration: 3 seconds 06.05.2013 Introducing a robust multitasking OS Michael Fritscher 15
Function tests: The whole system Overview • Synthetic tests – Test the interaction between the components – Complex test tasks, which interact with each other (directly or timely) – Only the board and optionally an oscilloscope required • Realistic Test – Use-case which could occur in normal use – Tests the suitability of the API and the system – Chosen scenario: • Learn and retrace a way path with obstacle avoidance • Control with ultrasonic sensors 06.05.2013 Introducing a robust multitasking OS Michael Fritscher 16
Benchmarks Real time characteristics (delays of incoming signals): Results • • Two tasks Large set of tasks Distribution Distribution Delay in milliseconds Delay in milliseconds Without 06.05.2013 Introducing a robust multitasking OS Michael Fritscher 17
Benchmarks Results ff. • • Impact of the integrity tests Stability over longer runtime • Calc packets per second Calc packets per second • Without any Time in s • • IPC: 90k-172k messages per second Context switches: 40-800µs (depends on the amount of integrity tests) 06.05.2013 Introducing a robust multitasking OS Michael Fritscher 18
Benchmarks Summery • No crashes or bad behavior • Delays: Exactly as estimated, no spikes, even with complex scenarios • Performance: Without the integrity tests near the maximum (IRQ-Handlers etc. need to be into consideration) • Very fair to the tasks • No complex and bug-provoking search of parameters for the scheduler • Context switches are fairly fast (~ 3k cycles) 06.05.2013 Introducing a robust multitasking OS Michael Fritscher 19
Tests of the whole system Realistic test • Task: Learn and retrace a way path with obstacle avoidance – control with ultrasonic sensors • Method: save the relative timestamps Taught Retraced Retraced, with obstacles and the commandos • Tests: – Duration of the implementation 2 days! – Stability / reliability – Accurateness (measured using iSpace from Nikon) 06.05.2013 Introducing a robust multitasking OS Michael Fritscher 20
Conclusion • A Operating System was designed and implemented, with following reached goals: – Robustness – Multitasking – Real time facility – Easy usage – can be used by students as well as scientific officers • Also frameworks and drivers for several devices • Lots of tests which prove both the performance and the suitability => Creation of a sustainable basis for many applications in the field of robotics 06.05.2013 Introducing a robust multitasking OS Michael Fritscher 21
Outlook • Adaption to several other robots – like the Scooter (Fit4Age) • Several drivers – including more tests for external components • Implementing more schedule algorithms • Adaption to ROS (Robot Operating System) • Multi microcontroller systems 06.05.2013 Introducing a robust multitasking OS Michael Fritscher 22
Thanks for your attention! 06.05.2013 Introducing a robust multitasking OS Michael Fritscher 23
Recommend
More recommend