Virtual AUTOSAR Environment on Linux
Total Page:16
File Type:pdf, Size:1020Kb
Virtual AUTOSAR Environment on Linux Evaluation study on performance gains from running ECU applications on POSIX threads Master’s thesis in Embedded Electronic System Design ATHANASIOS KOLTSIDAS OSCAR PETERSON Department of Computer Science and Engineering CHALMERS UNIVERSITY OF TECHNOLOGY UNIVERSITY OF GOTHENBURG Gothenburg, Sweden 2016 Virtual AUTOSAR Environment on Linux Evaluation study on performance gains from running ECU applications on POSIX threads ATHANASIOS KOLTSIDAS, OSCAR PETERSON © ATHANASIOS KOLTSIDAS, OSCAR PETERSON, 2016. Technical Supervisor: Mårten Hildell, ARCCORE AB Academic Supervisor: Sven Knutsson, Computer Science and Engineering Examiner: Per Larsson-Edefors, Computer Science and Engineering Master’s Thesis 2016 Department of Computer Science and Engineering Chalmers University of Technology and University of Gothenburg SE-412 96 Gothenburg Telephone +46 31 772 1000 Cover picture: Graphical representation of the sensor networks employed within an autonomous driven Volvo XC90. Copyright: Volvo Cars © Gothenburg, Sweden 2016 ii Abstract Testing an AUTOSAR application destined for an automotive Electronic Control Unit (ECU) can become an unpredictable situation, since the hardware availabil- ity of the target platform can be limited, if at all available. This thesis set out to provide developers with a virtual testing platform that would emulate the hardware behaviour in the shape of a Linux C-based application. The study was extended towards evaluating potential performance gains from running the developed appli- cation on high-end computers with similar performance levels as current powerful ECU hardware, which are able to host a UNIX-based operating system and execute multiple threads in parallel using the POSIX standard. The assessment of the gen- erated results is realised in terms of correctness of a predefined execution scenario, performance comparison to a set of reference results and standard real-time timing constraints for automotive software. Keywords: Linux, Adaptive AUTOSAR, POSIX, Operating Systems, Embedded Systems, Real-Time Systems. v Acknowledgements First and foremost, we would like to thank Johan Ekberg of ARCCORE AB for trusting us with this fascinating project work and providing us with all the neces- sary means to achieve our goals. Our deepest gratitude is due to our other technical supervisor in ARCCORE AB, Mårten Hilldel, without whose knowledge and day- to-day help this project would have not been successful. Special thanks also go to Simon Gaynor for his prior work and assistance on technical issues that troubled us during the course of our thesis. Our days in ARCCORE AB would be much less enjoyable without the support of all the employees of the company, who embraced us as their own and transformed the offices into a dream-place to work. We would also like to thank our academic supervisor Sven Knutsson, for his valuable comments on our project documentation. Furthermore, our true-hearted apprecia- tion goes to our examiner, Per Larsson-Edefors, for his critical feedback during the project and the motivation to produce work of high standards. Last but not least, we thank our families and friends, for their patience, their love and uninterrupted support throughout our studies. Athanasios Koltsidas, Oscar Peterson, Gothenburg, June 2016 vii Nomenclature AP I . Application Program Interface AUT OSAR . Automotive Open System Architecture BSP . Board Support Package BSW M . Basic Software Module CDD . Complex Device Drivers CPU . Central Processing Unit CSE . Computer Science and Engineering E/E . Electrical / Electronic ECU . Electronic Control Unit EEC . .Electronic Engine Control FCFS . First Come First Serve GP U . Graphical Processing Unit GUI . Graphical User Interface Hz ........................................................................Hertz I/O . Input-Output IDE . .Integrated Development Environment IEEE . .Institute of Electrical and Electronics Engineers MCAL . .Microcontroller Abstraction Layer MCU . .Microcontroller Unit OS . Operating System OSEK . Open Systems and their Interfaces for Electronics in Motor Vehicles PC . Personal Computer P OSIX . Portable Operating System Interface RR . Round-Robin RT . Real-Time RT E . .Runtime Environment RUP . Rational Unified Process SJF . Shortest Job First T BD . To Be Determined UI . User Interface UML . Unified Model Language UNIX . Uniplexed Information and Computing Service VM . .Virtual Machine s ........................................................................seconds ix x Table of Contents Nomenclature ix List of Figures xv List of Tables xvii 1 Introduction1 1.1 Background................................1 1.2 Problem Definition............................2 1.3 Motivation.................................4 1.4 Project Goal................................6 1.5 Scope Limitations.............................6 2 Theory9 2.1 Operating Systems............................9 2.1.1 Processes and Threads...................... 10 2.1.2 POSIX............................... 12 2.1.2.1 Thread Management with POSIX Standard..... 12 2.1.2.2 Pthreads and Synchronisation............. 14 2.1.3 Process Interaction........................ 14 2.1.3.1 Race Conditions and Critical Regions......... 15 2.1.3.2 Busy Waiting in Mutual Exclusion.......... 17 2.1.3.3 Sleep and Wakeup Approaches............ 18 2.1.4 Scheduling............................. 22 2.1.4.1 Process Behaviour and Scheduling Points...... 22 2.1.4.2 Scheduling Goals.................... 23 2.1.4.3 Popular Scheduling Policies.............. 24 2.2 Embedded Systems............................ 27 2.2.1 Definition............................. 27 2.2.2 Historical Motivation....................... 28 2.2.3 Real-Time Systems........................ 29 2.2.4 Real-Time Scheduling...................... 30 2.2.5 Embedded Operating Systems.................. 31 2.3 UNIX OS................................. 31 2.3.1 History of UNIX......................... 31 2.3.2 Fundamental UNIX Features................... 32 2.3.3 UNIX Structure.......................... 32 xi Table of Contents 2.4 AUTOSAR Specifications........................ 34 2.4.1 Software Architecture....................... 34 2.4.2 Adaptive AUTOSAR....................... 36 2.5 OSEK Specifications........................... 37 2.5.1 Architecture............................ 38 2.5.2 Task Management........................ 38 2.5.3 Events and alarms........................ 38 2.5.3.1 Resource management................. 40 2.6 Yocto Project............................... 41 2.6.1 Background............................ 41 2.6.2 Poky................................ 41 2.6.2.1 Bitbake......................... 41 2.6.2.2 Metadata........................ 42 3 Methods 45 3.1 Rational Unified Process......................... 45 3.1.1 Effective Practices........................ 45 3.1.2 Process Overview......................... 46 3.1.3 Static Structure of the Process.................. 47 3.1.4 Iterations............................. 48 3.2 Development Tools and Code Versioning................ 48 3.2.1 Modelling and Visualisation Tools................ 48 3.2.2 Integrated Development Environments............. 49 3.2.2.1 Makefile System and Arctic Core........... 49 3.2.3 Code Versioning and Data Analysis............... 50 3.2.4 Documentation.......................... 50 3.3 Implementation Architecture....................... 51 3.3.1 System Level........................... 51 3.3.2 Application Level......................... 53 3.4 Development Process........................... 55 3.4.1 Test Strategy........................... 55 3.4.2 Implementation Iteration 1.................... 55 3.4.2.1 Requirements...................... 56 3.4.2.2 Development Steps................... 56 3.4.2.3 Testing Phase...................... 57 3.4.3 Implementation Iteration 2.................... 57 3.4.3.1 Requirements...................... 58 3.4.3.2 Development Steps................... 58 3.4.3.3 Testing Phase...................... 59 3.4.4 Implementation Iteration 3.................... 59 3.4.4.1 Requirements...................... 59 3.4.4.2 Development Steps................... 60 3.4.4.3 Testing Phase...................... 60 3.4.5 Implementation iteration 4.................... 61 3.4.5.1 Requirements...................... 61 3.4.5.2 Development Steps................... 61 xii Table of Contents 3.4.5.3 Testing Phase...................... 62 4 Results 63 4.1 Performance Results........................... 63 4.2 Correctness and Timing Results..................... 70 5 Discussion 73 5.1 Results Discussion............................ 73 6 Conclusion 79 References 81 A Reference Performance ResultsI B CoreMark Benchmark Results III C Performance Results under LoadV C.1 Iteration 3.................................V C.2 Iteration 4................................. XIX D MinnowBoard MAX Performance Results XXXIII E Pthread Test Source Code XXXVII xiii Table of Contents xiv List of Figures 1.1 Virtual Machine..............................3 1.2 Standard AUTOSAR software architecture...............4 2.1 Simple OS Architecture.......................... 10 2.2 Visual representation of processes and threads............. 12 2.3 Functionality of pthread_join functionality.............. 14 2.4 Critical regions.............................. 17 2.5 Critical region with mutexes....................... 19 2.6 Example of how a deadlock can occur.................. 20 2.7 Non-Preemptive Scheduling....................... 23 2.8 Preemptive Scheduling.......................... 24 2.9