EEL 6897 1 Real-time Java part 2. EEL 6897 2 Acknowledgements All the lecture slides were adopted from the slides of Andy Wellings.

Slides:



Advertisements
Similar presentations
Introduction to Embedded Systems Resource Management - III Lecture 19.
Advertisements

Priority INHERITANCE PROTOCOLS
Concurrency: Deadlock and Starvation Chapter 6. Deadlock Permanent blocking of a set of processes that either compete for system resources or communicate.
© Andy Wellings, 2004 Roadmap  Introduction  Concurrent Programming  Communication and Synchronization  Completing the Java Model  Overview of the.
Concurrency Important and difficult (Ada slides copied from Ed Schonberg)
© Andy Wellings, 2004 Roadmap  Introduction  Concurrent Programming  Communication and Synchronization  Completing the Java Model  Overview of the.
CSI 3120, Exception handling, page 1 Exception and Event Handling Credits Robert W. Sebesta, Concepts of Programming Languages, 8 th ed., 2007 Dr. Nathalie.
Scheduling Theory ITV Real-Time Systems Anders P. Ravn Aalborg University March 2007.
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.
Process Description and Control Module 1.0. Major Requirements of an Operating System Interleave the execution of several processes to maximize processor.
© 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.
Concurrency in Ada What concurrency is all about Relation to operating systems Language facilities vs library packages POSIX threads Ada concurrency Real.
© 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.
Introduction to Operating Systems – Windows process and thread management In this lecture we will cover Threads and processes in Windows Thread priority.
© Andy Wellings, 2004 Roadmap  Introduction  Concurrent Programming  Communication and Synchronization  Completing the Java Model  Overview of the.
Chapter 13 Embedded Systems
© Andy Wellings, 2003 Roadmap  Introduction  Concurrent Programming  Communication and Synchronization  Completing the Java Model  Overview of the.
CprE 458/558: Real-Time Systems
© 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.
Java How to Program, 9/e CET 3640 Professor: Dr. Reyes Álamo © Copyright by Pearson Education, Inc. All Rights Reserved.
©Ian Sommerville 2004Software Engineering, 7th edition. Chapter 15 Slide 1 Real-time Systems 1.
Introduction to Embedded Systems
Real-Time Software Design Yonsei University 2 nd Semester, 2014 Sanghyun Park.
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.
1 소프트웨어공학 강좌 Chap 11. Real-time software Design - Designing embedded software systems whose behaviour is subject to time constraints -
Threads in Java. History  Process is a program in execution  Has stack/heap memory  Has a program counter  Multiuser operating systems since the sixties.
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.
EEL Software development for real-time engineering systems.
Real-Time Systems Design1 Priority Inversion When a low-priority task blocks a higher-priority one, a priority inversion is said to occur Assume that priorities:
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.
Enhancements to Java for Real Time Systems Theresa Dsena CSE Fall 2006 Prof. Ganesan.
CE Operating Systems Lecture 11 Windows – Object manager and process management.
Reference: Ian Sommerville, Chap 15  Systems which monitor and control their environment.  Sometimes associated with hardware devices ◦ Sensors: Collect.
Slide 1 Chapter 11 Real –time Software Designs. Slide 2 Real-time systems l Systems which monitor and control their environment l Inevitably associated.
Prepare by : Ihab shahtout.  Overview  To give an overview of fixed priority schedule  Scheduling and Fixed Priority Scheduling.
Instructore: Tasneem Darwish1 University of Palestine Faculty of Applied Engineering and Urban Planning Software Engineering Department Concurrent and.
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)
©Ian Sommerville, Robin Abraham 2004CS 361, Summer 2004 Slide 1 Real-time Software Design.
15.1 Threads and Multi- threading Understanding threads and multi-threading In general, modern computers perform one task at a time It is often.
Real-time Software Design King Saud University College of Computer and Information Sciences Department of Computer Science Dr. S. HAMMAMI.
111 G53SRP: RTSJ Memory Areas Chris Greenhalgh School of Computer Science.
CSCI1600: Embedded and Real Time Software Lecture 18: Real Time Languages Steven Reiss, Fall 2015.
Introduction to Embedded Systems Rabie A. Ramadan 5.
Thread Scheduling and Dispatching Maung Aung Han Marc E. Loy Jihua Zhong CIS 642: Seminar in Real-time Systems Instructor: Professor Insup Lee.
Silberschatz, Galvin and Gagne ©2011 Operating System Concepts Essentials – 8 th Edition Chapter 2: The Linux System Part 3.
11 G53SRP: Feasibility analysis Chris Greenhalgh School of Computer Science.
1.  System Characteristics  Features of Real-Time Systems  Implementing Real-Time Operating Systems  Real-Time CPU Scheduling  An Example: VxWorks5.x.
Undergraduate course on Real-time Systems Linköping University TDDD07 Real-time Systems Lecture 2: Scheduling II Simin Nadjm-Tehrani Real-time Systems.
© 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.
Unit - I Real Time Operating System. Content : Operating System Concepts Real-Time Tasks Real-Time Systems Types of Real-Time Tasks Real-Time Operating.
1 Threads in Java Jingdi Wang. 2 Introduction A thread is a single sequence of execution within a program Multithreading involves multiple threads of.
Embedded Real-Time Systems Processing interrupts Lecturer Department University.
Real-time Software Design
REAL-TIME OPERATING SYSTEMS
G53SRP: Real Time Threads in RTSJ (part I)
Threads CSSE 332 Operating Systems Rose-Hulman Institute of Technology
Real-time Software Design
CSCI1600: Embedded and Real Time Software
G53SRP: Asynchronous Events in RTSJ
Chapter 2: The Linux System Part 3
Real Time Java : Synchronization
CSCI1600: Embedded and Real Time Software
Presentation transcript:

EEL Real-time Java part 2

EEL Acknowledgements All the lecture slides were adopted from the slides of Andy Wellings

EEL Memory Management Classes MemoryArea HeapMemory ImmortalMemory ScopedMemory LTMemoryVTMemory SizeEstimator MemoryParameters GarbageCollector RTSJ class RTSJ abstract class

EEL Time Values and Clocks HighResolutionTime RationalTime AbsoluteTime RelativeTime Clock relativeTo standard Java interface RTSJ class RTSJ abstract class

EEL Scheduling in Java Java offers no guarantees that the highest priority runnable thread will always be the one executing This is because a JVM may be relying on a host operating system to support its threads; some of these systems may not support pre-emptive priority-based scheduling Java only defines 10 priority levels and an implementation is free to map these priorities onto a more restricted host operating system’s priority range if necessary The weak definition of scheduling and the restricted range of priorities means that Java programs lacks predictability and, hence, Java’s use for real-time systems implementation is severely limited

EEL Schedulable Objects RTSJ generalizes the entities that can be scheduled from threads to the notion of schedulable objects A schedulable object is one which implements the Schedulable interface Each schedulable object must also indicate its specific –release requirement (that is, when it should become runnable), –memory requirements (for example, the rate at which the object will allocate memory on the heap) –scheduling requirements (for example, the priority at which it should be scheduled)

EEL Release Parameters Scheduling theories often identify three types of releases: –periodic (released on a regular basis), –aperiodic (released at random) and –sporadic (released irregularly but with a minimum time between each release) All release parameters have a cost and a deadline relative time values –cost is the amount of cpu time needed every release –deadline is the time at which the current release must have finished PeriodicParameters also include the start time for the first release and the time interval (period) between releases. SporadicParameter include the minimum inter-arrival time between releases For aperiodic schedulable objects, it is possible to limit the amount of time the schedules gives them in a particular period using ProcessingGroupParameters

EEL Scheduling Parameters Scheduling parameters are used by a scheduler to determine which object is currently the most eligible for execution The abstract class SchedulingParameters provides the root class from which a range of possible scheduling criteria can be expressed The RTSJ defines only one criterion which is based on priority High numerical values for priority represent high execution eligibilities. ImportanceParameters allow an additional numerical scheduling metric to be assigned; it is a subclass of the PriorityParameters

EEL Schedulers The scheduler is responsible for scheduling its associate schedulable objects RTSJ explicitly supports priority-based scheduling via the PriorityScheduler (a fixed pre-emptive priority-based scheduling with 28 unique priority levels) Scheduler is an abstract class with PriorityScheduler a defined subclass This allows an implementation to provide, say, an Earliest-Deadline-First scheduler Any attempt by the application to set the scheduler for its threads has to be checked to ensure that it has the appropriate security permissions

