Real-Time & Embedded Operating Systems. VO Embedded Systems Engineering Benedikt Huber WS 2010/11

Similar documents
Real-time Operating Systems. VO Embedded Systems Engineering Armin Wasicek

Embedded Systems. 6. Real-Time Operating Systems

Hard Real-Time Linux

Performance Comparison of RTOS

Embedded & Real-time Operating Systems

REAL TIME OPERATING SYSTEMS. Lesson-10:

Predictable response times in event-driven real-time systems

Real-Time Operating Systems.

Linux 2.4. Linux. Windows

What is an RTOS? Introduction to Real-Time Operating Systems. So what is an RTOS?(contd)

RTAI. Antonio Barbalace (modified by M.Moro 2011) RTAI

Module 8. Industrial Embedded and Communication Systems. Version 2 EE IIT, Kharagpur 1

Enhancing the Monitoring of Real-Time Performance in Linux

POSIX. RTOSes Part I. POSIX Versions. POSIX Versions (2)

Lecture 3 Theoretical Foundations of RTOS

White Paper. Real-time Capabilities for Linux SGI REACT Real-Time for Linux

SYSTEM ecos Embedded Configurable Operating System

Real-Time Systems Prof. Dr. Rajib Mall Department of Computer Science and Engineering Indian Institute of Technology, Kharagpur

Thomas Fahrig Senior Developer Hypervisor Team. Hypervisor Architecture Terminology Goals Basics Details

Chapter 19: Real-Time Systems. Overview of Real-Time Systems. Objectives. System Characteristics. Features of Real-Time Systems

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

Chapter 2: OS Overview

Improvement of Scheduling Granularity for Deadline Scheduler

Linux A multi-purpose executive support for civil avionics applications?

COS 318: Operating Systems. Virtual Machine Monitors

What is best for embedded development? Do most embedded projects still need an RTOS?

Quality of Service su Linux: Passato Presente e Futuro

Operatin g Systems: Internals and Design Principle s. Chapter 10 Multiprocessor and Real-Time Scheduling Seventh Edition By William Stallings

CPU SCHEDULING (CONT D) NESTED SCHEDULING FUNCTIONS

Deeply Embedded Real-Time Hypervisors for the Automotive Domain Dr. Gary Morgan, ETAS/ESC

PikeOS: Multi-Core RTOS for IMA. Dr. Sergey Tverdyshev SYSGO AG , Moscow

Real-Time Operating Systems With Example PICOS18. What is an Operating System?

Real Time Operating Systems. Tajana Simunic Rosing Department of Computer Science and Engineering University of California, San Diego.

Operating Systems Concepts: Chapter 7: Scheduling Strategies

Tasks Schedule Analysis in RTAI/Linux-GPL

Real Time Programming: Concepts

Thread-based analysis of embedded applications with real-time and non real-time processing on a single-processor platform

Programming real-time systems with C/C++ and POSIX

Lecture Outline Overview of real-time scheduling algorithms Outline relative strengths, weaknesses

Modular Real-Time Linux

Real-time KVM from the ground up

COS 318: Operating Systems. Virtual Machine Monitors

Full and Para Virtualization

Embedded & Real-time Operating Systems Communication Libraries

A Survey of Fitting Device-Driver Implementations into Real-Time Theoretical Schedulability Analysis

Exercises : Real-time Scheduling analysis

sel4: from Security to Safety Gernot Heiser, Anna Lyons NICTA and UNSW Australia

Real- Time Scheduling

A hypervisor approach with real-time support to the MIPS M5150 processor

Hypervisors. Introduction. Introduction. Introduction. Introduction. Introduction. Credits:

Partition Scheduling in APEX Runtime Environment for Embedded Avionics Software

Trends in Embedded Software Engineering

Overview of the Linux Scheduler Framework

Operating System Aspects. Real-Time Systems. Resource Management Tasks

Real-Time Software. Basic Scheduling and Response-Time Analysis. René Rydhof Hansen. 21. september 2010

Experience with the integration of distribution middleware into partitioned systems

From Control Loops to Software

Chapter 3 Operating-System Structures

Linux Process Scheduling Policy

Real-Time Scheduling 1 / 39

Design and Implementation of the Heterogeneous Multikernel Operating System

Chapter 13 Embedded Operating Systems

Microkernels, virtualization, exokernels. Tutorial 1 CSC469

The Real-Time Operating System ucos-ii

CPU Scheduling. CPU Scheduling

System Software Integration: An Expansive View. Overview

CS 377: Operating Systems. Outline. A review of what you ve learned, and how it applies to a real operating system. Lecture 25 - Linux Case Study

Design and Implementation of a POSIX Compliant Sporadic Server for the Linux Kernel

