G53SRP: Resource Sharing Issues

Slides:



Advertisements
Similar presentations
Chapter 7 - Resource Access Protocols (Critical Sections) Protocols: No Preemptions During Critical Sections Once a job enters a critical section, it cannot.
Advertisements

Washington WASHINGTON UNIVERSITY IN ST LOUIS Resource and Resource Access Control Fred Kuhns Applied Research Laboratory Computer Science and Engineering.
Priority INHERITANCE PROTOCOLS
Computer Science 320 Clumping in Parallel Java. Sequential vs Parallel Program Initial setup Execute the computation Clean up Initial setup Create a parallel.
Copyright © 2000, Daniel W. Lewis. All Rights Reserved. CHAPTER 8 SCHEDULING.
1 EE5900 Advanced Embedded System For Smart Infrastructure RMS and EDF Scheduling.
Resource Access Protocols
CprE 458/558: Real-Time Systems (G. Manimaran)1 CprE 458/558: Real-Time Systems Resource Access Control Protocols.
CSE 522 Real-Time Scheduling (3)
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.
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.
Synchronization in Java Fawzi Emad Chau-Wen Tseng Department of Computer Science University of Maryland, College Park.
Definitions Process – An executing program
Wk 2 – Scheduling 1 CS502 Spring 2006 Scheduling The art and science of allocating the CPU and other resources to processes.
Threads Just Java: C10–pages 251- C11–pages 275-
UCDavis, ecs251 Fall /23/2007ecs251, fall Operating System Models ecs251 Fall 2007 : Operating System Models #3: Priority Inversion Dr. S.
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.
Introduction to Embedded Systems
Threading and Concurrency Issues ● Creating Threads ● In Java ● Subclassing Thread ● Implementing Runnable ● Synchronization ● Immutable ● Synchronized.
Real Time Operating Systems Schedulability - Part 3 Course originally developed by Maj Ron Smith 10/24/2015Dr Alain Beaulieu1.
1 Chapter 2.1 : Processes Process concept Process concept Process scheduling Process scheduling Interprocess communication Interprocess communication Threads.
Instructore: Tasneem Darwish1 University of Palestine Faculty of Applied Engineering and Urban Planning Software Engineering Department Concurrent and.
Deadlocks Silberschatz Ch. 7 and Priority Inversion Problems.
1 G53SRP: Introduction to Real Time Specification for Java (RTSJ) Chris Greenhalgh School of Computer Science Including material © Andy Wellings from his.
11 G53SRP: Clocks and Times in RTSJ Chris Greenhalgh School of Computer Science.
1 G53SRP: Java Concurrency Control (1) - synchronisation Chris Greenhalgh School of Computer Science.
Chapter 6 – Process Synchronisation (Pgs 225 – 267)
1 G53SRP: Clocks and Time in Java Chris Greenhalgh School of Computer Science.
Scis.regis.edu ● CS-434: Object-Oriented Programming Using Java Week 8 Dr. Jesús Borrego Adjunct Faculty Regis University 1.
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.
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.
CS333 Intro to Operating Systems Jonathan Walpole.
11 G53SRP: Feasibility analysis Chris Greenhalgh School of Computer Science.
Undergraduate course on Real-time Systems Linköping University TDDD07 Real-time Systems Lecture 2: Scheduling II Simin Nadjm-Tehrani Real-time Systems.
1 G53SRP: Java Concurrency Control (2) – wait/notify Chris Greenhalgh School of Computer Science.
1 G53SRP: Introduction to Real Time Scheduling Chris Greenhalgh School of Computer Science.
Mutual Exclusion -- Addendum. Mutual Exclusion in Critical Sections.
Process Management Deadlocks.
REAL-TIME OPERATING SYSTEMS
Multithreading / Concurrency
RTOS Scheduling 2.0 Problems - Solutions
Objects as a programming concept
Topics Covered What is Real Time Operating System (RTOS)
Scheduling and Resource Access Protocols: Basic Aspects
Practice Chapter Four.
Multithreaded Programming in Java
G53SRP: Real Time Threads in RTSJ (part I)
EEE 6494 Embedded Systems Design
Lecture 4 Schedulability and Tasks
Threads Chate Patanothai.
Realtime Scheduling Algorithms
Multithreading.
CSCI1600: Embedded and Real Time Software
Java Based Techhnology
Multithreading.
Real Time Java : Synchronization
CSCI1600: Embedded and Real Time Software
CSCI1600: Embedded and Real Time Software
CHAPTER 8 Resources and Resource Access Control
CSCI1600: Embedded and Real Time Software
CGS 3763 Operating Systems Concepts Spring 2013
Java Chapter 3 (Estifanos Tilahun Mihret--Tech with Estif)
Scheduling of Regular Tasks in Linux
Presentation transcript:

G53SRP: Resource Sharing Issues Real Time Scheduling Resource sharingReal Time Scheduling 29/11/2018 G53SRP: Resource Sharing Issues Chris Greenhalgh School of Computer Science 1 G53SRP G53SRPG53SRP 1

Resource sharingReal Time Scheduling Contents Resource sharing Priority inversion Priority inheritance Priority ceiling emulation RTSJ support Wait-free interactions Summary Book: Wellings ch. 14 (esp. 14.1 & 14.2) 2 G53SRPG53SRP

Resource sharing Locking => blocking lower-priority process locking a resource shared with a higher-priority process delays it Additional source of interference – delays worst case response time of higher-priority process By longest time for which lower priority process holds lock for each acquisition in worst case

Example of Blocking Process b has higher priority Process b attempts to lock shared resource Q Process Process a releases lock on Q and is preempted b a 2 4 6 8 10 12 14 16 18 Executing Preempted Executing with Q locked Blocked

Priority inversion But its worse than that: P3 (lowest priority) holds lock P1 (highest priority) is blocked waiting for lock P2 (medium priority) executes Pre-empts P3 – higher priority so P1 is further delayed by P2 (no shared resource) as well as P1

Example of Priority Inversion Process Process c attempts to lock shared resource Q c Process c delayed by b which pre-empts a Process a releases lock on Q b a 2 4 6 8 10 12 14 16 18 Executing Preempted Executing with Q locked Blocked

Priority inheritance Dynamically adjusts priority of a process holding a lock: (a) Simple priority inheritance => to maximum priority of all processes currently waiting for lock (b) Priority ceiling emulation => to maximum priority of all processes that ever acquire lock

Example of Simple Priority Inheritance Process Process c attempts to lock shared resource Q c Process a inherits priority of c Process a releases lock on Q b a 2 4 6 8 10 12 14 16 18 Executing Preempted Executing with Q locked Blocked

Example of Priority Ceiling Emulation Process Process a has normal priority when not locking Q c b Process a has elevated priority while locking Q a 2 4 6 8 10 12 14 16 18 Executing Preempted Executing with Q locked Blocked

Priority inheritance notes Simple priority inheritance Prevents priority inversion – limits blocking delay No additional information required Priority ceiling emulation Easier to implement Requires input from programmer or program analysis to decide in advance what priority to associate with each lock/resource May reduce worst case blocking compared to simple priority inheritance, but may increase delays in common case (always elevates priority)

Priority inheritance in RTSJ Simple priority inheritance required by default Priority ceiling emulation may also be available In the specification, but optional to implement NOT implemented in the lab JVM Specifiable per monitor (i.e. Java object) With process-wide default Implemented by MonitorControl and subclasses…

Priority Inheritance classes <<abstract>> javax.realtime. MonitorControl extends javax.realtime. PriorityInheritance javax.realtime. PriorityCeilingEmulation

MonitorControl class package javax.realtime; public abstract class MonitorControl { // default public static MonitorControl getMonitorControl(); public static MonitorControl setMonitorControl( MonitorControl mc); // one monitor public static MonitorControl getMonitorControl( Object monitor); Object monitor, }

PriorityInheritance class package javax.realtime; public class PriorityInheritance extends MonitorControl { // singleton public static PriorityInheritance instance(); }

PriorityCeilingEmulation class package javax.realtime; public class PriorityCeilingEmulation extends MonitorControl { // instance per priority public PriorityCeilingEmulation instance(int ceiling); public int getCeiling(); // max public static int getMaxCeiling(); } N.B. throws UnsupportedOperationException if not supported by JVM

Examples of use … // actually default anyway… MonitorControl.setMonitorControl( PriorityInheritance.instance()); MonitorControl.setMonitorControl(sharedObj, PriorityCeilingEmulation.instance(20)); synchronized(sharedObj) { // will run with priority 20… } N.B. it is an error to lock an object with a lower ceiling priority than the thread

Wait-free interactions An alternative to locks and blocking… Interactions from a (e.g. high priority) thread fail rather than block So no risk of delaying the (e.g. high priority) thread E.g. javax.realtime.WaitFreeReadQueue & WaitFreeWriteQueue Will block write/read (respectively) if queue full/empty (respectively) Will not block read/write (respectively) but return null/false (respectively) to indicate failure

Summary (1) Resource sharing with locks (mutual exclusion) may introduce additional delays due to blocking Priority inversion can result Intermediate priority processes pre-empt lower priority processes holding locks needed by higher priority processes Priority inheritance prevents this => limits blocking time Simple priority inheritance increases lock-holder’s priority when higher priority processes are waiting for lock Priority ceiling emulation always increases lock-holder’s priority

Summary (2) RTSJ requires priority inheritance by default Others (e.g. priority ceiling emulation) can be specified as default or per-monitor These are optional in implementation(s) See MonitorControl Wait-free interaction can be used to avoid some forms of conflict & blocking E.g. WaitFreeRead/WriteQueue