11 G53SRP: Clocks and Times in RTSJ Chris Greenhalgh School of Computer Science.

Slides:



Advertisements
Similar presentations
How to Build Multi- threaded Applications in.NET Mazen S. Alzogbi Technology Specialist Microsoft Corporation.
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.
Programming R-T Abstractions TSW November 2009 Anders P. Ravn Aalborg University.
© Andy Wellings, 2004 Roadmap  Introduction  Concurrent Programming  Communication and Synchronization  Completing the Java Model  Overview of the.
Classification of Simulation Models
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.
Programming Languages for Embedded Systems. Embedded Systems Communication Terminals Communication Infra Structure Control Systems Surveillance Systems.
CS220 Software Development Lecture: Multi-threading A. O’Riordan, 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 Recitation 11. Applet Applets. An applet is a Java program that is started by a browser (e.g. netscape or internet explorer) when an html file has a.
© Andy Wellings, 2004 Roadmap  Introduction  Concurrent Programming  Communication and Synchronization  Completing the Java Model  Overview of the.
ThreadThread Thread Basics Thread Synchronization Animations.
Real-Time Systems Specification and Analysis ITV Real-Time Systems Anders P. Ravn Aalborg University February 2009.
Concurrency - 1 Tasking Concurrent Programming Declaration, creation, activation, termination Synchronization and communication Time and delays conditional.
© 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.
The Processor Data Path & Control Chapter 5 Part 1 - Introduction and Single Clock Cycle Design N. Guydosh 2/29/04.
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.
A Safety-Critical Java Technology Compatibility Kit Hans Søndergaard Stephan Korsholm VIA University College, Horsens, Denmark & Anders P. Ravn Aalborg.
Chapter 15 Multithreading F Threads Concept  Creating Threads by Extending the Thread class  Creating Threads by Implementing the Runnable Interface.
The Use of Foreign Language Teaching Techniques in the Computer Science Laboratory to Support Oral Presentation and Group Work.
Copyright ©: Nahrstedt, Angrave, Abdelzaher, Caccamo1 Timers and Clocks II.
Spring/2002 Distributed Software Engineering C:\unocourses\4350\slides\DefiningThreads 1 Inter-Thread communication State dependency: Guarded Methods.
Instructore: Tasneem Darwish1 University of Palestine Faculty of Applied Engineering and Urban Planning Software Engineering Department Concurrent and.
Threads.
Copyright ©: Nahrstedt, Angrave, Abdelzaher1 Timers and Clocks.
1 G53SRP: Introduction to Real Time Specification for Java (RTSJ) Chris Greenhalgh School of Computer Science Including material © Andy Wellings from his.
EEL The Real-Time Specification for Java (1)
11 G53SRP: Deadline misses and cost over-runs in RTSJ Chris Greenhalgh School of Computer Science.
1 G53SRP: Java Concurrency Control (1) - synchronisation Chris Greenhalgh School of Computer Science.
CS2110: SW Development Methods Inheritance in OO and in Java Part 2: Topics: Forms of inheritance Interfaces in Java.
1 G53SRP: Clocks and Time in Java Chris Greenhalgh School of Computer Science.
Threads. Story so far  Our programs have consisted of single flows of control Flow of control started in the first statement of method main() and worked.
Concurrency Control 1 Fall 2014 CS7020: Game Design and Development.
111 G53SRP: RTSJ Memory Areas Chris Greenhalgh School of Computer Science.
Copyright ©: Nahrstedt, Angrave, Abdelzaher, Caccamo1 Timers and Clocks II.
SurfaceView.
SNU IDB Lab. Ch4. Performance Measurement © copyright 2006 SNU IDB Lab.
Threads in Java1 Concurrency Synchronizing threads, thread pools, etc.
COSC 3407: Operating Systems Lecture 9: Readers-Writers and Language Support for Synchronization.
Towards a Naming & Binding Framework for ObjectWeb Sacha Krakowiak Univ. of Grenoble & INRIA.
1 Java Programming Java Programming II Concurrent Programming: Threads ( I)
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.
1 G53SRP: Java Concurrency Control (2) – wait/notify Chris Greenhalgh School of Computer Science.
© 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.
Ch6. Flow of Time Ch7. Getting Hold of Memory 홍원의.
Threads.
Chapter 13: Multithreading
G53SRP: Real Time Threads in RTSJ (part I)
G53SRP: Asynchronous Events in RTSJ
null, true, and false are also reserved.
G53SRP: Resource Sharing Issues
Principles of Software Development
Time Sources and Timing
Chapter 15 Multithreading
Threads.
Presentation transcript:

11 G53SRP: Clocks and Times in RTSJ Chris Greenhalgh School of Computer Science

22 Contents OverviewOverview Time classesTime classes –HighResolutionTime, AbsoluteTime, RelativeTime Clock classClock class ExampleExample SummarySummary Book: Wellings ch. 9Book: Wellings ch. 9

3 Class Overview 3 > javax.realtime. HighResolutionTime javax.realtime. AbsoluteTime javax.realtime. RelativeTime extends javax.realtime. Clock has javax.realtime. RationalTime extends Deprecated (do not use)

4 HighResolutionTime class package javax.realtime; public abstract class HighResolutionTime { // nano-second resolution times public long getMilliseconds(); public int getNanoseconds(); public void set(long millis, int nanos); public Clock getClock(); // various utility/conversion methods … // high-res wait public static waitForObject(Object target, HighResolutionTime time) throws InterruptedException ; } Every time is based on a clock (it came from)

5 AbsoluteTime Class package javax.realtime; public class AbsoluteTime extends HighResolutionTime { // cons (also others) public AbsoluteTime(long millis, int nanos); // various utility conversions including… public AbsoluteTime add(RelativeTime time); public RelativeTime subtract(AbsoluteTime time); public AbsoluteTime subtract(RelativeTime time); … } Time is offset from clock-specific EpochTime is offset from clock-specific Epoch –Default clock Epoch is midnight 1 st January 1970 GMT

6 RelativeTime class package javax.realtime; public class RelativeTime extends HighResolutionTime { // cons (also others) public RelativeTime(long millis, int nanos); // various utility conversions including… public RelativeTime add(RelativeTime time); public RelativeTime subtract(RelativeTime time); … } Note: still based on a Clock, e.g. for resolution (and accuracy)

7 Clock class package javax.realtime; public abstract class Clock { // standard system realtime clock public static Clock getRealtimeClock(); public AbsoluteTime getTime(); public RelativeTime getResolution(); // offset of this clock vs Epoch public RelativeTime getEpochOffset(); … } Note: may be other clocks without date, e.g. timer from power-on of system. If so, this throws UnsupportedOperationException

8 E.g. RTClock.java … Clock clock = Clock.getRealtimeClock(); AbsoluteTime time = clock.getTime(); AbsoluteTime newTime = clock.getTime(); RelativeTime elapsed = newTime.subtract(time); RelativeTime delay = new RelativeTime(1000,0); AbsoluteTime delayTime = newTime.add(delay); …

9 E.g. RTSleep.java … Clock clock = Clock.getRealtimeClock(); AbsoluteTime time = clock.getTime(); RelativeTime delay = new RelativeTime(1000,0); AbsoluteTime delayTime = time.add(delay); RealtimeThread.sleep(delay); RealtimeThread.sleep(delayTime); … Relative sleep i.e. delay ms/ns Absolute sleep i.e. until delayTime

10 Summary RTSJ supports nanosecond-resolution times – –HighResolutionTime – –(but Clocks probably won’t be nanosecond granularity) Can be used for – –Wait variant ( HighResolutionTime.waitForObject ) – –Sleep variant ( RealtimeThread.sleep ) – –Other time specifications (e.g. ReleaseProperties – later) Distinguishes relative and absolute times – –AbsoluteTime & RelativeTime – –Includes various utility manipulation operations Supports at least one real-time clock – –Clock.getRealtimeClock() – –May support more