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

Similar documents
Real-Time Systems. Real-Time Operating Systems

REAL-TIME OPERATING SYSTEMS SHORT OVERVIEW

Real-Time Operating Systems

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

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

Embedded Systems. 6. Real-Time Operating Systems

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

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

EECS 571 Principles of Real-Time Embedded Systems. Lecture Note #10: More on Scheduling and Introduction of Real-Time OS

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

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

NuttX Realtime Programming

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

OVERVIEW. Last Week: But if frequency of high priority task increases temporarily, system may encounter overload: Today: Slide 1. Slide 3.

Operating system concepts. Task scheduling

RT extensions/applications of general-purpose OSs

* There are more than 100 hundred commercial RTOS with memory footprints from few hundred kilobytes to large multiprocessor systems

Systemy RT i embedded Wykład 11 Systemy RTOS

Real-Time Operating Systems (Working Draft) What is an Operating System (OS)?

Reference Model and Scheduling Policies for Real-Time Systems

REAL-TIME OVERVIEW SO FAR MICHAEL ROITZSCH. talked about in-kernel building blocks:

Real-time Support in Operating Systems

CEC 450 Real-Time Systems

Lesson 5: Software for embedding in System- Part 2

Resource Access Control (2) Real-Time and Embedded Systems (M) Lecture 14

Real-Time & Embedded Operating Systems

Interrupts and Time. Real-Time Systems, Lecture 5. Martina Maggio 28 January Lund University, Department of Automatic Control

Model Based Development of Embedded Control Software

TDDD07 Real-time Systems Lecture 10: Wrapping up & Real-time operating systems

Scheduling. Scheduling 1/51

Priority-driven Scheduling of Periodic Tasks (2) Advanced Operating Systems (M) Lecture 5

CS A331 Programming Language Concepts

Multimedia Systems 2011/2012

The Real Time Thing. What the hack is real time and what to do with it. 22C3 30. December Erwin Erkinger e.at

REAL TIME OPERATING SYSTEM PROGRAMMING-I: VxWorks

Green Hills Software, Inc.

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

Interrupts and Time. Interrupts. Content. Real-Time Systems, Lecture 5. External Communication. Interrupts. Interrupts


10 th AUTOSAR Open Conference

Chapter 3 Process Description and Control

LINUX AND REALTIME 1

Multiprocessor and Real-Time Scheduling. Chapter 10

Chapter 5: CPU Scheduling. Operating System Concepts 9 th Edit9on

Real-time in embedded Linux systems

Scheduling. Scheduling 1/51

Comparison of scheduling in RTLinux and QNX. Andreas Lindqvist, Tommy Persson,

INF1060: Introduction to Operating Systems and Data Communication. Pål Halvorsen. Wednesday, September 29, 2010

Introduction to Embedded Systems

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

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

Subject Name: OPERATING SYSTEMS. Subject Code: 10EC65. Prepared By: Kala H S and Remya R. Department: ECE. Date:

6/17/2011. Real-time Operating Systems

LAST LECTURE ROUND-ROBIN 1 PRIORITIES. Performance of round-robin scheduling: Scheduling Algorithms: Slide 3. Slide 1. quantum=1:

CSE 4/521 Introduction to Operating Systems. Lecture 29 Windows 7 (History, Design Principles, System Components, Programmer Interface) Summer 2018

Microkernel/OS and Real-Time Scheduling

Copyright Notice. COMP9242 Advanced Operating Systems S2/2014 Week 9: Real-Time Systems. Real-Time System: Definition

Embedded Systems: OS

Processes. Overview. Processes. Process Creation. Process Creation fork() Processes. CPU scheduling. Pål Halvorsen 21/9-2005

Asynchronous Events on Linux

The Real-time Specification for Java

Micrium µc/os II RTOS Introduction EE J. E. Lumpp

Common Computer-System and OS Structures

Processes and Non-Preemptive Scheduling. Otto J. Anshus

Embedded Systems Dr. Santanu Chaudhury Department of Electrical Engineering Indian Institution of Technology, IIT Delhi

CPU Scheduling (Part II)

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

