AUTOBEST: A United AUTOSAR-OS And ARINC 653 Kernel. Alexander Züpke, Marc Bommert, Daniel Lohmann

Similar documents
AUTOBEST: A microkernel-based system (not only) for automotive applications. Marc Bommert, Alexander Züpke, Robert Kaiser.

Deterministic Futexes Revisited

Green Hills Software, Inc.

Real-Time Systems Hermann Härtig Real-Time Operating Systems Brief Overview

Process Scheduling Queues

Real-Time Systems. Real-Time Operating Systems

Multiprocessor and Real- Time Scheduling. Chapter 10

Implementing Scheduling Algorithms. Real-Time and Embedded Systems (M) Lecture 9

Tasks. Task Implementation and management

RT extensions/applications of general-purpose OSs

Real-Time Component Software. slide credits: H. Kopetz, P. Puschner

Commercial Real-time Operating Systems An Introduction. Swaminathan Sivasubramanian Dependable Computing & Networking Laboratory

Multicore for safety-critical embedded systems: challenges andmarch opportunities 15, / 28

Embedded Systems: OS. Jin-Soo Kim Computer Systems Laboratory Sungkyunkwan University

ID 025C: An Introduction to the OSEK Operating System

Embedded Systems: OS

System Architecture Directions for Networked Sensors[1]

Implementing a High-Integrity Executive using Ravenscar

REAL TIME OPERATING SYSTEM PROGRAMMING-I: VxWorks

Motivation. Threads. Multithreaded Server Architecture. Thread of execution. Chapter 4

AC OB S. Multi-threaded FW framework (OS) for embedded ARM systems Torsten Jaekel, June 2014

REAL-TIME OPERATING SYSTEMS SHORT OVERVIEW

Embedded Software Programming

IT 540 Operating Systems ECE519 Advanced Operating Systems

Embedded Systems. 6. Real-Time Operating Systems

Real-Time Programming

Embedded Systems. 5. Operating Systems. Lothar Thiele. Computer Engineering and Networks Laboratory

Overview. Thread Packages. Threads The Thread Model (1) The Thread Model (2) The Thread Model (3) Thread Usage (1)

RTA-OSEK Texas Instruments TMS570 with the TI Compiler

A Predictable RTOS. Mantis Cheng Department of Computer Science University of Victoria

2. Introduction to Software for Embedded Systems

Outline Background Jaluna-1 Presentation Jaluna-2 Presentation Overview Use Cases Architecture Features Copyright Jaluna SA. All rights reserved

Zilog Real-Time Kernel

Sleepy Sloth: Threads as Interrupts as Threads

Operating Systems (2INC0) 2018/19. Introduction (01) Dr. Tanir Ozcelebi. Courtesy of Prof. Dr. Johan Lukkien. System Architecture and Networking Group

Reference Model and Scheduling Policies for Real-Time Systems

ZiLOG Real-Time Kernel Version 1.2.0

Chapter 19: Real-Time Systems. Operating System Concepts 8 th Edition,

Implementing Task Schedulers (1) Real-Time and Embedded Systems (M) Lecture 10

Processes and Non-Preemptive Scheduling. Otto J. Anshus

Protected mode RTOS: what does it mean?

CS370 Operating Systems

A Component Model and Software Architecture for CPS

MICROKERNEL CONSTRUCTION 2014

DSP/BIOS Kernel Scalable, Real-Time Kernel TM. for TMS320 DSPs. Product Bulletin

Dan Noé University of New Hampshire / VeloBit

FreeRTOS. A Brief Overview. Christopher Kenna. October 1, Avionics. FreeRTOS 1 / 34

Native POSIX Thread Library (NPTL) CSE 506 Don Porter

