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

Slides:



Advertisements
Similar presentations
Operating Systems Semaphores II
Advertisements

Chapter 7 - Resource Access Protocols (Critical Sections) Protocols: No Preemptions During Critical Sections Once a job enters a critical section, it cannot.
1 EE5900 Advanced Embedded System For Smart Infrastructure RMS and EDF Scheduling.
Practice Session 7 Synchronization Liveness Deadlock Starvation Livelock Guarded Methods Model Thread Timing Busy Wait Sleep and Check Wait and Notify.
0 Synchronization Problem Resource sharing –Requires mutual exclusion –Critical section A code section that should be executed mutually exclusively by.
CS5270 Lecture 31 Uppaal, and Scheduling, and Resource Access Protocols CS 5270 Lecture 3.
CprE 458/558: Real-Time Systems (G. Manimaran)1 CprE 458/558: Real-Time Systems Resource Access Control Protocols.
© Andy Wellings, 2004 Roadmap  Introduction  Concurrent Programming  Communication and Synchronization  Completing the Java Model  Overview of the.
Operating System Concepts and Techniques Lecture 12 Interprocess communication-1 M. Naghibzadeh Reference M. Naghibzadeh, Operating System Concepts and.
© 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. José M. Reyes Álamo © Copyright by Pearson Education, Inc. All Rights Reserved.
Scheduling Theory ITV Real-Time Systems Anders P. Ravn Aalborg University March 2007.
© 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.
© 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.
UCDavis, ecs150 Fall /23/2007ecs150, fall Operating System ecs150 Fall 2007 : Operating System #3: Priority Inversion (a paper on the class.
Introduction to Operating Systems – Windows process and thread management In this lecture we will cover Threads and processes in Windows Thread priority.
UCDavis, ecs150 Spring /21/2006ecs150, spring Operating System ecs150 Spring 2006 : Operating System #3: Priority Inversion (paper) Dr. S.
© 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.
© Andy Wellings, 2004 Roadmap  Introduction  Concurrent Programming  Communication and Synchronization  Completing the Java Model  Overview of the.
Spring 2002Real-Time Systems (Shin) Rate Monotonic Analysis Assumptions – A1. No nonpreemptible parts in a task, and negligible preemption cost –
Concurrency - 1 Tasking Concurrent Programming Declaration, creation, activation, termination Synchronization and communication Time and delays conditional.
1 Threads Chapter 4 Reading: 4.1,4.4, Process Characteristics l Unit of resource ownership - process is allocated: n a virtual address space to.
UCDavis, ecs251 Fall /23/2007ecs251, fall Operating System Models ecs251 Fall 2007 : Operating System Models #3: Priority Inversion Dr. S.
© 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.
Parallel Processing (CS526) Spring 2012(Week 8).  Thread Status.  Synchronization in Shared Memory Programming(Java threads ) ◦ Locks ◦ Barriars.
Real-Time Software Design Yonsei University 2 nd Semester, 2014 Sanghyun Park.
Collage of Information Technology University of Palestine Advanced programming MultiThreading 1.
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
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 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.
1 Announcements The fixing the bug part of Lab 4’s assignment 2 is now considered extra credit. Comments for the code should be on the parts you wrote.
Instructore: Tasneem Darwish1 University of Palestine Faculty of Applied Engineering and Urban Planning Software Engineering Department Concurrent and.
Scheduling Lecture 6. What is Scheduling? An O/S often has many pending tasks. –Threads, async callbacks, device input. The order may matter. –Policy,
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)
Multithreading in Java Sameer Singh Chauhan Lecturer, I. T. Dept., SVIT, Vasad.
Chapter 6 – Process Synchronisation (Pgs 225 – 267)
EEL Real-time Java part 2. EEL Acknowledgements All the lecture slides were adopted from the slides of Andy Wellings.
15.1 Threads and Multi- threading Understanding threads and multi-threading In general, modern computers perform one task at a time It is often.
Concurrency Control 1 Fall 2014 CS7020: Game Design and Development.
111 G53SRP: RTSJ Memory Areas Chris Greenhalgh School of Computer Science.
Classes. Constructor A constructor is a special method whose purpose is to construct and initialize objects. Constructor name must be the same as the.
Introduction to Embedded Systems Rabie A. Ramadan 5.
13-1 Chapter 13 Concurrency Topics Introduction Introduction to Subprogram-Level Concurrency Semaphores Monitors Message Passing Java Threads C# Threads.
1.  System Characteristics  Features of Real-Time Systems  Implementing Real-Time Operating Systems  Real-Time CPU Scheduling  An Example: VxWorks5.x.
© 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 Threads in Java Jingdi Wang. 2 Introduction A thread is a single sequence of execution within a program Multithreading involves multiple threads of.
Java Thread Programming
Scheduling and Resource Access Protocols: Basic Aspects
Real-time Software Design
Definitions Concurrent program – Program that executes multiple instructions at the same time. Process – An executing program (the running JVM for Java.
G53SRP: Resource Sharing Issues
Multithreading.
Real Time Java : Synchronization
Conditions for Deadlock
CSE 451: Operating Systems Autumn 2003 Lecture 7 Synchronization
CSE 451: Operating Systems Autumn 2005 Lecture 7 Synchronization
CSE 451: Operating Systems Winter 2003 Lecture 7 Synchronization
CSE 153 Design of Operating Systems Winter 19
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  Asynchronous Events and Handlers  Real-Time Threads  Asynchronous Transfer of Control  Resource Control  Schedulability Analysis  Conclusions

© Andy Wellings, 2004 Resource Sharing Lecture aims:  To introduce the notion of priority inversion  To illustrate simple priority inheritance and priority ceil emulation inheritance  To show the RTSJ Basic Model

© Andy Wellings, 2004 Introduction and Priority Inversion  In Java, communication and synchronization is based on a monitor-like construct  All synchronization mechanisms that are based on mutual exclusion suffer from priority inversion  This is where a low-priority thread (schedulable object) enters into a mutual-exclusion zone (synchronized method or statement) which it shares with a high-priority thread  A medium-priority thread then becomes runnable, pre-empts the low-priority thread and performs a computationally-intensive algorithm  At the start of this algorithm, a high-priority thread becomes runnable, pre-empts the medium-priority thread and tries to enter the mutual-exclusion zone

© Andy Wellings, 2004 Priority Inversion Continued  As the low-priority thread currently occupies the zone, the high- priority thread is blocked  The medium-priority thread then runs, thereby indirectly blocking the progression of the high-priority thread for a potentially unbounded period of time  It is this blocking that makes it very difficult to analyse the timing properties of schedulable objects

© Andy Wellings, 2004 Priority Inversion  To illustrate an extreme example of priority inversion, consider the executions of four periodic threads: a, b, c and d ; and two resources (synchronized objects) : Q and V thread Priority Execution Sequence Release Time a 1 EQQQQE 0 b 2 EE 2 c 3 EVVE 2 d 4 EEQVE 4  Where E is executing for one time unit, Q is accessing resource Q for one time unit, V is is accessing resource V for one time unit

© Andy Wellings, 2004 Example of Priority Inversion thread a b c d Executing Executing with Q locked Preempted Executing with V locked Blocked

© Andy Wellings, 2004 Solutions to Priority Inversion  Priority Inheritance  Non-blocking communication

© Andy Wellings, 2004 Priority Inheritance  If thread p is blocking thread q, then q runs with p 's priority a b c d Process

© Andy Wellings, 2004 The RTSJ Basic Model  Priority inversion can occur whenever a schedulable object is blocked waiting for a resource  In order to limit the length of time of that blocking, the RTSJ requires the following:  All queues maintained by the system to be priority ordered (e.g. the queue of schedulable objects waiting for an object lock Where there is more than one schedulable object in the queue at the same priority, the order should be first-in-first-out (FIFO) Similarly, the queues resulting from calling the wait method in the Object class should be priority ordered  Facilities for the programmer to specify different priority inversion control algorithms By default, the RTSJ requires simple priority inheritance to occur whenever a schedulable object is blocked waiting for a resource

© Andy Wellings, 2004 Monitor Control package javax.realtime; public abstract class MonitorControl { // constructors protected MonitorControl(); // methods public static void setMonitorControl( MonitorControl policy); public static void setMonitorControl( Object monitor, MonitorControl policy); // also get methods }

© Andy Wellings, 2004 Priority Inheritance package javax.realtime; public class PriorityInheritance extends MonitorControl { // methods public static PriorityInheritance instance(); }

© Andy Wellings, 2004 Blocking and Priority Inheritance  If a thread has m critical sections that can lead to it being blocked then the maximum number of times it can be blocked is m  Priority ceiling emulation attempts to reduce the blocking

© Andy Wellings, 2004 Priority Ceiling Emulation  Each thread has a static (base) default priority assigned (perhaps by the deadline monotonic scheme).  Each resource has a static ceiling value defined, this is the maximum priority of the threads that use it.  A thread has a dynamic (active) priority that is the maximum of its own static priority and the ceiling values of any resources it has locked  As a consequence, a thread will only suffer a block at the very beginning of its execution  Once the thread starts actually executing, all the resources it needs must be free; if they were not, then some thread would have an equal or higher priority and the thread ’ s execution would be postponed

© Andy Wellings, 2004 Priority Ceiling Emulation Inheritance a b c d thread

© Andy Wellings, 2004 Priority Ceiling Emulation package javax.realtime; public class PriorityCeilingEmulation extends MonitorControl { // methods public static PriorityCeilingEmulation instance(int ceiling); public int getCeiling();... }

© Andy Wellings, 2004 NOTE  Generally, the code used inside a synchronized method (or statement) should be kept as short as possible, as this will dictate the length of time a low priority schedulable object can block a high one  It is only possible to limit the block if the code doesn’t contain:  unbounded loops,  arbitrary-length blocking operations that hold the lock, for example an arbitrarily-length sleep request

© Andy Wellings, 2004 Ceiling Violations  Whenever a schedulable object calls a synchronized method (statement) in an object which has the Priority- CeilingEmulation policy in force, the real-time virtual machine will check the active priority of the caller  If the priority is greater than the ceiling priority, the uncheck CeilingViolationException is thrown

© Andy Wellings, 2004 Communication between heap-using and no-heap using schedulable objects I  One of the main driving forces behind the RTSJ was to make real-time Java applications more predictable  Hence, schedulable objects which need complete predictability can be defined not to reference the heap  This means that they can pre-empt any garbage collection that might be occurring when the schedulable objects are released.

© Andy Wellings, 2004 Communication between heap-using and no-heap using schedulable objects II  Most large real-time systems will consists of a mixture of heap-using and no- heap schedulable objects  There will be occasions when they need to exchange information  To ensure that no-heap schedulable objects are not indirectly delayed by garbage collection requires  all no-heap schedulable object should have priorities greater than heap-using schedulable objects,  priority ceiling emulation should be used for all shared synchronized objects,  all shared synchronized object should have their memory requirements pre- allocated (or dynamically allocated from scoped or immortal memory areas), and  objects passed in any communication should be primitive types passed by value (int, long, boolean etc) or be from scoped or immortal memory  If these conditions are fulfilled, then there will be no unwanted interference from the garbage collector at inopportune moments

© Andy Wellings, 2004 Summary  Priority inversion is where a high priority thread is blocked by the execution of a lower priority thread  Priority inheritance results in the lower priority thread inheriting the priority of the high priority thread whilst it is blocking the high priority thread  Whilst priority inheritance allows blocking to be bounded, a block still occurs for every critical section  Priority ceiling emulation allows only a single block  The alternative to using priority inheritance algorithms is to use wait free communication (see book)

© Andy Wellings, 2004 Further Reading and Exercises