© Andy Wellings, 2004 Roadmap  Introduction  Concurrent Programming  Communication and Synchronization  Completing the Java Model  Overview of the.

Slides:



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

Real-Time Systems and Programming Languages © Alan Burns and Andy Wellings Chapter 12: Programming Schedulable Systems.
Concurrent Programming Abstraction & Java Threads
CPE555A: Real-Time Embedded Systems
Real- time Dynamic Voltage Scaling for Low- Power Embedded Operating Systems Written by P. Pillai and K.G. Shin Presented by Gaurav Saxena CSE 666 – Real.
CSE 522 Real-Time Scheduling (4)
© Andy Wellings, 2004 Roadmap  Introduction  Concurrent Programming  Communication and Synchronization  Completing the Java Model  Overview of the.
Silberschatz, Galvin and Gagne ©2009Operating System Concepts – 8 th Edition Chapter 4: Threads.
Tasks Periodic The period is the amount of time between each iteration of a regularly repeated task Time driven The task is automatically activated by.
© 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.
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.
© Andy Wellings, 2004 Roadmap  Introduction  Concurrent Programming  Communication and Synchronization  Completing the Java Model  Overview of the.
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.
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.
© Andy Wellings, 2004 Roadmap  Introduction  Concurrent Programming  Communication and Synchronization  Completing the Java Model  Overview of the.
© 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.
© Andy Wellings, 2004 Roadmap  Introduction  Concurrent Programming  Communication and Synchronization  Completing the Java Model  Overview of the.
Enhancing the Platform Independence of the Real-Time Specification for Java Andy Wellings, Yang Chang and Tom Richardson University of York.
By Group: Ghassan Abdo Rayyashi Anas to’meh Supervised by Dr. Lo’ai Tawalbeh.
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.
Chapter 4: Threads READ 4.1 & 4.2 NOT RESPONSIBLE FOR 4.3 &
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.
© Andy Wellings, 2004 Roadmap  Introduction  Concurrent Programming  Communication and Synchronization  Completing the Java Model  Overview of the.
14.1 Silberschatz, Galvin and Gagne ©2009 Operating System Concepts with Java – 8 th Edition Chapter 4: Threads.
Silberschatz, Galvin and Gagne ©2009 Operating System Concepts – 8 th Edition, Chapter 4: Threads.
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.
Scheduling policies for real- time embedded systems.
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.
Java Threads. What is a Thread? A thread can be loosely defined as a separate stream of execution that takes place simultaneously with and independently.
Real-Time Scheduling CS4730 Fall 2010 Dr. José M. Garrido Department of Computer Science and Information Systems Kennesaw State University.
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.
EEL The Real-Time Specification for Java (1)
11 G53SRP: Deadline misses and cost over-runs in RTSJ Chris Greenhalgh School of Computer Science.
ICS 313: Programming Language Theory Chapter 13: Concurrency.
Undergraduate course on Real-time Systems Linköping 1 of 45 Autumn 2009 TDDC47: Real-time and Concurrent Programming Lecture 5: Real-time Scheduling (I)
EEL Real-time Java part 2. EEL Acknowledgements All the lecture slides were adopted from the slides of Andy Wellings.
CSCI1600: Embedded and Real Time Software Lecture 24: Real Time Scheduling II Steven Reiss, Fall 2015.
Thread Scheduling and Dispatching Maung Aung Han Marc E. Loy Jihua Zhong CIS 642: Seminar in Real-time Systems Instructor: Professor Insup Lee.
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.
Lecture 6: Real-Time Scheduling
Java Programming Language
Wayne Wolf Dept. of EE Princeton University
Multithreaded Programming in Java
G53SRP: Real Time Threads in RTSJ (part I)
Real-time Software Design
G53SRP: Asynchronous Events in RTSJ
Multithreading.
Real Time Java : Synchronization
Concurrent programming
The End Of The Line For Static Cyclic Scheduling?
Presentation transcript:

© Andy Wellings, 2004 Roadmap  Introduction  Concurrent Programming  Communication and Synchronization  Completing the Java Model  Overview of the RTSJ  Memory Management  Clocks and Time  Scheduling and Schedulable Objects  Introduction to fixed priority scheduling  Overview of the RTSJ model  Continued  Asynchronous Events and Handlers  Real-Time Threads  Asynchronous Transfer of Control  Resource Control  Schedulability Analysis  Conclusions

© Andy Wellings, 2004 Scheduling and Schedulable Objects Lecture aims  To review the parameter classes in detail  To consider alternative schedulers

© Andy Wellings, 2004 The Parameter Classes  Each schedulable objects has several associated parameters  These parameters are tightly bound to the schedulable object and any changes to the parameters can have an immediate impact on the scheduling of the object or any feasibility analysis performed by its scheduler  Each schedulable object can have only one set of parameters associated with it  However, a particular parameter class can be associated with more than one schedulable object  In this case, any changes to the parameter objects affects all the schedulable objects bound to that parameter

© Andy Wellings, 2004 Release Parameters I  Release parameters characterize  how often a schedulable object runs  the worst case processor time needed for each run  a relative deadline by which each run must have finished  There is a close relationship between the actions that a schedulable object can perform and its release parameters  E.g., the RealtimeThread class has a method called waitForNextPeriod ; however a real-time thread object can only call this methods if it has PeriodicParameters associated with it  This may seem a little counter intuitive; the main advantage of is that it allows a thread to change its release characteristics and hence adapt its behavior