Windows 7 Overview. Windows 7. Objectives. The History of Windows. CS140M Fall Lake 1

Enriching Enea OSE for Better Predictability Support

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

NPRG051 Advanced C++ Programming 2016/17 Assignment 2

Operating System Architecture. CS3026 Operating Systems Lecture 03

THREADS ADMINISTRIVIA RECAP ALTERNATIVE 2 EXERCISES PAPER READING MICHAEL ROITZSCH 2

ZiLOG Real-Time Kernel Version 1.2.0

CEC 450 Real-Time Systems

Lecture 2 Process Management

Timers 1 / 46. Jiffies. Potent and Evil Magic

POSIX in Real-Time. By Kevin M. Obenland 03/15/2001. Daniel Correia nºmec Carlos Guisado nºmec 49099

CSE 237A Middleware and Operating Systems. Tajana Simunic Rosing Department of Computer Science and Engineering University of California, San Diego.

PROCESS SCHEDULING II. CS124 Operating Systems Fall , Lecture 13

Real Time Operating System Support for Concurrency

ELEC 377 Operating Systems. Week 1 Class 2

The POSIX AIO interface consists of the following functions: Enqueue a write request. This is the asynchronous analog of write(2).

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

Lecture 2: September 9

Introduction History RTCore PREEMPT RT Demo Usage References. Real-Time Linux. Christopher Schuster

DEPARTMENT OF COMPUTER SCIENCE AND ENGINEERING UNIT-1

IT 540 Operating Systems ECE519 Advanced Operating Systems

Operating Systems 2010/2011

Real-Time Operating Systems Design and Implementation. LS 12, TU Dortmund

OS Design Approaches. Roadmap. OS Design Approaches. Tevfik Koşar. Operating System Design and Implementation

SMD149 - Operating Systems

OPERATING SYSTEMS CS3502 Spring Processor Scheduling. Chapter 5

Zilog Real-Time Kernel

2008 Chapter-8 L1: "Embedded Systems - Architecture, Programming and Design", Raj Kamal, Publs.: McGraw-Hill, Inc.

OS? Based on. Embedded Systems: A Contemporary Design Tool James Peckol. and EE472 Lecture Notes Pack Blake Hannaford, James Peckol, Shwetak Patel

Comparison of soft real-time CPU scheduling in Linux kernel 2.6 series with Solaris 10

EECS 3221 Operating System Fundamentals

CS A320 Operating Systems for Engineers

EECS 3221 Operating System Fundamentals

Transcription:

Real-Time Systems Hermann Härtig Real-Time Operating Systems Brief Overview 02/02/12

Outline Introduction Basic variants of RTOSes Real-Time paradigms Common requirements for all RTOSes High level resources Non-Real-Time on RTOS Scheduling Memory management Examples POSIX and Real-Time Michael Roitzsch WS 2011/12 Real-Time Systems, Real-Time Operating Systems / Hermann Härtig 2

Basic variants of RTOSes (simplest) Cyclic executive Only one task as infinite loop Time driven, polling for external events Set of interrupt handlers Event driven Handlers usually have priorities Stacked execution, remember stack-based priority ceiling protocol WS 2011/12 Real-Time Systems, Real-Time Operating Systems / Hermann Härtig 3

Basic variants of RTOSes (II) Thread packages (irmx, FreeRTOS, ecos,... ) Use a form of scheduling Preemptive or cooperative Priorities Provide synchronization primitives (e.g., semaphores) Some with priority inheritance/ceiling No address-space protection, no virtual memory WS 2011/12 Real-Time Systems, Real-Time Operating Systems / Hermann Härtig 4

Basic variants of RTOSes (III) Microkernels (QNX, VxWorks, L4/Fiasco...) Memory protection (address spaces) With or without virtual memory More robustness (fault isolation) Extensive functionality provided by services atop WS 2011/12 Real-Time Systems, Real-Time Operating Systems / Hermann Härtig 5

