Real Time Operating Systems and Middleware

Similar documents
Reservation-Based Scheduling for IRQ Threads

Integrating Multimedia Applications in Hard Real-Time Systems

IN4343 Real-Time Systems

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

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

Inferring Temporal Behaviours Through Kernel Tracing

Real-Time Operating Systems M. 9. Real-Time: Basic Concepts

Learning Outcomes. Scheduling. Is scheduling important? What is Scheduling? Application Behaviour. Is scheduling important?

Introduction to Real-time Systems. Advanced Operating Systems (M) Lecture 2

CS4514 Real-Time Systems and Modeling

Constant Bandwidth vs Proportional Share Resource Allocation

Real-time Support in Operating Systems

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

Multimedia-Systems. Operating Systems. Prof. Dr.-Ing. Ralf Steinmetz Prof. Dr. rer. nat. Max Mühlhäuser Prof. Dr.-Ing. Wolfgang Effelsberg

3. Quality of Service

Simplified design flow for embedded systems

4/6/2011. Informally, scheduling is. Informally, scheduling is. More precisely, Periodic and Aperiodic. Periodic Task. Periodic Task (Contd.

Real-Time Systems 1. Basic Concepts

Reference Model and Scheduling Policies for Real-Time Systems

Real-Time Scheduling. Dynamic Priority Servers

A Capacity Sharing and Stealing Strategy for Open Real-time Systems

Faculty of Computer Science Institute of Systems Architecture, Operating Systems Group. vs. REAL-TIME SYSTEMS MICHAEL ROITZSCH

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

arxiv: v1 [cs.os] 7 Dec 2015

CEC 450 Real-Time Systems

6.1 Motivation. Fixed Priorities. 6.2 Context Switch. Real-time is about predictability, i.e. guarantees. Real-Time Systems

Event-Driven Scheduling. (closely following Jane Liu s Book)

Developing Real-Time Applications

Concurrent activities in daily life. Real world exposed programs. Scheduling of programs. Tasks in engine system. Engine system

Real-Time Architectures 2004/2005

Introduction to Real-Time Communications. Real-Time and Embedded Systems (M) Lecture 15

Introduction to Embedded Systems

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

Multimedia Systems 2011/2012

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

Serving Non Real-Time Tasks in a Reservation Environment

Constructing and Verifying Cyber Physical Systems

Ensuring Schedulability of Spacecraft Flight Software

Syllabus Instructors:

Real-time Systems. 9 September Dr. Sergio Ruocco ERTOS Researcher. Copyright 2004 National ICT Australia Limited

Achieving Predictable Multicore Execution of Automotive Applications Using the LET Paradigm

OPERATING SYSTEMS CS3502 Spring Processor Scheduling. Chapter 5

Scheduling of Parallel Real-time DAG Tasks on Multiprocessor Systems

Overview. Sporadic tasks. Recall. Aperiodic tasks. Real-time Systems D0003E 2/26/2009. Loosening D = T. Aperiodic tasks. Response-time analysis

Communication Problems. Flow Control

Overall Structure of RT Systems

15: OS Scheduling and Buffering

Operating Systems and Networks

Global Scheduling in Multiprocessor Real-Time Systems

Partitioned Fixed-Priority Scheduling of Parallel Tasks Without Preemptions

Reservation-Based Scheduling for IRQ Threads

Multiprocessor and Real- Time Scheduling. Chapter 10

Chapter -5 QUALITY OF SERVICE (QOS) PLATFORM DESIGN FOR REAL TIME MULTIMEDIA APPLICATIONS

Lecture 3. Introduction to Real-Time kernels. Real-Time Systems

MaRTE-OS: Minimal Real-Time Operating System for Embedded Applications

Real Time Operating Systems and Middleware

CEC 450 Real-Time Systems

Multiprocessor and Real-Time Scheduling. Chapter 10

Embedded Software Programming

Predictable Interrupt Management and Scheduling in the Composite Component-based System

7. Multimedia Operating System. Contents. 7.3 Resource Management. 7.4 Process Management. 7.2 Real Time Systems. 7.5 Prototype Systems. 7.

Adaptive Scheduling Parameters Manager for SCHED DEADLINE

ECE519 Advanced Operating Systems

Time Triggered and Event Triggered; Off-line Scheduling

Exam Review TexPoint fonts used in EMF.

CISC 7310X. C05: CPU Scheduling. Hui Chen Department of Computer & Information Science CUNY Brooklyn College. 3/1/2018 CUNY Brooklyn College

TrueTime: Simulation of Control Loops Under Shared Computer Resources

What are Embedded Systems? Lecture 1 Introduction to Embedded Systems & Software

CS370: System Architecture & Software [Fall 2014] Dept. Of Computer Science, Colorado State University

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

Processes and Threads

SE300 SWE Practices. Lecture 10 Introduction to Event- Driven Architectures. Tuesday, March 17, Sam Siewert

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

Concurrent programming: Introduction I

Communication in Distributed Systems

Microkernel/OS and Real-Time Scheduling

Enriching Enea OSE for Better Predictability Support

Multicore CPU Reclaiming: Parallel or Sequential?

PROCESS SCHEDULING Operating Systems Design Euiseong Seo

requests or displaying activities, hence they usually have soft deadlines, or no deadlines at all. Aperiodic tasks with hard deadlines are called spor

SCHED DEADLINE: a real-time CPU scheduler for Linux

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

2. REAL-TIME CONTROL SYSTEM AND REAL-TIME NETWORKS

Scheduling Mar. 19, 2018

Giancarlo Vasta, Magneti Marelli, Lucia Lo Bello, University of Catania,

DISTRIBUTED REAL-TIME SYSTEMS

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

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

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

Low-Latency Audio on Linux by Means of Real-Time Scheduling

Analyzing Real-Time Systems

ARTIST-Relevant Research from Linköping

Real-Time Technology in Linux

Respecting temporal constraints in virtualised services

CS370 Operating Systems

NAME: KEY (FIRST NAME FIRST) TOTAL:

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

Dynamic Voltage Scaling of Periodic and Aperiodic Tasks in Priority-Driven Systems Λ

Real-time HOOD. Analysis and Design of Embedded Systems and OO* Object-oriented Programming Jan Bendtsen Automation and Control

Sporadic Server Scheduling in Linux Theory vs. Practice. Mark Stanovich Theodore Baker Andy Wang

Transcription:

Real Time Operating Systems and Middleware Introduction to Real-Time Systems Luca Abeni abeni@disi.unitn.it Credits: Luigi Palopoli, Giuseppe Lipari, Marco Di Natale, and Giorgio Buttazzo Scuola Superiore Sant Anna Pisa -Italy Real Time Operating Systems and Middleware p. 1

Some Information Slides available from http://www.disi.unitn.it/~abeni/rtos Interested students can have a look at: Giorgio Buttazzo, HARD REAL-TIME COMPUTING SYSTEMS: Predictable Scheduling Algorithms and Applications, Second Edition, Springer, 2005 Exam: Written exam + Optional project You will be asked questions about all the course Prerequisites: Programming skills: C, C++ Some knowledge about Operating Systems Real Time Operating Systems and Middleware p. 2

Prerequisites You must know how to code in C / C++ This is not about knowing the C syntax... It is about writing good C code If you do not feel confident enough with C, have a look at The C Programming Language by Kerrigan and Ritchie Some notes about C programming are available on the course web site About Operating Systems: Sistemi Operativi I, or similar exams References: a good OS book (Stallings, Tanenbaum,...) How to use a shell, the make command, and how to compile and execute programs Real Time Operating Systems and Middleware p. 3

Overview of the Course - 1 Real-Time Systems: what are they? Real-Time Computing, Temporal Constraints Definitions and task model Real-Time scheduling Notes about real-time programming, RT-POSIX, pthreads,... Real-Time Scheduling Fixed Priority scheduling, RM, DM EDF and dynamic priorities Resource Sharing (Priority Inversion, etc...) Real Time Operating Systems and Middleware p. 4

Overview of the Course - 2 Operating System structure Notes about traditional kernel structures Sources of kernel latencies Some approaches to real-time kernels: dual kernel approach interrupt pipes microkernels monolithic kernels and RT Real Time Operating Systems and Middleware p. 5

Real-Time Operating Systems Real-Time operating system (RTOS): OS providing support to Real-Time applications Real-Time application: the correctness depends not only on the output values, but also on the time when such values are produced Operating System: Set of computer programs Interface between applications and hardware Control the execution of application programs Manage the hardware and software resources OS as... A Service Provider for user programs (interface...) A Resource Manager Real Time Operating Systems and Middleware p. 6

perating System as a Resource Manager Process Management Memory Management File Management VFS File System Networking Device Drivers Graphical Interface Resources must be managed so that real-time applications are served properly Real Time Operating Systems and Middleware p. 7

Operating System Services Services (Kernel Space): Process Synchronisation, Inter-Process Communication (IPC) Process / Thread Scheduling I / O Virtual Memory Specialised API? Resource Manager (device drivers...) Interrupt Handling Device Management... OS Structure? Real Time Operating Systems and Middleware p. 8

Typical Applications Air traffic control Flight control systems Robotics Telecommunication systems Nuclear / chemical power plants Multimedia systems Automotive systems by Giorgio Buttazzo p. 9

Real-Time Systems: What??? Real-Time application: the time when a result is produced matters a correct result produced too late is equivalent to a wrong result, or to no result characterised by temporal constraints that have to be respected Example: mobile vehicle with a software module that 1. Detects obstacles 2. Computes a new trajectory to avoid them 3. Computes the commands for engine, brakes,... 4. Sends the commands by Giorgio Buttazzo p. 10

Real-Time Systems: What??? If the commands are correctly computed, but are not sent in time......the vehicle crashes into the obstacle before receiving the commands! Examples of temporal constraints: must react to external events in a predictable time must repeat a given activity at a precise rate must end an activity before a specified time by Giorgio Buttazzo p. 11

More About Temporal Constraints Explicit: included in the specification of the system activities open the valve in 10 seconds read the altimeter every 200ms send the position within 40ms Implicit: do not appear in the system specification, but must be respected to meet the requirements avoid obstacles while running at speed v slide a surface with speed v and force F They can always be modelled using the concept of deadline by Giorgio Buttazzo p. 12

Real-Time & Determinism A Real-Time system is not just a fast system...... Because speed is always relative to a specific environment. Running faster is good, but does not guarantee a correct behaviour It must be possible to prove that temporal constraints are always respected... worst-case analysis In general, fast systems tend to minimise the average response time of a task set...... While a real-time system must guarantee the timing behaviour of RT tasks! by Giorgio Buttazzo p. 13

Processes, Threads, and Tasks Algorithm logical procedure used to solve a problem Program formal description of an algorithm, using a programming language Process instance of a program (program in execution) Thread flow of execution Task process or thread A task can be seen as a sequence of actions...... and a deadline must be associated to each activity! Some kind of formal model is needed to identify activities and associate deadlines to them Real Time Operating Systems p. 14

Mathematical model of a task - 1 Real-Time task τ i : stream of jobs (or instances) J i,k Each job J i,k = (r i,k,c i,k,d i,k ): Arrives at time r i,k (activation time) Executes for a time c i,k Finishes at time f i,k Should finish within an absolute deadline d i,k c i,k r i,k f i,k d i,k Real Time Operating Systems p. 15

Mathematical model of a task - 2 Summing up, a job is an abstraction used to associate deadlines (temporal constraints) to activities r i,k is the time when job J i,k is activated (by an external event, a timer, an explicit activation, etc...) c i,k is the time needed by job J i,k to complete d i,k is the absolute time instant by which job J i,k must complete job J i,k respects its deadline if f i,k d i,k the response time of job J i,k is ρ i,k = f i,k r i,k Real Time Operating Systems p. 16

Periodic Tasks A periodic task τ i = (C i,d i,t i ) is a stream of jobs J i,k, with T i is the task period; r i,k+1 = r i,k +T i d i,k = r i,k +D i C i = max k {c i,k} D i is the task relative deadline; C i is the task worst-case execution time (WCET); R i is the worst-case response time: R i = max k {ρ i,k } = max k {f i,k r i,k }; for the task to be correctly scheduled, it must be R i D i. Real Time Operating Systems p. 17

Periodic Task Model A periodic task has a regular structure (cycle): activate periodically (period T i ) execute a computation suspend waiting for the next period void *PeriodicTask(void *arg) { <initialization>; <start periodic timer, period = T>; while (cond) { <read sensors>; <update outputs>; <update state variables>; <wait next activation>; } } Real Time Operating Systems p. 18

Graphical representation Tasks are graphically represented by using a GANNT chart. For example, the following picture shows a schedule of a periodic task τ 1 = (3,6,8) (with WCET 1 = 3, D 1 = 6, P 1 = 8) τ 1 0 2 4 6 8 10 12 14 16 18 20 22 24 Notice that, while job J 1,1 and J 1,3 execute for 3 units of time (WCET), job J 1,2 executes for only 2 units of time. Real Time Operating Systems p. 19

Aperiodic Tasks Aperiodic tasks are not characterised by periodic arrivals: A minimum interarrival time between activations does not exist Sometimes, aperiodic tasks do not have a particular structure Aperiodic tasks can model: Tasks that respond to events that occur rarely. Example: a mode change. Tasks that respond to events that happen with an irregular structure. Example: bursts of packets arriving from the network. Real Time Operating Systems p. 20

Aperiodic Tasks - Example The following example shows a possible arrival pattern for an aperiodic task τ 1 τ 1 0 2 4 6 8 10 12 14 16 18 20 22 24 Notice that arrivals might be bursty, and there is not a minimum time between them. Real Time Operating Systems p. 21

Sporadic tasks Sporadic tasks are aperiodic tasks characterised by a minimum interarrival time between jobs. In this sense, they are similar to periodic tasks, but... Periodic task activated by a periodic timer Sporadic task activated by an external event (for example, the arrival of a packet from the network) void *SporadicTask(void *) { <initialization>; while (cond) { <computation>; <wait event>; } } Real Time Operating Systems p. 22

Mathematical model of a sporadic task Similar to a periodic task: a sporadic task τ i = (C i,d i,t i ) is a stream of jobs J i,k, with r i,k+1 d i,k C i r i,k +T i = r i,k +D i = max k {c i,k} T i is the task minimum interarrival time (MIT); D i is the task relative deadline; C i is the task worst-case execution time (WCET). Again, for the task to be correctly scheduled it must be R i D i. Real Time Operating Systems p. 23

Graphical representation The following example, shows a possible schedule of a sporadic task τ 1 = (2,5,9). τ 1 0 2 4 6 8 10 12 14 16 18 20 22 24 26 Notice that r 1,2 = 12 > r 1,1 +T 1 = 9 r 1,3 = 21 = r 1,2 +T 1 = 21 Real Time Operating Systems p. 24

Task Criticality - 1 A deadline is said to be hard if a deadline miss causes a critical failure in the system A task is said to be a hard real-time task if all its deadlines are hard All the task s deadlines have to be guaranteed ( j,ρ i,j D i R i D i ) a priori, before starting the task Examples: The controller of a mobile robot, must detect obstacles and react within a time dependent on the robot speed, otherwise the robot will crash into the obstacles. Real Time Operating Systems p. 25

Task Criticality - 2 A deadline is said to be soft if a deadline miss causes a degradation in the Quality of Service, but is not a catastrophic event A task is said to be a soft real-time task if it has soft deadlines Some deadlines can be missed without compromising the correctness of the system...... But the number of missed deadlines must be kept under control, because the quality of the results depend on the number of missed deadlines Real Time Operating Systems p. 26

Soft Real-Time Requirements - 1 Characterising the a soft real-time task can be difficult... What s the tradeoff between non compromising the system correctness and not considering missed deadlines? Some way to express the QoS experienced by a (soft) real-time task is needed The QoS of a soft task can be expressed in different ways. Examples are: no more than X consecutive deadlines can be missed no more than X deadlines in an interval of time T can be missed Real Time Operating Systems p. 27

Soft Real-Time Requirements - 2 Other examples of soft real-time constraints: the deadline miss probability must be less than a specified value P{f i,j > d i,j } R max the deadline miss ratio can be used instead number of missed deadlines total number of deadlines R max the maximum tardiness must be less than a specified value R i D i < L... Real Time Operating Systems p. 28

Example of Soft Real-Time Audio / Video player: fps: 25 frame period: 40ms if a frame is played a little bit too late, the user might even be unable to notice any degradation in the QoS......but skipped frames can be disturbing missing a lot of frames by 5ms can be better than missing only few frames by 40ms! In some robotic systems, some actuations can be delayed with little consequences on the control quality In any case, soft real-time does not mean no guarantee on deadlines... Real Time Operating Systems p. 29

Job Execution Times Tasks can have variable execution times between different jobs Execution times might depend on different factors: Input data Hardware issues (cache effects, pipeline stalls, etc...) The internal state of the task... τ 1 0 2 4 6 8 10 12 14 16 18 20 22 24 26 28 30 32 34 Real Time Operating Systems p. 30

Variable Execution Times: Video Player Distribution of the job execution times for a video player (frame decoding times for an MPEG video) 0.1 0.09 0.08 0.07 probability density 0.06 0.05 0.04 0.03 0.02 0.01 0 0 2000 4000 6000 8000 10000 decoding time (microseconds) Real Time Operating Systems p. 31

Maximum vs Average Load - 1 In a hard real-time system, all the deadlines must be respected This must be guaranteed in advance The worst case has to be considered a necessary condition for respecting all the deadlines is based on maximum execution times Maximum execution times might be too pessimistic for soft real-time systems (causing bad system utilization) But the system must not be overloaded (see stable queues in queueing theory) the average system load must be less than 1 The system must be designed based on average execution times Real Time Operating Systems p. 32

Maximum vs Average Load - 2 Worst possible situation: maximum execution time C i = max i {c i,j } (WCET) Very difficult (almost impossible?) to compute in advance Often estimated by running a sufficient number of jobs Average situation: average execution time c i = N j=1 c i,j Used to compute the average load......in a soft real-time system, the average load must be less than 1 N Real Time Operating Systems p. 33

System Utilization The maximum utilization (load) for a periodic or sporadic task τ i = (C i,t i,t i ) (with D i = T i ) is U i = C i T i The system utilization (load) is defined as U = i U i For periodic or sporadic tasks with T i = D i, U = i C i T i Example: τ 1 = (2,6,6), τ 2 = (2,8,8), τ 3 = (4,12,12) U 1 = 1/3 = 0.3;U 2 = 2/8 = 0.25;U 3 = 0.3 U = 0.916 Real Time Operating Systems p. 34

Maximum Utilization & RT Guarantees U U lub t Real Time Operating Systems p. 35

Average utilization & RT Guarantees If the average utilization is less than U lub, the task set may or may not be schedulable: U U lub U avg t Real Time Operating Systems p. 36

Average utilization & RT Guarantees If the average utilization is greater than U lub, the task set is probably not schedulable: U U avg U lub t Real Time Operating Systems p. 37