© Andy Wellings, 2004 The ReleaseParameter Class public class ReleaseParameters { protected ReleaseParameters(); protected ReleaseParameters(RelativeTime cost, RelativeTime deadline, AsyncEventHandler overrunHandler, AsyncEventHandler missHandler); public RelativeTime getCost(); public AsyncEventHandler getCostOverrunHandler(); public RelativeTime getDeadline(); public AsyncEventHandler getDeadlineMissHandler(); // methods to set the above public boolean setIfFeasible(RelativeTime cost, RelativeTime deadline); }

© Andy Wellings, 2004 Release Parameters II  The minimum information that a scheduler will need for feasibility analysis is the cost and deadline  cost : a measure of how much CPU time the scheduler should assume that the scheduling object will require for each release  This is dependent on the processor on which it is being executed; consequently, any programmer-defined value will not be portable  deadline : the time from a release that the scheduler object has to complete its execution  overrunHandler : the asynchronous event handler that should be released if the schedulable object overruns its cost value on a particular release  missHandler is released if the schedulable object is still executing when its deadline arrives

© Andy Wellings, 2004 Cost Enforcement If cost monitoring is supported:  the RTSJ requires that the priority scheduler gives a schedulable object a CPU budget of no more than its cost value on each release  if a schedulable objects overrun its cost budget, it is automatically descheduled (made not eligible for execution) immediately  it will not be re-scheduled until either its next release occurs (in which case its budget is replenished) or its associated cost value is increased.

© Andy Wellings, 2004 The PeriodicParameters Class  For schedulable objects which are released on a regular basis  The start time can be an AbsoluteTime or a RelativeTime and indicates when the schedulable object should be first released  For a real-time thread, the actual first release time is given by  if start is a RelativeTime value Time of invocation of start method + start  if start is an AbsoluteTime value Max of (Time of invocation of start method, start )  A similar formula can be given for an asynchronous event handler  The deadline for a schedulable object with periodic parameters is measured from the time that it is released not when it is started or fired

© Andy Wellings, 2004 The PeriodicParameters Class package javax.realtime; public class PeriodicParameters extends ReleaseParameters { // constructors public PeriodicParameters( HighResolutionTime start, RelativeTime period, RelativeTime cost, RelativeTime deadline, AsyncEventHandler overrunHandler, AsyncEventHandler missHandler); // methods public RelativeTime getPeriod(); public HighResolutionTime getStart(); public void setPeriod(RelativeTime period); public void setStart(HighResolutionTime start); public boolean setIfFeasible(RelativeTime period, RelativeTime cost, RelativeTime deadline); }

© Andy Wellings, 2004 The AperiodicParameters Class I public class AperiodicParameters extends ReleaseParameters { // constructors public AperiodicParameters( RelativeTime cost, RelativeTime deadline, AsyncEventHandler overrunHandler, AsyncEventHandler missHandler); public boolean setIfFeasible(RelativeTime cost, RelativeTime deadline);... } The deadline of an aperiodic schedulable object can never be guaranteed, why? Hence, the deadline attribute should be interpreted as a target completion time rather than a strict deadline.

© Andy Wellings, 2004 The AperiodicParameters Class II  Schedulable object with aperiodic parameters are released at irregular intervals  When an aperiodic schedulable object is released for the first time, it becomes runnable and is scheduled for execution.  Before it completes its execution, it may be released again.  It is necessary for an implementation to queue the release events to ensure that they are not lost  The programmer is able to specify the length of this queue and the actions to be taken if the queue overflows

© Andy Wellings, 2004 The AperiodicParameters Class III public class AperiodicParameters extends ReleaseParameters {... public static final String arrivalTimeQueueOverflowExcept; public static final String arrivalTimeQueueOverflowIgnore; public static final String arrivalTimeQueueOverflowReplace; public static final String arrivalTimeQueueOverflowSave;... }

© Andy Wellings, 2004 The AperiodicParameters Class IV public class AperiodicParameters extends ReleaseParameters {... public String getArrivalTimeQueueOverflowBehaviour(); public void setArrivalTimeQueueOverflowBehaviour( String behaviour); public int getArrivalTimeQueueOverflowLength(); public void setArrivalTimeQueueOverflowLength( int initial); }

© Andy Wellings, 2004 Sporadic Parameters  Schedulable object with sporadic parameters are released at irregular intervals but the scheduler can assume that two releases will always occur greater than or equal to a minimum inter-arrival time  At run time, the scheduler must check for violation of this constraint and take some corrective action  When a sporadic schedulable object is released for the first time, it becomes runnable and is scheduled for execution.  Before it completes its execution, it may be released again.  As with aperiodic schedulable objects, it is necessary for an implementation to queue the release events to ensure that they are not lost

© Andy Wellings, 2004 The SporadicParameters Class I public class SporadicParameters extends AperiodicParameters { public static final String mitViolationExcept; public static final String mitViolationIgnore; public static final String mitViolationReplace; public static final String mitViolationSave;

© Andy Wellings, 2004 The SporadicParameters Class II //constructors public SporadicParameters(RelativeTime minInterarrival, RelativeTime cost, RelativeTime deadline, AsyncEventHandler overrunHandler, AsyncEventHandler missHandler); // methods public String getMitViolationBehaviour(); public void getMitViolationBehaviour(String behaviour); public RelativeTime getMinimumInterarrival(); public void getMinimumInterarrival ( RelativeTime interval); public boolean setIfFeasible( RelativeTime interarrival, RelativeDeadline cost, RelativeTime deadline); }

© Andy Wellings, 2004 Example I  Consider a sporadic event handler which is released by a call to the fire method of its associated asynchronous event  Suppose that the maximum length of the queue is 3 and the implementation is simply keeping track of the time of the fire request  Assume the MIT is 2  At some point in time the queue is:

© Andy Wellings, 2004 Example II  Consider a new event occurring at X+12:  throw an exception: ResourceLimitError is thrown on the offending call of the fire method; note that even if more than one handler is associated with the event, the exception is thrown if one or more of them suffer a queue overflow  ignore the fire: the call to fire the asynchronous event is ignored for that handler  replace the last release: the last release event is overwritten with the new release event.  save the request: the queue is lengthened. XX+4X+12

© Andy Wellings, 2004 Example III  The available actions on violation of the minimum inter-arrival time are similar (assume a new requests arrives at X+5)  throw an exception: the exception MITViolationException is thrown on the offending call of the fire method  ignore the fire: the call to fire the event is ignored  replace the last request: the last request is overwritten with the new request; the new queue becomes  save the request: the request is saved but the time between the request is set to the minimum inter-arrival time: note: the deadline of the last release is still relative to X+5

© Andy Wellings, 2004 Scheduling Parameters public abstract class SchedulingParameters { // constructors public SchedulingParameters(); }

© Andy Wellings, 2004 Priority Parameters public class PriorityParameters extends SchedulingParameters { // constructors public PriorityParameters(int priority); // methods public int getPriority(); public void setPriority(int priority); public String toString(); }

© Andy Wellings, 2004 Importance Parameters public class ImportanceParameters extends PriorityParameters { // constructors public ImportanceParameters( int priority, int importance); // methods public int getImportance(); public void setImportance(int importance); public jString toString(); }

© Andy Wellings, 2004 Processing Group Parameters  See specification

© Andy Wellings, 2004 Alternative Schedulers  Most RT OSs support fixed priority pre-emptive based scheduling with no online feasibility analysis  As more computers become embedded, there is need for more flexible scheduling  In general, there are three approaches to getting flexible scheduling:  Pluggable scheduler: the system provides a framework from within which different schedulers can be plugged in  Application-defined schedulers: the system notifies the application every time an event occurs which requires a scheduling decision to be taken; the application then informs the system which thread should execute next  Implementation-defined schedulers: an implementation is allowed to define alternative schedulers; typically this would require the underlying operating system (virtual machine, in the case of Java) to be modified

© Andy Wellings, 2004 RTSJ and Alternative Schedulers  The RTSJ adopts the implementation-defined schedulers approach  Applications can determine dynamically whether the real- time JVM on which it is executing has a particular scheduler  This is the least portable approach, as an application cannot rely of any particular implementation-defined scheduler being supported

© Andy Wellings, 2004 Flexible Scheduling and Priority-based Systems  Priority-based scheduling is very flexible if schedulable objects can change their priority (as they can in the RTSJ)  Much can be done which is portable by allowing the application to implement its own scheduling policy on top of the PriorityScheduler

© Andy Wellings, 2004 EDF Scheduler PriorityScheduler publicEdfScheduler(int,,, ) // low,medium, high, maxSchedObjects public synchronized voiddeschedule() public synchronized voidreschedule() protected synchronized booleanaddToFeasibility(Schedulable) public synchronized booleanchangeIfFeasible(Schedulable, ReleaseParameters MemoryParameters) public synchronized voidfireSchedulable(Schedulable) public synchronized booleanisFeasible() protected synchronized booleanremoveFromFeasibility(Schedulable) publicjava.lang.String getPolicyName()

© Andy Wellings, 2004 EDF Scheduler Approach I  All objects which are to be scheduled by the EdfScheduler run at one of three priority levels: low, medium and high  When schedulable objects are released, they are released at the high priority level; they immediately call the reschedule method to announce themselves to the EdfScheduler  The EdfScheduler keeps track of the schedulable object with the closest absolute deadline; this object has its priority set to the medium level  When a call is made to reschedule, the EdfScheduler compares the deadline of the calling object with that of its closest deadline; if the caller has a closer deadline, the object with the current closest deadline has its priority set to low and the caller has its priority set to medium

© Andy Wellings, 2004 EDF Scheduler Approach II  After the end of each release, a schedulable object calls deschedule  The EdfScheduler sets caller’s priority to high (ready for the next release), and then scans its list of schedulable objects to find the one with the closest deadline  It sets the priority of this object to medium  The constructor for the class gives the appropriate priority values for low, medium and high  It also contains the maximum number of schedulable objects to be scheduled by the scheduler

© Andy Wellings, 2004 EDF Example I  Consider the execution of three real-time threads (T1, T2 and T3) which are released at times t1, t2, and t3 respectively (where t1 < t2 < t3)  T2 has the closest deadline, followed by T3 and T1.

© Andy Wellings, 2004 EDF Example II time priority t1t2 t3 High Medium Low T1T2T3 T1T2 T1 T1, T3 T3 T1 call to deschedule call to reschedule T1T2T3T2T3T1 Running thread

© Andy Wellings, 2004 EDF Example III  With this approach, a thread with a longer deadline will execute in preference to a shorter deadline thread but only for a small limited time when it is released  This can be ensured by encapsulating the calls to reschedule and deschedule

© Andy Wellings, 2004 EDF Example IV

© Andy Wellings, 2004 Summary  The parameter classes capture the properties which affect scheduling  The RTSJ provides a framework for alternative implementation- defined schedulers

© Andy Wellings, 2004 Further Reading and Exercises