EEL Scheduling-related Classes ReleaseParameters PeriodicParameters AperiodicParameters SporadicParameters SchedulingParameters ProcessingGroupParametersMemoryParameters ImportanceParameters Scheduler PriorityParameters PriorityScheduler uses RealtimeSecurity checks

EEL Meeting Deadlines A real-time system needs to –predict whether a set of application objects will meet their deadlines, and –report a missed its deadline, a cost overrun, or minimum inter-arrival time violation For some systems it is possible to predict offline whether the application will meet its deadline For other systems, some form of on-line analysis is required The RTSJ provide the hooks for on-line analysis Irrespective of whether or how prediction has been formed, it is necessary to report overruns etc The RTSJ provides an asynchronous event handling mechanism for this purpose

EEL Real-Time Threads A schedulable object More than an extension of java.lang.thread No heap version ensure no access to the heap and therefore independence from garbage collection

EEL Real-time Threads

EEL Asynchronous Event Handling Threads and real-time threads are the appropriate abstractions to use to represent concurrent activities that have a significant life history It is also necessary to respond to events that happen asynchronously to a thread’s activity These events may be happenings in the environment of an embedded system or notifications received from internal activities within the program It always possible to have extra threads which wait for these events but this is inefficient From a real-time perspective, events may require their handlers to respond within a deadline; hence, more control is needed over the order in which events are handled The RTSJ generalizes Java event handlers to be schedulable entities

EEL Async Events and their Handlers

EEL Handlers and Real-Time Threads In practice, the real-time JVM will usually dynamically associate an event handler with a real-time thread when the handler is released for execution To avoid this overhead, it is possible to specify that the handler must be permanently bound to a real-time thread Each AsyncEvent can have one or more handlers and the same handler can be associated with more than one event When the event occurs, all the handlers associated with the event are released for execution according to their SchedulingParameters

EEL More on Async Events Asynchronous events can be associated with interrupts or POSIX signals (if supported by the underlying operating system) or they can be linked to a timer The timer will cause the event to fire when a specified time (relative to a particular clock) expires This can be a one shot firing or a periodic firing

EEL AsynEvent related Classses

EEL Asynchronous Transfer of Control Asynchronous events allow the program to respond in a timely fashion to a condition that has been detected by the program or the environment They do not allow a particular schedulable object to be directly informed In many applications, the only form of asynchronous transfer of control that a real-time thread needs is a request for it to terminate itself Consequently, languages and operating systems typically provide a kill or abort facility For real-time systems, this approach is too heavy handed; instead what is required if for the schedulable object to stop what it is currently doing and to begin executing an alternative algorithm

EEL ATC I In standard Java, it is the interrupt mechanism which attempts to provide a form of asynchronous transfer of control The mechanism does not support timely response to the “interrupt” Instead, a running thread has to poll for notification This delay is deemed unacceptable for real-time systems For these reasons, the RTSJ provides an alternative approach for interrupting a schedulable object, using asynchronous transfer of control (ATC)

EEL ATC II The ATC model is based on the following principles A schedulable object must explicitly indicate that it is prepared to allow an ATC to be delivered By default, schedulable object will have ATCs deferred The execution of synchronized methods and statements always defers the delivery of an ATC An ATC is a non-returnable transfer of control

EEL ATC III The RTSJ ATC model is integrated with the Java exception handling facility An AsynchronouslyInterruptedException (AIE) class defines the ATC event A method that is prepared to allow an AIE indicate so via a throws AsynchronouslyInterruptedException in its declaration The Interruptible interface provides the link between the AIE class and the object executing an interruptible method

EEL The ATC Classes and Interface

EEL Synchronization Key to predicting the behaviour of multi-threaded programs is understanding how threads (and other schedulable objects) communicate and synchronize Java provides mutually exclusive access to shared data via a monitor-like construct All synchronization mechanisms which are based on mutual exclusion suffer from priority inversion The problem of priority inversion and its solution priority inheritance is now a well-researched area of real-time systems There are a variety of priority inheritance algorithms; the RTSJ explicitly support two: simple priority inheritance and priority ceiling emulation inheritance (sometimes called immediate ceiling priority inheritance or priority protect inheritance protocol)

