Real-Time Programming Languages (ADA and Esterel as Examples)

Similar documents
Real-Time Systems Hermann Härtig Real-Time Programming Languages (ADA and Esterel as Examples)

Introduction 2 The first synchronous language (early 80 s) Gérard Berry and his team (École des Mines de Paris / INRIA Sophia-Antipolis) Imperative, s

The Esterel language

Ada and Real-Time. Prof. Lars Asplund. Mälardalen University, Computer Science

EE382N.23: Embedded System Design and Modeling

ECL: A SPECIFICATION ENVIRONMENT FOR SYSTEM-LEVEL DESIGN

Programming Languages for Real-Time Systems. LS 12, TU Dortmund

AI Non-Preemptive Dispatching. A new dispatching policy is defined for the non-preemptive execution of Ada tasks.

Real-Time Programming

Introduction to Lab 2

Today s topic: Real Time Programming with Ada

Integrating OOP and Tasking The missing requeue

Resource management. Real-Time Systems. Resource management. Resource management

Chapter Machine instruction level 2. High-level language statement level 3. Unit level 4. Program level

Real-Time Systems. Lecture #4. Professor Jan Jonsson. Department of Computer Science and Engineering Chalmers University of Technology

Models of concurrency & synchronization algorithms

Ada 2005 An introduction for TTK4145

Operating Systems (2INC0) 2017/18

Today s topic: Real Time Programming with Ada

IT 540 Operating Systems ECE519 Advanced Operating Systems

Synchronous Languages Lecture 07

Time Handling in Programming Language

G Programming Languages Spring 2010 Lecture 13. Robert Grimm, New York University

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

The University of Texas at Arlington

CS370 Operating Systems Midterm Review

Compiling Esterel. Dumitru Potop-Butucaru. Stephen A. Edwards Gérard Berry

EE458 - Embedded Systems Lecture 8 Semaphores

Synchronous Statecharts. Christian Motika

SWE 760 Lecture 1: Introduction to Analysis & Design of Real-Time Embedded Systems

Introduction to Lab 2

Concurrent Programming Lecture 10

Chapter 13 Topics. Introduction. Introduction

CS 31: Introduction to Computer Systems : Threads & Synchronization April 16-18, 2019

Real-Time and Concurrent Programming Lecture 4 (F4): Monitors: synchronized, wait and notify

Using and Compiling Esterel

Concurrent Programming using Threads

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

Chapter 5 Concurrency: Mutual Exclusion and Synchronization

The Deadline Floor Protocol and Ada

Learning from Bad Examples. CSCI 5828: Foundations of Software Engineering Lecture 25 11/18/2014

Lecture 8: September 30

1 Process Coordination

Real-Time and Embedded Systems (M) Lecture 19

Chapter 5 Concurrency: Mutual Exclusion. and. Synchronization. Operating Systems: Internals. and. Design Principles

AP COMPUTER SCIENCE JAVA CONCEPTS IV: RESERVED WORDS

Numerical approach estimate

OPERATING SYSTEMS CS3502 Spring Processor Scheduling. Chapter 5

Concurrency - Topics. Introduction Introduction to Subprogram-Level Concurrency Semaphores Monitors Message Passing Java Threads

THREADS AND CONCURRENCY

Reactive Web Programming

Real Time & Embedded Systems. Final Exam - Review