System Software and TinyAUTOSAR

Weighted Total Mark. Weighted Exam Mark

Resource Containers: A new facility for resource management in server systems

Control period can have high frequency (short control frame) ex: 0.1kHz - 1kHz in robot controllers

Virtual Machine Monitors. Dr. Marc E. Fiuczynski Research Scholar Princeton University

Operating System Organization. Purpose of an OS

Kernel Types System Calls. Operating Systems. Autumn 2013 CS4023

the high-performance embedded kernel User Guide Version 5.0 Express Logic, Inc Toll Free 888.THREADX FAX

x86 ISA Modifications to support Virtual Machines

How do Users and Processes interact with the Operating System? Services for Processes. OS Structure with Services. Services for the OS Itself

LynxOS RTOS (Real-Time Operating System)

How to design and implement firmware for embedded systems

Introduction to Operating Systems. Perspective of the Computer. System Software. Indiana University Chen Yu

Asymmetric Scheduling and Load Balancing for Real-Time on Linux SMP

CPU Scheduling. Basic Concepts. Basic Concepts (2) Basic Concepts Scheduling Criteria Scheduling Algorithms Batch systems Interactive systems

Comparison between scheduling algorithms in RTLinux and VxWorks

Last Class: OS and Computer Architecture. Last Class: OS and Computer Architecture

Example of Standard API

Deciding which process to run. (Deciding which thread to run) Deciding how long the chosen process can run

Operating Systems 4 th Class

Operating Systems. Lecture 03. February 11, 2013

Real-time processing the basis for PC Control

Virtualization in the ARMv7 Architecture Lecture for the Embedded Systems Course CSD, University of Crete (May 20, 2014)

Aperiodic Task Scheduling

Application of Android OS as Real-time Control Platform**

Last Class: OS and Computer Architecture. Last Class: OS and Computer Architecture

Virtual Machines. COMP 3361: Operating Systems I Winter

Software Tracing of Embedded Linux Systems using LTTng and Tracealyzer. Dr. Johan Kraft, Percepio AB