EEL RTSJ Classes for Priority Inheritance

EEL Priority Inheritance and Garbage Collection If real-time threads want to communicate with non real-time threads then interaction with garbage collection must be considered It is necessary to try to avoid the situation where a non real-time thread has entered into a mutual exclusion zone shared with a real-time thread The actions of the non real-time thread results in garbage collection being formed The real-time thread then pre-empts the garbage collector but is unable to enter the mutual exclusion zone It must now wait for the garbage collection to finish and the non real-time thread to leave the zone

EEL Wait Free Communication One way of avoiding unpredictable interactions with the garbage collector is to provide a non-blocking communication mechanism for use between non real- time threads and real-time threads The RTSJ provides three wait-free non blocking classes to help facilitate this communication: –WaitFreeWriteQueue: a bounded buffer; the read operation is synchronized; the write operation is not synchronized –WaitFreeReadQueue: a bounded buffer; the write operation on the buffer is synchronized; the read operation is not; the reader can request to be notified (via an asynchronous event) when data arrives –WaitFreeDequeue: a bounded buffer which allows both blocking and non-blocking read and write operations

EEL Wait Free Classses WaitFreeDequeueWaitFreeWriteQueueWaitFreeReadQueue uses AsyncEventHandler uses

EEL Physical and Raw Memory Classes Mechanisms that allow objects to be placed into areas of memory that have particular properties or access requirements; eg DMA memory, shared memory –the RTSJ provides extensions of the MemoryArea to provide the physical memory counterparts to the linear-time, variable-time and immortal memory classes Mechanisms that allow the programmer to access raw memory locations that are being used to interface to the outside world; for example memory-mapped input output device registers –the RTSJ provides classes which can access raw memory in terms of reading and writing Java variables or arrays of primitive data types (int, long, float etc.) The implementation of both these physical and raw memory classes can assume the existence of a PhysicalMemory-Manager class and the PhysicalMemoryTypeFilter interface

EEL Physical and Raw Memory Classes II PhysicalMemoryManager ImmortalPhysicalMemory ScopedMemory PhysicalMemoryTypeFilter LTPhysicalMemoryVTPhysicalMemory RawMemoryFloatAccess RawMemoryAccess uses AsyncEventHandler uses registers uses RealtimeSecurity uses Implementation-defined implements uses MemoryArea

EEL NIST Requirements Review I Fixed priority and round robin scheduling — RTSJ supports fixed priority scheduler and allows implementations to provide other schedulers Mutual exclusion locking (avoiding priority inversion) — the RTSJ supports priority inheritance algorithms of synchronized objects and requires all RTSJ implementations to avoid priority inversion Inter-thread communication (e.g. semaphores) — schedulable objects can communicate using the standard Java mechanisms User-defined interrupt handlers and device drivers (including the ability to manage interrupts; e.g., enabling and disabling) — the RTSJ allows interrupts to be associated with asynchronous events Timeouts and aborts on running threads — the RTSJ allows asynchronous transfer of controls via asynchronous exceptions; they can be event triggered or time triggered

EEL NIST Requirements Review II A framework for finding available profiles — the RTSJ does not explicitly address the issues of profiles Distributed real-time systems are not addressed Bounded pre-emption latency on any garbage collection — supported by the GarbageCollector class A well-defined model for real-time Java threads — supported by the RealtimeThread and NoHeapRealtime - Thread classes Communication and synchronization between real-time and non real-time threads — supported by the wait free communication classes Mechanisms for handling internal and external asynchronous events — supported by the AsyncEvent, AsyncEventHandler and POSIXSignalhandler classes

EEL NIST Requirements Review III Asynchronous thread termination — supported by the AsynchronouslyInterruptedException class and the Interruptible interface Mutual exclusion without blocking — supported by the wait free communication classes The ability to determine whether the running thread is real- time or non real-time — supported by the RealtimeThread class A well-define relationship between real-time and non real- time threads — supported by the real-time thread, the scheduling and memory management models Overall then, it can be seen that the RTSJ addresses all the NIST top level requirements in some form or other. It is, however, a little weak in its support for profiles.