CPSC/ECE 3220 Fall 2017 Exam Give the definition (note: not the roles) for an operating system as stated in the textbook. (2 pts.

Synchronization. CSCI 5103 Operating Systems. Semaphore Usage. Bounded-Buffer Problem With Semaphores. Monitors Other Approaches

Green Hills Software, Inc.

The Ravenscar Tasking Profile for High Integrity Real-Time Programs

COMP 346 WINTER Tutorial 2 SHARED DATA MANIPULATION AND SYNCHRONIZATION

The University of Texas at Arlington

Concurrency. Lecture 14: Concurrency & exceptions. Why concurrent subprograms? Processes and threads. Design Issues for Concurrency.

A Simple Example. The Synchronous Language Esterel. A First Try: An FSM. The Esterel Version. The Esterel Version. The Esterel Version

Java Threads and intrinsic locks

Outline of the talk. The egg and the hen Or, Which comes first: the problem or the solution? Challenges (2/6) Challenges (1/6) Recall of basics

ni.com Preparing for the CLAD Exam

CHAPTER 6: PROCESS SYNCHRONIZATION

THREADS & CONCURRENCY

SYNCHRONIZED DATA. Week 9 Laboratory for Concurrent and Distributed Systems Uwe R. Zimmer. Pre-Laboratory Checklist

Note: in this document we use process and thread interchangeably.

Multitasking / Multithreading system Supports multiple tasks

The Esterel Language. The Esterel Version. Basic Ideas of Esterel

Lecture Notes on Programming Languages

Algorithms for Scalable Synchronization on Shared Memory Multiprocessors by John M. Mellor Crummey Michael L. Scott

CS370 Operating Systems

What is the Race Condition? And what is its solution? What is a critical section? And what is the critical section problem?

Deadlock. Lecture 4: Synchronization & Communication - Part 2. Necessary conditions. Deadlock handling. Hierarchical resource allocation

IT 540 Operating Systems ECE519 Advanced Operating Systems

Chapter 13. Concurrency ISBN

General Objectives: To understand the process management in operating system. Specific Objectives: At the end of the unit you should be able to:

Structuring the Computation. Structuring the Computation

CS 162 Operating Systems and Systems Programming Professor: Anthony D. Joseph Spring Lecture 8: Semaphores, Monitors, & Condition Variables

Implementing Priority Inheritance Algorithms in an Ada Runtime System

Module 6: Process Synchronization. Operating System Concepts with Java 8 th Edition

Programming. In Ada JOHN BARNES TT ADDISON-WESLEY

Language Extensions. present [C and not pre(a or B or C)] then p else q end

Real Time Programming with Ada

Synchronization II: EventBarrier, Monitor, and a Semaphore. COMPSCI210 Recitation 4th Mar 2013 Vamsi Thummala

Real-Time Systems and Programming Languages

G52CON: Concepts of Concurrency

Concurrent Programming. Alexandre David

연세대학교전기전자공학과프로세서연구실박사과정김재억.

Reducing Priority Inversion in Interprocessor Synchronization on a Fixed-Priority Bus

OBJECT ORIENTED SIMULATION LANGUAGE. OOSimL Reference Manual - Part 2

Programming Languages Third Edition. Chapter 9 Control I Expressions and Statements

Synchronization for Concurrent Tasks

Java: Just Another Version of Ada an overview of Ada 2005

Virtual Machine Design

On 17 June 2006, the editor provided the following list via an to the convener:

Lecture 2. The SCADE Language Data Flow Kernel. Daniel Kästner AbsInt GmbH 2012

Implementing a High-Integrity Executive using Ravenscar

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

Introduction. Coherency vs Consistency. Lec-11. Multi-Threading Concepts: Coherency, Consistency, and Synchronization

Transcription:

Real-Time Programming Languages (ADA and Esterel as Examples) Real-Time Systems, 2008 RT Languages, 1

RT Language Classes HLL suitable for RT-Analysis (e.g., rms or time-driven) Synchronous HLL (clock driven) Esterel Lustre (State Charts) RT-Euclid Normal HLL with some rt-extensions ADA RT-Java PEARL CHILL Real-Time Systems, 2008 RT Languages, 2

Synchroneous Systems > Synchronous Languages Gerard Berry: Our approach is based on the standard principle of separation of concerns. First, write the program at the logical level and make use of all the mathematics available there. Then, implement the program using the best available automatic synthesis tools, and check that the result is practically OK. Ideal Systems produce their outputs synchronously with their inputs. Real-Time Systems, 2008 RT Languages, 3

Gerard Berry: Implementation For example, assume we want to trigger a reaction with two inputs A and B present. We execute the following [compiler generated] C code: M_I_A(); M_I_B(); M(); If X is emitted by the reaction, the function M() will call an output function M O X() we have to supply. The reaction is subject to an essential atomicity condition: during the execution of the main reaction function M(), it is forbidden to call any input function. This is the software counterpart to the hardware requirement that input voltages must be kept stable during a clock cycle. Real-Time Systems, 2008 RT Languages, 4

Esterel Most statements are instantaneous (starts and terminates at the same instant of time) Stepwise execution, everything completes in each step/cycle Time consumption explicit (e.g., Pause ) Real-Time Systems, 2008 RT Languages, 5

Esterel Data : Variables and Signals Variable: Value Signal: Value vs Status Value of any type Status: Present/non present Newly evaluated at every step present when emitted Real-Time Systems, 2008 RT Languages, 6

Signals vs Variables Emit Count(pre(?Count) + 1) vs V:= V+1; Beware: writing emit COUNT(?COUNT+1) is tempting but incorrect. Since?COUNT is the current value of COUNT, it cannot be incremented and reemitted right away as itself. It is necessary to use the previous value pre(?count). Real-Time Systems, 2008 RT Languages, 7

Esterel: Statements Consume no time (unless explicitly said otherwise) Await A: consumes one A Pause: consumes one time step (tick) X:= Y: assigns values to variables S1;S2 S1 S2 Loop S end starts s, repeats if not terminated (s must consume time) Loop S each R restarts S at each occurance of R Real-Time Systems, 2008 RT Languages, 8

Signals Emit x(y): sets signal x present, assigns value y?s current value: value just emitted (if so) or value of previous instant (otherwise) pre(?s): previous value Present then s1 else s2 end (conditional) Abort S when do R end abort; starts S, terminates when σ becomes active, does R Suspend S when suspends S when active no emission when suspended Trap in S end trap starts S, aborts when present Real-Time Systems, 2008 RT Languages, 9

More Statements halt: loop pause end await : abort halt when end abort sustain x(t): loop emit x(t); pause end every do S end every: await ; loop S each Real-Time Systems, 2008 RT Languages, 10

Examples (all by Berry): ABRO Specification ABRO: Emit an output O as soon as two inputs A and B have occurred. Reset this behavior each time the input R occurs. module ABRO: input A, B, R; output O; loop [ await A await B ]; emit O each R end module Real-Time Systems, 2008 RT Languages, 11

Counting Specification COUNT: Count the number of occurrences of the input I seen so far, and broadcast it as the value of a COUNT signal at each new I. module COUNT: input I; output COUNT := 0 : integer; every I do emit COUNT(pre(?COUNT) + 1) end every end module Beware: emit COUNT(?COUNT+1) is tempting but incorrect. Real-Time Systems, 2008 RT Languages, 12

Speed Specification SPEED: Count the number of centimeters run per second, and broadcast that number as the value of a Speed signal every second. Real-Time Systems, 2008 RT Languages, 13

module SPEED: input Centimeter, Second; relation Centimeter # Second; output Speed : integer; loop var Distance := 0 : integer in abort every Centimeter do Distance := Distance+1 end every when Second do emit Speed(Distance) end abort end var end loop end module Real-Time Systems, 2008 RT Languages, 14

RT-Extensions for Standard HLL: Requirements standard goodies + exception handling tasks + communication priorities a notion of time access to low level hardware portability efficiency predictability Real-Time Systems, 2008 RT Languages, 15

ADA as an Example Used intensively, e.g. Military, Aircraft (B777), Space most commonly used language in US weapons modernization Ada 83 - result of a competition... Ada 95 - major redesign (ISO/IEC 8652: 1995) Ravenscar: subset Ada 2005 Annex: Real-Time Systems (here: very limited excerpts... Especially, not covered at all: packages OO, Generics Real-Time Systems, 2008 RT Languages, 16

Exception Handling Exceptions are declared and may be raised. Buffer_Full: exception; begin... if BufferSize > Limit then raise Buffer_Full end if;... exception when Buffer_Full => reset; when others => bla ; end; Real-Time Systems, 2008 RT Languages, 17

Tasks Tasks are entities whose execution may proceed in parallel. A task has a thread of control. Different tasks proceed independently, except at points where they synchronize.... declared by an object declaration or created dynamically.... Every task has a master : block, subprogram etc. containing the declaration of the task object (or access object). Before leaving the master, the parent task waits for all dependent tasks. Real-Time Systems, 2008 RT Languages, 18

task type Babbler is Example entry Start(Message : Unbounded_String; Count : Natural); end Babbler; task body Babbler is Babble : Unbounded_String; Maximum_Count : Natural; begin -- We're done, exit task. end Babbler; Real-Time Systems, 2008 RT Languages, 19

Communication Activation and termination (see previous slide) protected objects for synchronized access to shared data rendezvous for synchronous communication unprotected access to shared data (global variables) Real-Time Systems, 2008 RT Languages, 20

The Rendezvous One task calls an entry (Client) Other task accepts a call (Server) calling task placed on a queue Real-Time Systems, 2008 RT Languages, 21

task body Babbler is Babble : Unbounded_String; Maximum_Count : Natural; begin Rendezvous, example accept Start(Message : Unbounded_String; Count : Natural) do Babble := Message; -- Copy the rendezvous data to Maximum_Count := Count; -- local variables. end Start; -- babble... end Babbler; Real-Time Systems, 2008 RT Languages, 22

procedure Noise is Babble_1 : Babbler; -- Create a task. Babble_2 : Babbler; -- Create another task. begin -- At this point we have two active tasks, but both of them -- are waiting for a "Start" message. So, send them a Start. Babble_1.Start(U("Hi, I'm Babble_1"), 10); Babble_2.Start(U("And I'm Babble_2"), 6); end Noise; Real-Time Systems, 2008 RT Languages, 23

Entries and Exceptions What happens if an exception is raised within an accept statement? Exception is raised twice, at caller and callee tasks Real-Time Systems, 2008 RT Languages, 24

select when (expression) => accept E1 do bla end E1; or when (expression) => accept E2 do bla end E2; or... end select; Select Statement Arbitrary entry, whose expression is evaluated to true, is called. Exception if no expression evaluates to true. Real-Time Systems, 2008 RT Languages, 25

Time Access to time: Calendar object. delay duration point in time delay 5.0; -- delay for 5 seconds delay until A_Time; -- delay until it is... Real-Time Systems, 2008 RT Languages, 26

select accept An_Entry do bla end An_Entry; or delay 5.0; Put("An_Entry: timeout"); end select; Delay and Select Real-Time Systems, 2008 RT Languages, 27

Protected Objects export functions read-only access to shared data functions can be executed concurrently procedures read/write access to shared data Procedures: executed under mutual exclusion entries procedures with barriers (boolean expressions) synchronization operations automatic evaluate barriers at each call to and at each return from an entry Real-Time Systems, 2008 RT Languages, 28

protected type Resource is entry Seize; -- Acquire this resource exclusively. procedure Release; -- Release the resource. private Busy : Boolean := False; end Resource; protected body Resource is entry Seize when not Busy is begin Busy := True; end Seize; procedure Release is begin Busy := False end Release; end Resource; Real-Time Systems, 2008 RT Languages, 29

Reordering Requests: Requeue Flexible, explicit treatment of request orders example: An request enters entry or barrier Parameters inspected Decision: wait for another chance Action: Requeue a request of a caller to some entry or barrier Not easy to use!!! Real-Time Systems, 2008 RT Languages, 30

Example: Requeue Statement protected body AirportGate is entry EnterGateBusiness(Ticket) begin if Ticket.Economy then requeue EnterGateEconomy; end if; CountBusinessPassengers end EnterGate; entry EnterGateEconomy(Ticket) when AllBusinessPassengersHaveEntered begin... end end Event; Real-Time Systems, 2008 RT Languages, 31

select delay 5.0; Timeouts on Actions CalculationComplete:= false; -- triggering alternative then abort Invert_Giant_Matrix(M); -- abortable part CalculationComplete:= true; end select; also possible: an entry call instead of delay (intricate sematics) Real-Time Systems, 2008 RT Languages, 32

Priorities Priority Scheduling Ceiling Queuing Policies Dynamic priorities Real-Time Annex Real-Time Systems, 2008 RT Languages, 33

Time Access to Real-Time: Real_Time.Time finer grained monotonically non-decreasing (time zone, correction, summertime) loop delay until Poll_Time; --- poll Poll_Time:= Poll_Time + Period; end loop; Real-Time Systems, 2008 RT Languages, 34

Priorities Task/protected type T is pragma Priority(P); pragma task_dispatching_policy( fifo within priorities ); evaluated at init time task gets priority of creator if no pragma is present Real-Time Systems, 2008 RT Languages, 35

Dynamic Priorities procedure Set_Priority(Priority: Any_Priority; T: Task_ID := Current_Task); function Get_Priority(T: Task_ID := Current_Task) return Any_Priority; Real-Time Systems, 2008 RT Languages, 36

Priority Ceiling Pragma Locking_Policy(Ceiling_Locking); the task executing a protected operation inherits the priority of the protected object dynamic priorities higher than ceiling Real-Time Systems, 2008 RT Languages, 37

Standard: FIFO Entry Queuing Policies pragma Queuing_Policy(Priority_Queuing); the user can override the default FIFO policy with the pragma Queuing_Policy per partition (not per entries or tasks) passing of dynamic priorities as implicit parameters Real-Time Systems, 2008 RT Languages, 38

ADA No support for explicit specification of periodic processes!!! for static analysis for feasible schedules!!! Real-Time Systems, 2008 RT Languages, 39

Material Esterel: Gerard Berry, Esterel Language Primer http://www.esterel-technologies.com/files/primer.zip ADA: lots... Used for this lecture: Burns/Wellings: RT systems and Programming Languages http://www.adahome.com/ammo/cplpl2ada.html (Ada for C programmers) http://www.adahome.com/tutorials/lovelace http://atlas.otago.ac.nz:800/staff/paulg/ Ada-Information/Ada95/Rationale ADA 2005 and Ravenscar: http://www.adacore.com/home/ada_answers/ada_2005 Real-Time Systems, 2008 RT Languages, 40