Objectives. Chapter 2: Operating-System Structures. Operating System Services (Cont.) Operating System Services. Operating System Services (Cont.

Transcription:

Real-Time & Embedded Operating Systems VO Embedded Systems Engineering Benedikt Huber WS 2010/11

Overview Real-Time Systems (Review) OS and RTOS RTOS Classification Linux as RTOS Programming Considerations Summary ESE: Real Time Opera0ng Systems 2

Computer system classification Transformational systems compute output values from input values, then stop. numerical computations, compiler Interactive systems constantly interact with their environment. The system delivers a service to the user. operating systems, databases Reactive systems continuously react to stimuli from the environment. Reaction time is dictated by the environment. signal processors, process controllers ESE: Real Time Opera0ng Systems 3

Real-Time Systems In a real 0me computer system the correctness of the system behavior depends not only on the logical results of the computa0ons, but also on the physical instant at which these results are produced. Hard Real-Time deadline miss can have catastrophic results Soft Real-Time result has utility after the deadline U5lity U5lity 1,00 0,50 1,00 0,50 t t ESE: Real Time Opera0ng Systems 4

Schedulability Analysis In a hard real 0me system, we need to a high confidence that no deadline will be missed during opera0on Offline Scheduling Timing analysis is much easier without preemption Offline Scheduling Static Priority Scheduling (e.g., RMS) Dynamic Priority Scheduling (e.g., EDF) For both: Need to know timing characteristics of runtime system (OS) and WCET of all tasks ESE: Real Time Opera0ng Systems 5

Determinism & Predictability A system behaves determinis0c if the same sequence of input always produces the same sequence of output Key difference between reactive and interactive systems Compare e.g. a process controller and a compiler Predictability Is our (timing) model a precise characterisation of the system? Can we predict e.g. context switch delay, execution times? Temporal behavior of many non-rt systems in unpredictable ESE: Real Time Opera0ng Systems 6

Embedded Software market grows Compare the Average Annual Growth Rate (AAGR) of the market for embedded software (16%) with the estimated growth rates of GDP (about 2%) shows the crucial relevance of the Embedded Systems. A strong increase in the value of Embedded Systems is expected Examples are telecommunications, logistics, automation, or automotive. Further softwareization is predicted: estimated AAGR 2004-2009 16% for embedded software, 14.2% for embedded hardware (integrated circuits, IC), and 10% for embedded boards Increased number of lines of code per functionality (in aircraft systems from 10 to 105 between 1970 and 2007) ESE: Real Time Opera0ng Systems 7

Market data for 2004 on tools and services Characteris5cs Market (2004) Embedded OSs, bundled tools, related services SW development tools, related services Design automa0on tools, related services Test automa0on tools, related services Market volume in million Market growth Largest consuming region and its share 712.6 20.9% Americas 52.7% 195.1 1.8% Americas 48.2% 275.6 n.a. Americas n.a. 65.7 19.8% Americas 50.8% Largest consuming sector and its share Consumer Electronics 41.7% n.a. Military / Aerospace, n.a. Military / Aerospace, 27.6% 1,249.0 17.0% (weighted average) ESE: Real Time Opera0ng Systems 8

OS and RTOS ESE: Real Time Opera0ng Systems 9

Operating Systems Operating System (OS): abstracts from hardware provides access to I/O, memory management, sharing of the resources of the computer provides system calls to access low level functions Input devic es S ys tem c alls Us er A pplic ation H ardware Output devic es S ig nals O perating s ys tem R eg is ters Interrupts Embedded system is a hardware/soeware ar5fact. ESE: Real Time Opera0ng Systems 10

Common OS Services Task management Scheduling and Timers Memory Management Memory Protection and Error Handling Hardware Abstraction and I/O interface Inter Process Communication Synchronization (mutual exclusion) Message passing Shared Memory ESE: Real Time Opera0ng Systems 11

Real-Time Operating Systems (RTOS) Real-Time (RT) requirements for OS + features for timing constraints guaranteed max. execution time of system calls guaranteed OS response time to external events guaranteed max. execution time of OS functions (ISRs, drivers, context switches,...) Determinism and Predictability Efficiency Fast context switch Minimize intervals during which the interrupts are disabled ESE: Real Time Opera0ng Systems 12

Scheduling created dead ready running Scheduling Decision: Which task in ready state can execute? Scheduler uses a scheduling strategy fixed priorities, dynamic priorities, round-robin (timeslicing), rate monotonic, cooperative How does scheduler get CPU? called by application system timer interrupt blocked ESE: Real Time Opera0ng Systems 13

Mutual Exclusion Realized using e.g. semaphores Increases response times For Real-Time Scheduling, protocol to avoid priority inversion due to locking is needed Attempt to lock Unlocked, Preempt T3 T 1 T 2 T 3 Preempted by T2 ESE: Real Time Opera0ng Systems 14

Is Scheduler Necessary? No, you can meet deadlines without any RTOS (generate offline schedule, implement it): inefficient (regularly poll infrequent events, reserve max. time for interrupts) long schedule cycle time (least common multiple of all task periods) or unnecessary overhead (shorten task periods) hard to change and maintain (use tools!) ESE: Real Time Opera0ng Systems 15

RTOS taxonomy and architecture ESE: Real Time Opera0ng Systems 16

RTOS taxonomy and architecture (1) Small, fast, proprietary kernels Highly specialized to specific applications Real-Time extensions to commercial operating systems (RT-Linux, RT-Posix, RT-MACH, RT-WinNT) Compliant kernels Existing OS is modified such that non-rtos binaries run without modification Dual kernels Thin RT-kernel stay below the native OS Core kernel modification Changes are made in the core of OS The resource kernel approach Kernel is extended to provide support for resource reservation ESE: Real Time Opera0ng Systems 17

RTOS taxonomy and architecture (2) Component based kernels OS components can be selectively included to compose an RTOS Selection depends on the target and application Construction of OS through composition ecos PURE - embedded applications MMLite - dynamic reconfiguration of components ESE: Real Time Opera0ng Systems 18

RTOS taxonomy and architecture (3) QoS based kernels Used for soft real-time systems Research kernels Developed at university research projects to study research aspects of RTOS Examples: MARS (time triggered, distributed), SPRING (admission control, reservation), HARTOS (distributed communication) ESE: Real Time Opera0ng Systems 19

Partioning RTOS Hard real-time / mixed criticality systems Spatial Isolation: Memory protection Temporal Isolation: Hierarchical Scheduling (Pike OS) Static scheduling of partitions Dynamic scheduling of tasks within partition Background partition ESE: Real Time Opera0ng Systems 20

Microkernels Kernel restricted to necessary minimum Improves maintainability, predictability, security Hypervisor - Mikrokernel Isolates hard real-time tasks Example: OKL4 Used in e.g. Mobile Phones for the Android Platform IPC, Resource Allocation, but not scheduling, I/O Virtual Environment for other paravirtualized RTOSs ESE: Real Time Opera0ng Systems 21

Designing an RTOS application ESE: Real Time Opera0ng Systems 22

Design Decisions How many tasks? Poll events or use interrupts? If interrupt, handle event in ISR or in a task? ESE: Real Time Opera0ng Systems 23

Number of Tasks Few tasks: small OS overhead (not much scheduling) not much inter-task communication easy to understand complete system Many tasks: good and consequent functional partitioning modularization easy to maintain/change modules high parallelism ESE: Real Time Opera0ng Systems 24

Programming Considerations Keep program short Keep memory usage down Be careful not to overwrite system memory (buffer overflow) Consider power consumption use CPU as seldom as possible (no busy wait, no idle loop!) on a distributed system, try to minimize consumption (but take care not to completely drain one node...) ESE: Real Time Opera0ng Systems 25

Event Handling: Polling vs. Interrupts Polling: easier to understand regular, hence easier to estimate worst case times under the control of the scheduler Interrupt: only called when event occurs always called as soon as possible good performance in average case (resp. ESE: Real Time Opera0ng Systems 26 interrupt rate)

Event Handling: in ISR or in Task? In ISR: + fastest possible reaction long ISR not all system calls allowed in ISR (e.g., I/O access) In Task: + considers execution time needs of other tasks handling time harder to compute ESE: Real Time Opera0ng Systems 27

Selecting an OS Supported processors? Memory requirements (OS + appl <= Target memory; don't forget RAM requirements) Features (scheduling strategies, IPC mechanisms,...) Execution time (if real-time requirements) Support! (hotline, documentation, sources?,...) Check newsgroups & magazines for reports ESE: Real Time Opera0ng Systems 28

Advantages of having a RTOS RTOS provide an abstraction (process model) Structuring in tasks improves Modularity Maintainability Reusability Facilitates temporal and spatial partitioning of application Enables power management strategies Reduces effort for certification ESE: Real Time Opera0ng Systems 29

Linux as RTOS ESE: Real Time Opera0ng Systems 30

Linux as real-time operating system (1) Predictability of real-time task execution Pre-2.6 scheduling algorithm was O(n), so it could delay a even a high priority task s start time. (Since 2.6 O(1) scheduler introduced: time to schedule is both fixed and deterministic regardless of the number of active tasks) Kernel cannot always be preempted. Sometimes it requires exclusive access to resources and internal data structures in order to maintain their consistency Interrupts from hardware may delay a task ESE: Real Time Opera0ng Systems 31

Linux as real-time operating system (2) Virtual memory management introduces indeterministic delays (jitter). Real-Time applications may not use the virtual memory Clock granularity of 1ms insufficient for most real-time apps (e.g., a typical control loop task executes with 100 Hz = every 10ms) ESE: Real Time Opera0ng Systems 32

RT-POSIX Real-Time Extensions to Portable Operating System Interface (POSIX) Real-Time Scheduling: SCHED_FIFO, SCHED_RR Virtual Memory Locking High-Precision Timers Real-Time Threads (Globally or Locally Scheduled) Mutexes with Protocols avoiding Priority Inversion Profiles to support small embedded devices ESE: Real Time Opera0ng Systems 33

The Real-Time Preemption Patch Makes Linux better suited to real-time systems Real-Time Scheduling In the RTPreempt, RT-Posix fixed priority scheduling. There is also an EDF patch for Linux. Critical sections in kernel are preemptable They now use real-time mutexes, including a priority inheritance protocol Interrupt handlers are interruptable kernel threads High-precision timer support Not suitable for safety-critical hard real-time [SCHED_DEADLINE, http://www.evidence.eu.com/content/view/313/390/] ESE: Real Time Opera0ng Systems 34

Linux as real-time operating system (3) Solutions to run hard-real time tasks and Linux: Real Time Linux (RTLinux) Real-Time Application Interface (RTAI) Xenomai ESE: Real Time Opera0ng Systems 35

RTLinux & RTAI Dual-kernel approach, two schedulers are in operation Supports hard real-time (deterministic) operation through interrupt control between the hardware and the operating system. (Adeos Event Pipeline) Linux runs as its lowest-priority process Real-time applications specifically written for the non- Linux kernel using an associated real-time API Can exchange data with Linux applications (LXRT) ESE: Real Time Opera0ng Systems 36

RTLinux & RTAI Tasks are executed inside kernel memory space, which prevents threads to be swapped-out and also the number of TLB misses is reduced. Threads are executed in processor supervisor mode (i.e. ring level 0 in i386 arch), have full access to the underlying hardware. Since the RTOS and the application are linked together in a "single" execution space, system call mechanism is implemented by means of a simple function call (default is software interrupt which produces higher overhead). ESE: Real Time Opera0ng Systems 37

Xenomai RTAI spin-off, designed for extensibility portability maintainability Task can switch transparently Primary mode (hard RT) Secondary mode (soft RT) Skins can emulate RTOS APIs ESE: Real Time Opera0ng Systems 38

ENDE Danke für die Aufmerksamkeit!