Basic variants of RTOSes (IV) Monolithic RTOS (LynxOS, MontaVista Linux..., preemption-patch Linux) Monolithic kernel with RT API (POSIX RT...) Often non-real-time APIs as well (e.g., Linux compatibility) Device drivers etc. usually run in privileged mode Real-time applications usually run in user mode Monolithic with RT executive underneath (RTLinux, RTAI, XtratuM...) Combination of a legacy OS with some form of an RT thread package (usually no memory protection) Real-time applications run in kernel mode WS 2011/12 Real-Time Systems, Real-Time Operating Systems / Hermann Härtig 6

Basic variants of RTOSes (V) Partitioned system (time driven) All resources are statically allocated to the partitions (CPU, Memory, Devices...) Space and time isolation Multiple threads/processes in a partition Scheduling: Partitions: time driven (see slide 7) Threads/processes: any local scheduling scheme possible Arinc 653-1 standard for avionics WS 2011/12 Real-Time Systems, Real-Time Operating Systems / Hermann Härtig 7

Common requirement for RT Time as First Class Citizen Periodic processes or absolute timeouts Interface: clock_gettime, clock_getres High clock resolution necessary Special CPU event counters Non-periodic timers (dynamic ticks in Linux) Time synchronization WS 2011/12 Real-Time Systems, Real-Time Operating Systems / Hermann Härtig 8

High level resources RT is often reduced to CPU scheduling and latencies. There are more resources to give guarantees about: Disk, Video, Network... Operating systems addressing these are Linux/RK (resource kernel) DROPS... WS 2011/12 Real-Time Systems, Real-Time Operating Systems / Hermann Härtig 9

Non-Real-Time on RTOS Non-RT API on RT kernel: Unix emulation on QNX Linux emulation on LynxOS Run Non-RT OS on RT kernel: Xtratum, Radisys (Windows-NT), RT-MACH, L4Linux on DROPS WS 2011/12 Real-Time Systems, Real-Time Operating Systems / Hermann Härtig 10

Scheduling in Real-Time OSes Priorities Priority inversion and countermeasures Time budgets Interrupt / event latencies WS 2011/12 Real-Time Systems, Real-Time Operating Systems / Hermann Härtig 11

Real-Time scheduling (I) Fixed priorities Sufficient priority levels (e.g., RMS 256 prios [1]) Events/messages with priorities Higher priority events arrive first On some systems priority is donated to the receiver Signals are queued (predictability) WS 2011/12 Real-Time Systems, Real-Time Operating Systems / Hermann Härtig 12

Real-Time scheduling (II) Dynamic priorities Application based: set_priority(p) Good for mode changes Not suitable for EDF OS driven EDF scheduling WS 2011/12 Real-Time Systems, Real-Time Operating Systems / Hermann Härtig 13

Scheduling avoid priority inversion Priority ceiling Set priority of lock Critical sections as parameter for process creation Priority inheritance Borrowing of CPU time (priority) Non-preemptive critical sections WS 2011/12 Real-Time Systems, Real-Time Operating Systems / Hermann Härtig 14

Scheduling budgets What if processes abuse their priorities? Overload situations? Periodic threads and time quanta Scheduling Assign budgets per period to threads: thread -> (period, priority, budget) Control overuse of budgets Periodic threads as first class object (fiasco) Watchdog timers to signal budget overruns WS 2011/12 Real-Time Systems, Real-Time Operating Systems / Hermann Härtig 15

Interrupt latencies One key property of RTOSes: Predictable and low interrupt latency Interrupt latency reduction: No interrupt blocking for synchronization (preemptivity) Short interrupt service routines ( top halves ) Schedule more complex interrupt handling in a thread like fashion Partition data and instruction caches... WS 2011/12 Real-Time Systems, Real-Time Operating Systems / Hermann Härtig 16

Real-Time and memory management Avoid demand paging/swaping (disk access is orders of magnitude slower than main memory) However: Address space isolation useful for robustness/debugging Some scenarios need paging Interface mlock(...) lock pages in memory (prevent swaping) munlock(...) allow demand paging again WS 2011/12 Real-Time Systems, Real-Time Operating Systems / Hermann Härtig 17

Real-Time and memory management Static memory allocation Always good for real time Inflexible Dynamic memory management Use real-time capable memory allocator (e.g., [3] TLSF) WS 2011/12 Real-Time Systems, Real-Time Operating Systems / Hermann Härtig 18

