Programming R-T Abstractions TSW November 2009 Anders P. Ravn Aalborg University.

Slides:



Advertisements
Similar presentations
Real-Time Systems and Programming Languages © Alan Burns and Andy Wellings Chapter 12: Programming Schedulable Systems.
Advertisements

© Andy Wellings, 2004 Roadmap  Introduction  Concurrent Programming  Communication and Synchronization  Completing the Java Model  Overview of the.
Real-Time Systems and Programming Languages © Alan Burns and Andy Wellings Chapter 9: Real-Time Facilities.
© Andy Wellings, 2004 Roadmap  Introduction  Concurrent Programming  Communication and Synchronization  Completing the Java Model  Overview of the.
Scheduling Theory ITV Real-Time Systems Anders P. Ravn Aalborg University March 2007.
RTS - Implementation ITV Real-Time Systems Anders P. Ravn Aalborg University February 2006.
Software Engineering Lecture 5 Multiprogramming and Scheduling ASPI8-4 Anders P. Ravn March 2004.
Real-Time Systems Specification and Analysis ITV Mutiprogramming and Real-Time Programs Anders P. Ravn Aalborg University May 2009.
Real-Time Java Real-Time Systems Anders P. Ravn Aalborg University March 2008.
© Andy Wellings, 2004 Roadmap  Introduction  Concurrent Programming  Communication and Synchronization  Completing the Java Model  Overview of the.
© Andy Wellings, 2004 Roadmap  Introduction  Concurrent Programming  Communication and Synchronization  Completing the Java Model  Overview of the.
© Andy Wellings, 2004 Roadmap  Introduction  Concurrent Programming  Communication and Synchronization  Completing the Java Model  Overview of the.
Programming Languages for Embedded Systems. Embedded Systems Communication Terminals Communication Infra Structure Control Systems Surveillance Systems.
© Andy Wellings, 2004 Roadmap  Introduction  Concurrent Programming  Communication and Synchronization  Completing the Java Model  Overview of the.
Scheduling Theory ITV Multiprogramming and Real-Time Programs Anders P. Ravn Aalborg University May 2009.
© Andy Wellings, 2004 Roadmap  Introduction  Concurrent Programming  Communication and Synchronization  Completing the Java Model  Overview of the.
Real-time Java Threads Insik Shin Real-time Systems Group University of Pennsylvania.
Real-Time Systems Specification and Analysis ITV Real-Time Systems Anders P. Ravn Aalborg University February 2006.
© Andy Wellings, 2004 Roadmap  Introduction  Concurrent Programming  Communication and Synchronization  Completing the Java Model  Overview of the.
© Andy Wellings, 2004 Roadmap  Introduction  Concurrent Programming  Communication and Synchronization  Completing the Java Model  Overview of the.
1 Predictable Java Java Objekt 2, 19 August 2009 Anders P. Ravn and Hans Søndergaard Overview Implementations Next steps.
© Andy Wellings, 2003 Roadmap  Introduction  Concurrent Programming  Communication and Synchronization  Completing the Java Model  Overview of the.
Low-level Programming TSW November 2009 Anders P. Ravn Aalborg University.
The Implementation of Dynamic Priority Assignment on CVM Threading System Insik Shin Real-time Systems Group University of Pennsylvania.
© Andy Wellings, 2004 Roadmap  Introduction  Concurrent Programming  Communication and Synchronization  Completing the Java Model  Overview of the.
Real-Time Systems – The big Picture
Real-Time Systems Specification and Analysis ITV Real-Time Systems Anders P. Ravn Aalborg University February 2009.
© Andy Wellings, 2004 Roadmap  Introduction  Concurrent Programming  Communication and Synchronization  Completing the Java Model  Overview of the.
Clocks & Asynchronous Events. Overview Clocks  API  Implementation Asynchronous Events  API  Single Threaded Model  Multi-Threaded Model  Code Walkthrough.
© Alan Burns and Andy Wellings, 2001 Characteristics of a RTS Large and complex Concurrent control of separate system components Facilities to interact.
The Real-Time Java Profile ITV Real-Time Systems Anders P. Ravn Aalborg University February 2006.
© Andy Wellings, 2004 Roadmap  Introduction  Concurrent Programming  Communication and Synchronization  Completing the Java Model  Overview of the.
© Andy Wellings, 2004 Roadmap  Introduction  Concurrent Programming  Communication and Synchronization  Completing the Java Model  Overview of the.
Chair of Software Engineering ATOT - Lecture 21, 16 June 2003 Advanced Topics in Object Technology Bertrand Meyer.
© Andy Wellings, 2004 Roadmap  Introduction  Concurrent Programming  Communication and Synchronization  Completing the Java Model  Overview of the.
©Ian Sommerville 2004Software Engineering, 7th edition. Chapter 15 Slide 1 Real-time Systems 1.
Real-Time Software Design Yonsei University 2 nd Semester, 2014 Sanghyun Park.
Liang, Introduction to Java Programming, Eighth Edition, (c) 2011 Pearson Education, Inc. All rights reserved Concurrency in Android with.
A Safety-Critical Java Technology Compatibility Kit Hans Søndergaard Stephan Korsholm VIA University College, Horsens, Denmark & Anders P. Ravn Aalborg.
Real-Time Java Martin Schöberl. Real Time Java2 Overview What are real-time systems Real-time specification for Java RTSJ issues, subset Real-time profile.
Programming in Java Unit 2. Class and variable declaration A class is best thought of as a template from which objects are created. You can create many.
Distributed Real- Time in the RTSJ Andrew Borg. Presentation RMI – A brief introduction The RTSJ – A (very) brief introduction The DRTSJ – The 3 Levels.
Real-Time Java on JOP Martin Schöberl. Real-Time Java on JOP2 Overview RTSJ – why not Simple RT profile Scheduler implementation User defined scheduling.
Monitoring Deadline Misses in Periodic Real-time Threads Prepared By: Ebtesam Saleh Prepared For: Eng. Tasneem Darwesh University of Palestine.
Instructore: Tasneem Darwish1 University of Palestine Faculty of Applied Engineering and Urban Planning Software Engineering Department Concurrent and.
Enhancements to Java for Real Time Systems Theresa Dsena CSE Fall 2006 Prof. Ganesan.
1 Chapter 8 – Classes and Object: A Deeper Look Outline 1 Introduction 2 Implementing a Time Abstract Data Type with a Class 3 Class Scope 4 Controlling.
An Introduction to Programming and Object Oriented Design using Java 3 rd Edition. Dec 2007 Jaime Niño Frederick Hosch Chapter 18 Integrating user interface.
11 G53SRP: Clocks and Times in RTSJ Chris Greenhalgh School of Computer Science.
EEL The Real-Time Specification for Java (1)
11 G53SRP: Deadline misses and cost over-runs in RTSJ Chris Greenhalgh School of Computer Science.
EEL Real-time Java part 2. EEL Acknowledgements All the lecture slides were adopted from the slides of Andy Wellings.
Multithreading in JAVA
111 G53SRP: RTSJ Memory Areas Chris Greenhalgh School of Computer Science.
Thread Scheduling and Dispatching Maung Aung Han Marc E. Loy Jihua Zhong CIS 642: Seminar in Real-time Systems Instructor: Professor Insup Lee.
Thread A thread represents an independent module of an application that can be concurrently execution With other modules of the application. MULTITHREADING.
How to Compile Aspects with Real-Time Java Pengcheng Wu Northeastern University Mar. 14, 2005 FOAL Workshop with AOSD’05.
Real-Time Operating System Design
Quick Review of OOP Constructs Classes:  Data types for structured data and behavior  fields and methods Objects:  Variables whose data type is a class.
Multithreading & Synchronized Algoritma Pemrograman 3 Sistem Komputer – S1 Universitas Gunadarma 1.
11 G53SRP: Feasibility analysis Chris Greenhalgh School of Computer Science.
Threads b A thread is a flow of control in a program. b The Java Virtual Machine allows an application to have multiple threads of execution running concurrently.
© Andy Wellings, 2004 Thread Priorities I  Although priorities can be given to Java threads, they are only used as a guide to the underlying scheduler.
Real-Time Java Ron K. Cytron and Christopher D. Gill June 2001
Multithreading Lec 23.
G53SRP: Real Time Threads in RTSJ (part I)
G53SRP: Asynchronous Events in RTSJ
null, true, and false are also reserved.
Chapter 1: Computer Systems
Real Time Java : Synchronization
Presentation transcript:

Programming R-T Abstractions TSW November 2009 Anders P. Ravn Aalborg University

Characteristics of a RTS Timing Constraints Concurrent control of separate components Dependability Requirements Facilities to interact with special purpose hardware

Timing Constraints Notion of time Specifying timing constraints: Temporal scopes Notion of Event Clocks, delays and timeouts

RT Java Time Types public abstract class HighResolutionTime implements java.lang.Comparable {... public boolean equals(HighResolutionTime time); public final long getMilliseconds(); public final int getNanoseconds(); public void set(HighResolutionTime time); public void set(long millis); public void set(long millis, int nanos); }

Time HighResolutionTime AbsoluteTime RelativeTime

public class AbsoluteTime extends HighResolutionTime { // various constructor methods including public AbsoluteTime(AbsoluteTime T); public AbsoluteTime(long millis, int nanos);... public final AbsoluteTime add(RelativeTime time); public final RelativeTime subtract(AbsoluteTime time); public final AbsoluteTime subtract(RelativeTime time); } RTSJ Absolute and Relative Time public class RelativeTime extends HighResolutionTime { // various constructor methods including public RelativeTime(long millis, int nanos); public RelativeTime(RelativeTime time);... public final RelativeTime add(RelativeTime time); public final RelativeTime subtract(RelativeTime time); }

Temporal scope C: maximum execution time D: deadline for completion of execution T: minimum time between releases (period) S: minimum delay before start of execution

RTSJ ReleaseParameters ReleaseParameters PeriodicParameters AperiodicParameters SporadicParameters

RTSJ ReleaseParameters public abstract class ReleaseParameters { protected ReleaseParameters( RelativeTime cost, RelativeTime deadline, AsyncEventHandler overrunHandler, AsyncEventHandler missHandler);... }

public class PeriodicParameters extends ReleaseParameters { public PeriodicParameters( HighResolutionTime start, RelativeTime period, RelativeTime cost, RelativeTime deadline, AsyncEventHandler overrunHandler, AsyncEventHandler missHandler); public RelativeTime getPeriod(); public HighResolutionTime getStart(); } RTSJ Periodic Parameters

RTSJ Aperiodic- and SporadicParameters public class AperiodicParameters extends ReleaseParameters { public AperiodicParameters(RelativeTime cost, RelativeTime deadline, AsyncEventHandler overrunHandler, AsyncEventHandler missHandler); } public class SporadicParameters extends AperiodicParameters { public SporadicParameters(RelativeTime minInterarrival, RelativeTime cost, RelativeTime deadline, AsyncEventHandler overrunHandler, AsyncEventHandler missHandler); public RelativeTime getMinimumInterarrival(); public void setMinimumInterarrival(RelativeTime minimum); }

RTSJ AsyncEvent public class AsyncEvent { public AsyncEvent();... public void addHandler(AsyncEventHandler handler); public void fire();... } An asynchronous event can have a set of handlers associated with it, and when the event occurs, the fireCount of each handler is incremented, and the handlers are released.

RTSJ Clock public abstract class Clock { public Clock(); public static Clock getRealtimeClock(); public abstract RelativeTime getEpochOffset(); public AbsoluteTime getTime(); public abstract void getTime(AbsoluteTime time); public abstract RelativeTime getResolution(); public abstract void setResolution(RelativeTime resolution); }

Characteristics of a RTS Timing Constraints Concurrent control of separate components Dependability Requirements Facilities to interact with special purpose hardware

RTSJ Schedulable «interface» Schedulable AsyncEventHandler BoundAsyncEventHandler RealTimeThread NoHeapRealTimeThread

RTSJ AsyncEventHandler public class AsyncEventHandler extends java.lang.Object implements Schedulable { public AsyncEventHandler( SchedulingParameters scheduling, ReleaseParameters release, MemoryArea area);... public void handleAsyncEvent(); // the program to be executed... }

RTSJ RealTimeThread public class RealtimeThread extends java.lang.Thread implements Schedulable { public RealtimeThread(SchedulingParameters s, ReleaseParameters r);... public static RealtimeThread currentRealtimeThread(); public synchronized void schedulePeriodic(); // add the thread to the list of schedulable objects public synchronized void deschedulePeriodic(); // remove the thread from the list of schedulable object // when it next issues a waitForNextPeriod public boolean waitForNextPeriod() throws...; public synchronized void interrupt(); // overrides java.lang.Thread.interrupt() public static void sleep(Clock c, HighResolutionTime time) throws...; }

Ravenscar Periodic Thread

Asynchronous Event and Handler

A Real-Time Application Periodic Event Handlers Aperiodic Event Handlers collected in a mission Mission Handler Each handler  has a Memory  is Scheduled 20

Periodic handler class Periodic extends PeriodicEventHandler { protected Periodic(.., PeriodicParameters pp, Scheduler scheduler, MemoryArea memory); public void handleEvent() { // the logic to be executed every period } 21

Aperiodic handler class Aperiodic extends AperiodicEventHandler { protected Aperiodic(.., AperiodicParameters ap, Scheduler scheduler, MemoryArea memory); public void handleEvent() { // the logic to be executed when an event occurs } 22

A simple mission public class Basic extends Mission { protected Basic(.., AperiodicParameters ap, Scheduler scheduler, MemoryArea memoryArea) {... // initialization } public static void main (String[] args) { new Basic( null, null, new CyclicScheduler(), new LTMemory(10*1024)); } 23

…The mission addToMission( new Periodic( null, pp, getScheduler(), new LTMemory(1024))); addToMission( new Periodic( null, pp, getScheduler(), new LTMemory(1024)));... add(); // mission to its scheduler 24

Complex mission private Mission[] mission; private int active = 0; static AperiodicEvent event; public ThreeSequentialMissions(...) { mission = new Mission[3]; // set up the three missions mission[0] = new Mission(...); // add handlers for mission 0 // including the mission termination... mission[1] = new Mission();... // start the first mission mission[active].add(); event = new AperiodicEvent(this); } 25

Changing mission private Mission[] mission; private int active = 0; static AperiodicEvent event; public ThreeSequentialMissions(...) {... } public void handleEvent() { mission[active].remove(); active = (active + 1) % mission.length; mission[active].add(); } 26

RTSJ Scheduler Scheduler PriorityScheduler Class which represents the required (by the RTSJ) priority-based scheduler. The default instance is the base scheduler which does fixed priority, preemptive scheduling.

RTSJ SchedulingParameters public class PriorityParameters { public PriorityParameters(int priority);... } public class ImportanceParameters { public PriorityParameters(int priority, int importance);... } Importance is an additional scheduling metric that may be used by some priority-based scheduling algorithms during overload conditions to differentiate execution order among threads of the same priority.

RTSJ PriorityScheduler public class PriorityScheduler extends Scheduler { public static PriorityScheduler instance();... protected boolean addToFeasibility(Schedulable schedulable); public boolean isFeasible(); public boolean SetIfFeasible( Schedulable schedulable, ReleaseParameters release, MemoryParameters memory); }

RTSJ Memory Management MemoryArea «singleton» HeapMemory ScopedMemory ImmortalMemory LTMemory ImmortalPhysicalMemory VTMemory

RTSJ MemoryArea public abstract class MemoryArea { protected MemoryArea(long sizeInBytes); public void enter(java.lang.Runnable logic); // associate this memory area to the current thread // for the duration of the logic.run method public static MemoryArea getMemoryArea( java.lang. Object object); // get the memory area associated with the object public long memoryConsumed(); // number of bytes consumed in this memory area public long memoryRemaining(); // number of bytes remaining... public synchronized java.lang.Object newInstance( java.lang.Class type)throws IllegalAccessException, InstantiationException, OutOfMemoryError; // allocate an object public long size(); // the size of the memory area }

Simplicity – Static Schedules Cyclic Executive Time Triggered Architecture (Kopetz) Synchronous Languages (Esterel) Giotto (Henzinger)