G53SRP: Real Time Threads in RTSJ (part I)

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.
Scheduling Theory ITV Real-Time Systems Anders P. Ravn Aalborg University March 2007.
Unit 141 Threads What is a Thread? Multithreading Creating Threads – Subclassing java.lang.Thread Example 1 Creating Threads – Implementing java.lang.Runnable.
Software Engineering Lecture 5 Multiprogramming and Scheduling ASPI8-4 Anders P. Ravn March 2004.
Programming R-T Abstractions TSW November 2009 Anders P. Ravn Aalborg University.
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.
© 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 Systems Specification and Analysis ITV Real-Time Systems Anders P. Ravn Aalborg University February 2006.
1 Threads (Part I) Introduction to Threads and Concurrency Overview  Introduction to Threads of Computation  Creating Threads in java an Example  Thread.
© 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.
The Implementation of Dynamic Priority Assignment on CVM Threading System Insik Shin Real-time Systems Group University of Pennsylvania.
Threads Just Java: C10–pages 251- C11–pages 275-
Real-Time Systems Specification and Analysis ITV Real-Time Systems Anders P. Ravn Aalborg University February 2009.
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.
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.
Java Programming: Advanced Topics
Object Oriented Programming Lecture 8: Introduction to laboratorial exercise – part II, Introduction to GUI frames in Netbeans, Introduction to threads.
Lecture 5 : JAVA Thread Programming Courtesy : MIT Prof. Amarasinghe and Dr. Rabbah’s course note.
Quick overview of threads in Java Babak Esfandiari (extracted from Qusay Mahmoud’s slides)
Monitoring Deadline Misses in Periodic Real-time Threads Prepared By: Ebtesam Saleh Prepared For: Eng. Tasneem Darwesh University of Palestine.
Today’s Agenda  Quick Review  Finish Java Threads  The CS Problem Advanced Topics in Software Engineering 1.
Concurrent Programming in Java Dr. Zoltan Papp. Motivation: event driven, responsive systems Sequential approach: while ( true ) { do event = getEventId()
1 Tutorial: CSI 3310 Dewan Tanvir Ahmed SITE, UofO.
Instructore: Tasneem Darwish1 University of Palestine Faculty of Applied Engineering and Urban Planning Software Engineering Department Concurrent and.
111 © 2002, Cisco Systems, Inc. All rights reserved.
COP-3330: Object Oriented Programming Flow Control May 16, 2012 Eng. Hector M Lugo-Cordero, MS.
A Guide to Advanced Java Faculty:Nguyen Ngoc Tu. Concurrent programming in Java How to make all things run-able?
11 G53SRP: Clocks and Times in RTSJ Chris Greenhalgh School of Computer Science.
Multithreading in Java Sameer Singh Chauhan Lecturer, I. T. Dept., SVIT, Vasad.
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.
Introduction to Threads Session 01 Java Simplified / Session 14 / 2 of 28 Objectives Define a thread Define multithreading List benefits of multithreading.
1 5.0 Garbage collector & Threads : Overview Introduction: In this module we discuss the merits and demerits of automated garbage collection over manual.
UMass Lowell Computer Science Java and Distributed Computing Prof. Karen Daniels Fall, 2000 Lecture 18 Advanced Java Concepts Threads and Multithreading.
Multithreading in JAVA
Object-oriented Programming in Java. © Aptech Ltd. Introduction to Threads/Session 7 2  Introduction to Threads  Creating Threads  Thread States 
1 G53SRP: Clocks and Time in Java Chris Greenhalgh School of Computer Science.
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.
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.
Chapter 13: Multithreading The Thread class The Thread class The Runnable Interface The Runnable Interface Thread States Thread States Thread Priority.
© 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.
1 G53SRP: Introduction to Real Time Scheduling Chris Greenhalgh School of Computer Science.
Multithreading / Concurrency
Multi Threading.
Java Multithreading.
Multithreaded Programming in Java
G53SRP: Asynchronous Events in RTSJ
G53SRP: Resource Sharing Issues
Java Based Techhnology
Principles of Software Development
Multithreading.
Real Time Java : Synchronization
Chapter 15 Multithreading
Computer Science 2 06A-Java Multithreading
Multithreading in java.
Java Chapter 3 (Estifanos Tilahun Mihret--Tech with Estif)
Presentation transcript:

G53SRP: Real Time Threads in RTSJ (part I) Real Time Scheduling 23/07/2018 G53SRP: Real Time Threads in RTSJ (part I) Chris Greenhalgh School of Computer Science G53SRP

Contents Overview The Scheduler Class Fixed Priority Scheduler The RealtimeThread Class RealtimeThread properties SchedulingParameters PriorityParameters ReleaseParameters Periodic RealtimeThreads overview Book: Wellings 10.2.1, 10.3, 10.4.1, 10.4.2 (part), 10.4.4, 10.5, 12.1 (part), 12.3 (part)

Class Overview … <<interface>> java.lang. Runnable <<interface>> javax.realtime. Schedulable implements extends implements java.lang. Thread <<abstract>> javax.realtime. Scheduler has javax.realtime. RealtimeThread extends javax.realtime. PriorityScheduler extends (Default) … javax.realtime. NoHeapRealtimeThread extends

Checking and setting the Scheduler package javax.realtime; public abstract class Scheduler { public static Scheduler getDefaultScheduler(); public static void setDefaultScheduler(Scheduler s); public String getPolicyName(); // other Scheduler methods … } See HelloScheduler.java

The Priority-based Scheduler package javax.realtime; public class PriorityScheduler extends Scheduler { public static PriorityScheduler instance(); // Scheduler-related info: priorities // Note: all RT Priorities > standard (1-10) public int getMinPriority(); public int getMaxPriority(); // at least min+27 public int getNormPriority(); // other PriorityScheduler methods … } See HelloScheduler.java

The Priority-based Scheduler Only standard scheduler specified in RTSJ Used as initial default scheduler Schedules realtime threads according to priority Single fixed priority assigned to each thread Fully pre-emptive i.e. a higher priority thread that becomes runnable immediately pre-empts a lower priority thread Does not time-slice threads of equal priority Running thread may yield to allow another equal-priority thread to run

The RealtimeThread class package javax.realtime; public class RealtimeThread extends java.lang.Thread implements Schedulable { public RealtimeThread( SchedulingParameters scheduling, ReleaseParameters release, MemoryParameters memory, MemoryArea area, ProcessingGroupParameters group, java.lang.Runnable logic); // partial cons. – defaults are all null public RealtimeThread(); public RealtimeThread(SchedulingParameters s); public RealtimeThread(SchedulingParameters s, ReleaseParameters release); …

… public static RealtimeThread currentRealtimeThread(); // from Thread public void run(); // runs logic by default public void start(); public void interrupt(); // changed: see ATC public void join(); public void join(long millis); public void join(long millis, int nanos); static public void sleep(long millis); static public void sleep(long millis, int nanos); // high-res versions static void sleep(Clock clock, HighResolutionTime t); static void sleep(HighResolutionTime time);

… // scheduler public Scheduler getScheduler(); public void setScheduler(Scheduler scheduler); // from Thread public void setPriority(int priority); public int getPriority(); // getters & setters for all parameters // (release, scheduler, memory, proc.group)… // periodic threads (see later) static boolean waitForNextPeriod(); static boolean waitForNextPeriodInterruptible(); public void schedulePeriodic(); public void deschedulePeriodic(); }

E.g. HelloRealtimeThread.java import javax.realtime.RealtimeThread; public class HelloRealtimeThread extends RealtimeThread { public void run() { RealtimeThread rt = RealtimeThread.currentRealtimeThread(); System.out.println("Hello from "+rt); } public static void main(String args[]) { RealtimeThread rt = new HelloRealtimeThread(); rt.start(); try { rt.join(); } catch (InterruptedException ie) { } Code run with realtime support

RealtimeThread (Schedulable) properties SchedulingParameters (subclass) Scheduler-specific thread information, e.g. priority ReleaseParameters (subclass) Temporal characteristics of the thread, e.g. release time, period, deadline, cost MemoryParameters memory usage of thread, e.g. max size, max rate of allocation

RealtimeThread (Schedulable) properties (cont.) MemoryArea type/area of memory in which new objects will be allocated by thread ProcessingGroupParameters optional group limits (cost per period) for a set of schedulable objects java.lang.Runnable the logic to be run by the default run method (or over-ride run method)

SchedulingParameters classes <<abstract>> javax.realtime. SchedulingParameters Empty class javax.realtime. PriorityParameters extends javax.realtime. ImportanceParameters extends

PriorityParameters class package javax.realtime; public abstract class PriorityParameters extends SchedulingParameters { public PriorityParameters(int priority); public int getPriority(); public void setPriority(int priority); } 14

PriorityParameters notes SchedulingParameters depend on Scheduler used PriorityParameters used with (e.g.) PriorityScheduler Equivalent to Thread get/setPriority

Priority notes Realtime Priorities > normal thread priorities Normal priorities 1-10 Time-sliced – priority affects time budget RT priorities 11-? (at least 28) Strict order – only highest priority runs See NRTPriority.java See RTPriority.java

ImportanceParameters Extends PriorityParameters Adds an integer importance property May be used by scheduler in deadline over-run situations E.g. to identify safety-critical tasks for preferential scheduling Optional – depends on scheduler implementation

ReleaseParameters classes <<abstract>> javax.realtime. ReleaseParameters extends javax.realtime. PeriodicParameters javax.realtime. AperiodicParameters javax.realtime. SporadicParameters extends

ReleaseParameters class package javax.realtime; public abstract class ReleaseParameters { protected ReleaseParameters( RelativeTime cost, RelativeTime deadline, AsyncEventHandler overrunHandler, AsyncEventHandler missHandler); // getters & setters … } 19

ReleaseParameters notes For every type of realtime thread or other Schedulable cost Time units per release May (or may not) be enforced as maximum May (or may not) be used for feasibility test deadline Latest completion time after release time

PeriodicParameters class package javax.realtime; public class PeriodicParameters extends ReleaseParameters { public PeriodicParameters( HighResolutionTime start, RelativeTime period, RelativeTime cost, RelativeTime deadline, AsyncEventHandler overrunHandler, AsyncEventHandler missHandler); // getters & setters … } Specific to Periodic tasks 21

PeriodicParameters notes start may be AbsoluteTime or RelativeTime Default deadline = period

Periodic RealtimeThread Follows standard code pattern: public void run() { boolean ok = true; while(ok) { // periodic task code … ok = RealtimeThread. waitForNextPeriod(); } // contingency… See HelloPeriodicThread.java

Example Periodic RealtimeThread (no problems) Process Release Time Process Process Completion Time Deadline met Start Period… Call to waitForNextPeriod RT1 Actual task execution waitForNextPeriod blocking 1000 2000 3000 4000 5000 Time (ms)

Summary Scheduler exposed through Scheduler abstract class Fixed Priority Scheduler provided as default –PriorityScheduler RealtimeThread class extends java.lang.Thread implements Schedulable as well as Runnable (see later)

Summary (2) RealtimeThread properties SchedulingParameters – for Scheduler PriorityParameters – for PriorityScheduler, specifies thread priority (like Thread.get/setPriority) ReleaseParameters Defines thread deadline and cost Subclassed as PeriodicParameters, AperiodicParameters & SporadicParameters

Summary (3) PeriodicParameters Defines thread start time/delay and period Supported by RealtimeThread.waitForNextPeriod