POSIX and Real-Time POSIX (Portable OS Interface): IEEE 1003.1 REALTIME extensions semaphores process memory locking priority scheduling realtime signal extension clocks/timers interprocess communication synchronized I/O asynchronous I/O WS 2011/12 Real-Time Systems, Real-Time Operating Systems / Hermann Härtig 19

POSIX: memory locking Memory ranges can be locked (excluded from swaping) Provide latency guarantees for memory accesses WS 2011/12 Real-Time Systems, Real-Time Operating Systems / Hermann Härtig 20

POSIX: Real-Time Scheduling Multiple scheduling policies SCHED_FIFO (non-preemptive FIFO) SCHED_RR (preemptive/time-sliced FIFO) SCHED_SPORADIC (2 prio levels, replenishment interval, and budget, FIFO on active priority level) SCHED_OTHER (threads without RT policy) At least 32 RT priorities WS 2011/12 Real-Time Systems, Real-Time Operating Systems / Hermann Härtig 21

POSIX: Real-Time Signals Difference to non-realtime signals: Queued (also for the same signal number) Carry user data Ordered delivery Specific properties RT signals are in the range SIGRTMIN to SIGRTMAX Handler gets siginfo_t with additional data Lowest pending signal (number) is delivered first WS 2011/12 Real-Time Systems, Real-Time Operating Systems / Hermann Härtig 22

Long I/O operations Use asynchronous I/O Example: POSIX (IEEE Std 1003.1) Initiate I/O aio_read(struct aiocb *aiocbp) aio_write(struct aiocb *aiocbp) POSIX signals for completion aio_suspend(...) to wait for completion WS 2011/12 Real-Time Systems, Real-Time Operating Systems / Hermann Härtig 23

Long I/O operations (II) struct aiocbp { Int aio_filedes; /* file descriptor */ off_t aio_offset; /* absolute file offset */ Void *aio_buf; /* pointer to memory buffer */ size_t aio_nbytes; /* number of bytes to I/O */ Int aio_reqprio; /* prio of request */ struct sigevent aio_sigevent; /* signal */ Int aio_lio_opcode; /* opcode for lio_listio */ }; WS 2011/12 Real-Time Systems, Real-Time Operating Systems / Hermann Härtig 24

POSIX: Real-Time timers/clocks (I) Clocks Min. resolution of 20ms (clock_getres()) Multiple clocks CLOCK_REALTIME (wall clock time) CLOCK_MONOTONIC (system-wide monotonic clock) CLOCK_PROCESS_CPUTIME_ID CLOCK_THREAD_CPUTIME_ID WS 2011/12 Real-Time Systems, Real-Time Operating Systems / Hermann Härtig 25

POSIX: Real-Time timers/clocks (II) Timers Associated to a specific clock (see Clocks) Per process timers (generate RT signals) Periodic timers supported (struct timespec) WS 2011/12 Real-Time Systems, Real-Time Operating Systems / Hermann Härtig 26

POSIX: execution time monitoring Clocks measuring thread/process execution time CLOCK_PROCESS_CPUTIME_ID CLOCK_THREAD_CPUTIME_ID Timers connected to these clocks Signal deadline misses WS 2011/12 Real-Time Systems, Real-Time Operating Systems / Hermann Härtig 27

ARINC 653-1 standard for avionics Statically partitioned system (time-driven scheduling) 1 2 3 t n t n+1 t n+2 time Execution in one partition must not influence execution in another partition (strict isolation) Strictly time-driven scheduling of partitions No transfer of idle CPU time among partitions Additionally defines System health monitoring Intra/inter-partition communication Time management WS 2011/12 Real-Time Systems, Real-Time Operating Systems / Hermann Härtig 28

Real-Time paradigms (I) Time driven Static partitioning in time slots Scheduler dispatches time slots in a fixed fashion (e.g., fixed cyclic scheduler) Event driven Events: messages, signals, interrupts... Priorities WS 2011/12 Real-Time Systems, Real-Time Operating Systems / Hermann Härtig 29