RTA-OSEK. fåñáåéçå=qêá`çêé=ñ~ãáäó=ïáíü=íüé=q~ëâáåö=`çãéáäéê. cé~íìêéë=~í=~=dä~ååé. oq^jlpbh. `çãéáäéêl^ëëéãääéêliáåâéê.

10 th AUTOSAR Open Conference

Model Based Development of Embedded Control Software

Outline. Process and Thread Management. Data Structures (2) Data Structures. Kernel Process Block (PCB)

Hardware OS & OS- Application interface

Process and Thread Management

QUESTION BANK UNIT I

MULTI SLOTH: An Efficient Multi-Core RTOS using Hardware-Based Scheduling

Performance and Optimization Issues in Multicore Computing

Operating Systems Overview. Chapter 2

CSE 410 Final Exam 6/09/09. Suppose we have a memory and a direct-mapped cache with the following characteristics.

What s An OS? Cyclic Executive. Interrupts. Advantages Simple implementation Low overhead Very predictable

Process Description and Control. Chapter 3

Concurrency: Deadlock and Starvation

Achieving Predictable Multicore Execution of Automotive Applications Using the LET Paradigm

Operating System. Operating System Overview. Structure of a Computer System. Structure of a Computer System. Structure of a Computer System

C09: Process Synchronization

RTA-OSEK Texas Instruments TMS470R1x with the TI Compiler

Processes and Threads

Operating System Design Issues. I/O Management

Process Description and Control. Chapter 3

CS370 Operating Systems

OPERATING SYSTEM CONCEPTS UNDERSTAND!!! IMPLEMENT!!! ANALYZE!!!

Introduction to Embedded Systems

Efficiency and memory footprint of Xilkernel for the Microblaze soft processor

Announcements. Reading. Project #1 due in 1 week at 5:00 pm Scheduling Chapter 6 (6 th ed) or Chapter 5 (8 th ed) CMSC 412 S14 (lect 5)

OPERATING SYSTEMS CS3502 Spring Processor Scheduling. Chapter 5

Department of Computer Science Institute for System Architecture, Operating Systems Group REAL-TIME MICHAEL ROITZSCH OVERVIEW

SMD149 - Operating Systems

Driving the standard for optimized embedded systems

CS 326: Operating Systems. CPU Scheduling. Lecture 6

Ausgewählte Betriebssysteme - Mark Russinovich & David Solomon (used with permission of authors)

Today s Topics. u Thread implementation. l Non-preemptive versus preemptive threads. l Kernel vs. user threads

CS533 Concepts of Operating Systems. Jonathan Walpole

(MCQZ-CS604 Operating Systems)

OSEK/VDX. Communication. Version January 29, 2003

A New Real-time Kernel development on an embedded platform

CS 471 Operating Systems. Yue Cheng. George Mason University Fall 2017

Yielding, General Switching. November Winter Term 2008/2009 Gerd Liefländer Universität Karlsruhe (TH), System Architecture Group

Multiprocessor and Real-Time Scheduling. Chapter 10

Mid Term from Feb-2005 to Nov 2012 CS604- Operating System

CS A320 Operating Systems for Engineers

Distributed Systems Operation System Support

Xen and the Art of Virtualization. CSE-291 (Cloud Computing) Fall 2016

Following are a few basic questions that cover the essentials of OS:

Virtual Memory COMPSCI 386

The Global Control-Flow Graph

Operating Systems. Operating System Structure. Lecture 2 Michael O Boyle

Virtualización. Apolinar González Alfons Crespo

Faculty of Computer Science, Operating Systems Group. The L4Re Microkernel. Adam Lackorzynski. July 2017

Embedded Systems Programming

Preemptive Scheduling

Transcription:

AUTOBEST: A United AUTOSAR-OS And ARINC 653 Kernel Alexander Züpke, Marc Bommert, Daniel Lohmann alexander.zuepke@hs-rm.de, marc.bommert@hs-rm.de, lohmann@cs.fau.de

Motivation Automotive and Avionic industry begin to face similar challenges: Hyper integration: increasing HW & SW complexity Energy consumption Certification effort Cost pressure Security issues But both industries use different OS standards! Can't we challenge this with a single, unified operating system? Combine avionics safety with the resource-efficiency of automotive systems? And (probably) make it faster than existing systems? 2

Motivation Automotive and Avionic industry begin to face similar challenges: Hyper integration: increasing HW & SW complexity Energy consumption Certification effort Cost pressure Security issues But both industries use different OS standards! Can't we challenge this with a single, unified operating system? Combine avionics safety with the resource-efficiency of automotive systems? And (probably) make it faster than existing systems? 3

Outline AUTOSAR and ARINC 653 Short introduction Task models Partitioning concepts Challenges AUTOBEST Architecture Lazy priority switching Static Futexes Conclusions & Outlook 4

AUTOSAR Source: http://www.autosar.org 5

AUTOSAR OS Concepts: Tasks ISRs Event driven Fixed-priority scheduling Statically configured at compile time Isolation: group tasks into OS-Applications Here: focus on AUTOSAR-OS, the OS kernel Source: http://www.autosar.org 6

ARINC 653 ARINC 653 Standard: Part 1 - Required Services APPLICATION SOFTWARE Application Software of Partition 1 LOGICAL COMMUNICATIONS APEX Application Software of Partition 2 ARINC 653 O/S APEX System Partition(s) EXCEPTION HANDLING CONFIGURATION DATA Part 2 - Extended Services Part 3 - Conformity Part 4 - Subset Services INTEGRATED MODULE CORE MODULE CORE SOFTWARE PARTITIONING MEMORY MANAGEMENT PHYSICAL COMMUNICATIONS DEVICE HANDLERS SCHEDULER CONTEXT SWITCHING HARDWARE INTERFACE SOFTWARE INTERRUPT HANDLING HEALTH MONITOR BIT COMMUNICATIONS MEDIA MMU CLOCK INTERRUPT CONTROLLER CORE HARDWARE BITE Time driven and event driven Fixed-priority task scheduling, TDMA partition scheduling Task synchronization and partition communication means Source: ARINC 653 specification 7

ARINC 653 ARINC 653 Standard: Part 1 - Required Services APPLICATION SOFTWARE Application Software of Partition 1 LOGICAL COMMUNICATIONS APEX Application Software of Partition 2 ARINC 653 O/S APEX System Partition(s) EXCEPTION HANDLING CONFIGURATION DATA Part 2 - Extended Services Part 3 - Conformity Part 4 - Subset Services INTEGRATED MODULE CORE MODULE CORE SOFTWARE PARTITIONING MEMORY MANAGEMENT PHYSICAL COMMUNICATIONS DEVICE HANDLERS SCHEDULER CONTEXT SWITCHING HARDWARE INTERFACE SOFTWARE INTERRUPT HANDLING HEALTH MONITOR BIT OS Concepts: Robust partitioning in space and time Processes (=Tasks) as executing entities Time driven and event driven COMMUNICATIONS MEDIA Fixed-priority task scheduling, TDMA partition scheduling Task synchronization and partition communication means MMU CLOCK INTERRUPT CONTROLLER CORE HARDWARE BITE Source: ARINC 653 specification 8

Task Model AUTOSAR AUTOSAR 4 task states TERMINATED Preemptive scheduling Waiting: activate per-task event bitmask A task terminates when its job is complete READY release WAITING ARINC 653 preempt terminate Additional transitions dispatch wait Waiting: RUNNING Single-bit events Semaphores Buffers and blackboards Queuing and sampling ports 9

Task Model AUTOSAR and ARINC ARINC only READY STOP() dispatch activate SUSPEND() preempt TERMINATED terminate RUNNING STOP() RESUME() release DELAYED START() wait SUSPEND SELF() WAITING SUSPEND() AUTOSAR 4 task states Preemptive scheduling Waiting: per-task event bitmask A task terminates when its job is complete ARINC 653 Additional transitions Waiting: Single-bit events Semaphores Buffers and blackboards Queuing and sampling ports 10

Separation & Isolation AUTOSAR OS-Applications Task OS-Application ISR Task OS-Application Task Optional concept Memory protection Configurable access to objects in other Applications Task Task... AUTOSAR OS Kernel Task User mode Supervisor mode ARINC 653 Partition Partition Partitions Proc Proc Proc Mandatory concept Complete isolation Sema Proc... Event Proc Explicit inter-partition communication means ARINC 653 Kernel User mode Supervisor mode 11

Separation & Isolation AUTOSAR OS-Applications Task OS-Application ISR Task OS-Application Task Optional concept Memory protection Configurable access to objects in other Applications Task Task... AUTOSAR OS Kernel Task User mode Supervisor mode ARINC 653 Partition Partition Partitions Proc Proc Proc Mandatory concept Complete isolation Sema Proc... Event Proc Explicit inter-partition communication means ARINC 653 Kernel User mode Supervisor mode 12

Time Partitioning AUTOSAR repeating Schedule Tables Schedule Table Duration Offset activate tasks set event Expiry Point Delay Time AUTOSAR Schedule Tables allow similar time-triggered task activation For temporal separation, optional timing protection facilities are available Activation ARINC 653 Time Partitioning Major Time Frame Partition 1 Part. 2 Part. 3 Partition 1 Partition 4 Idle Duration Partition 1 Time Time partitioning separates partitions and drives time-triggered tasks 13

Time-Triggered AUTOSAR repeating Schedule Tables Schedule Table Duration Offset activate tasks set event Expiry Point Delay Time AUTOSAR Schedule Tables allow similar time-triggered task activation For temporal separation, optional timing protection facilities are available Activation ARINC 653 Time Partitioning Major Time Frame Partition 1 Part. 2 Part. 3 Partition 1 Partition 4 Idle Duration Partition 1 Time Time partitioning separates partitions and drives time-triggered tasks 14

Differences AUTOSAR Construction kit Task classes Scalability classes Isolation is an add-on Goals: reduce resource usage keep it simple 15

Differences AUTOSAR Construction kit Task classes Scalability classes Isolation is an add-on Goals: reduce resource usage keep it simple ARINC 653 General purpose API No configuration options Certification Decoupling of partitions Goals: fault mitigation safety first 16

Challenges Support both AUTOSAR and ARINC 653 APIs Full ARINC 653 partitioning at minimal resource costs Performance comparable to other AUTOSAR implementations Keep system easy to (re-)certify 17

AUTOBEST 18

AUTOBEST Architecture Statically configured microkernel Partitions Space partitioning Time partitioning Driven by ARINC 653 Tasks Superset of AUTOSAR & ARINC 653 task API Keep OS specific differences out of the kernel Task Task AUTOSAR Partition AUTOBEST Kernel ARINC 653 Partition User space libraries provide full AUTOSAR or ARINC 653 API Task AUTOSAR Library ISR... Task sync object Task ARINC 653 Library User mode Supervisor mode 19

AUTOBEST Architecture Scheduling Two-level scheduler Time-Partition Scheduling One ready queue per time partition Multiple space partitions can share one time partition Task Scheduling Priority Scheduling with FIFO order on tie Fast critical sections using priority ceiling protocols Futex wait queues 20

AUTOBEST Architecture Special Requirements of AUTOSAR Counters, Alarms, and Schedule Tables difficult to implement in user space Interrupt Handling Allow ISRs in both kernel and user space ISR cat 1 kernel domain (no interaction with OS) ISR cat 2a kernel domain ISR cat 2b partition domain Partitioned ISRs are mapped to high priority tasks DisableInterrupts() raise priority to partition maximum hooks (high priority pseudo tasks) for error handling 21

AUTOBEST Architecture Special Requirements of ARINC 653 Futex wait queues for ARINC sync objects 64-bit Nanosecond Timeout API Health Monitoring Strict error handling using HM tables Error process is mapped to a hook (like for AUTOSAR) Partitioning API Start & Shutdown of other partitions Privileged system calls Task deadline monitoring 22

AUTOBEST Architecture Component Architecture Generic code Architecture code Board code AUTOSAR Application AUTOSAR Library ARINC 653 Application ARINC 653 Library Configuration Configuration user mode supervisor mode Boot, Interrupt Handling,... Kernel device drivers Configuration data OS specific libraries Architecture Layer Kernel Component Configuration Board Component Processor Kernel and partition code kept in dedicated binary images System Configuration XML config C language data structs (no C code, no #ifdefs) Binary reuse possible + reduces testing efforts 23

AUTOBEST Architecture Resource Efficiency: RAM is precious! Split data model: keep config in flash keep data in RAM Most expensive: task data (64 bytes) register contexts kernel stacks Task Data Queues use doubly-linked lists: - either ready queue or timeout queue - sync object's wait queue - deadline monitoring queue Time tracking in 64-bit nanoseconds: - timeout expiry time - phase shift of task activation - deadline timeout House keeping: - task state, priorities, - pending events and task activations - etc 24 bytes 24 bytes 16 bytes ready queue per time partition (2 KiB / 256 priority levels) 24

AUTOBEST Architecture Resource Efficiency: And flash as well! Example Configuration: 5 resource partitions, 1 time partition 29 tasks, 10 hooks, 1 ISR 4 schedule tables, 2 alarms Kernel memory usage on TMS570: 13.5 KiB code (ARM thumb code, gcc -O2) 7.5 KiB config 17 KiB data (8 KiB stacks, 3.5 KiB registers, 2 KiB ready queues) 25

Lazy Priority Switching 26

Lazy Priority Switching Typical critical section priority (using the AUTOSAR priority ceiling protocol) raise lower time critical section 27

Lazy Priority Switching Typical critical section priority (using the AUTOSAR priority ceiling protocol) raise lower critical section time If critical sections are short and frequent, the overhead to change the caller's scheduling priority dominates runtime costs! 28

Lazy Priority Switching Change scheduling priority: System call overhead Raising priority: check & update some values Lowering priority: same + check for rescheduling Idea for Optimization: Get rid of system call to set some values Kernel and user share variables to set priority Move rescheduling check into user space (checked when leaving a critical section) 29

Lazy Priority Switching Change scheduling priority: System call overhead Raising priority: check & update some values Lowering priority: same + check for rescheduling Idea for Optimization: Get rid of system call to set some values Kernel and user share variables to set priority Move rescheduling check into user space (checked when leaving a critical section) 30

Lazy Priority Switching Optimized critical section: One system call in the worst case (preemption) priority Update variable raise lower critical section Update var, check resched do system call to preempt time Frequently used pattern, esp. in OS libraries! Best case / no preemption: MPC5646C: 688 31 TMS570: 843 94 (CPU cycles) 31

Futex Wait Queues 32

Futex Wait Queues All ARINC 653 synchronization objects behave similar: Some tasks wait for something to happen Other tasks wake one or all waiters Each sync object has a wait queue Queue discipline: FIFO or priority-sorted (configured at partition start) Optional timeout Provide an API for wait queue operations 33

Futex Wait Queues Example: Queuing port communication Shared memory for message buffers in queuing port channel One atomic Futex variable encodes read and write positions Two cross-connected wait queues receiver side wakes one after message was consumed wake one partition A B wait sender side waits if message queue is full shared memory: atomic variable N msg buffers receiver side waits if message queue is empty wait wake one sender side wakes one after message was sent 34

Futex Wait Queues The kernel needs to manage wait queues only: Abstract wait and wake operations like in Linux Futexes Wait and wake sides can reside in different partitions All ARINC 653 synchronization objects can be built upon Futexes and wait queues Bonus: all copy operations done in user space (copy messages in user space at highest priority) 35

Conclusion 36

Conclusion Conclusion Possible: unified kernel for AUTOSAR and ARINC Lazy priority switching improves performance Futex wait queues for ARINC 653 synchronization means keep complexity out of the kernel Lessons learned Statically tailored kernels: good choice for safetycritical systems (much simpler than using runtime configuration) AUTOSAR nowadays provides similar functionality as ARINC 653 37

Outlook Status Single core: PPC (e200) and ARM (Cortex R4) AUTOSAR OS 4.1 rev 3 ARINC 653 part 1 suppl 3 Pthread subset as additional OS environment Future work Multi core: Infineon AURIX Real-world benchmarks Interrupts do not fit well to a time partitioned world Problem: Lock step not available for all cores 38

Thank you for your attention! 39

Backup Slides 40

POSIX Subset of POSIX PSE5.1 Pthread API Pthreads Mutexes Condition Variables Minimal C-library Dynamic memory allocation Scheduling SCHED_FIFO supported SCHED_RR not supported No Signal Handling No Thread Cancellation No additional efforts in the kernel! 41

Performance Performance (Nov 2014) Freescale MPC5646C Bolero @120 MHz Syscall 87 cycles / 0.73 µs OSEK resource fast 29 cycles / 0.24 µs OSEK resource slow 300 cycles / 2.50 µs Task switch 390 cycles / 3.25 µs Texas Instruments TMS570LS3137 @180 MHz Syscall 151 cycles / 0.83 µs OSEK resource fast 70 cycles / 0.38 µs OSEK resource slow 431 cycles / 2.39 µs Partition switch overhead 659 cycles / 3.66 µs 42

AUTOBEST Architecture Considered alternative: Hypervisor design Microkernel Kernel knows all OS tasks Kernel schedules tasks and partitions API: OSEK + Partitioning API Hypervisor HV knows only partitions HV schedules partitions, delegates task scheduling to partition API: Virtual CPU + virtual interrupt controller programming interface ISRs: - Cat 2 ISRs partitioned - Cat 1 ISRs global ISRs: similar Cat 2 ISRs are scheduled like tasks How to inject interrupts with priority? 43

The End 44