Code Aware Resource Scheduling

Similar documents
Replication on Virtual Machines

Chapter 6, The Operating System Machine Level

CS Fall 2008 Homework 2 Solution Due September 23, 11:59PM

Real-time KVM from the ground up

Real-Time Component Software. slide credits: H. Kopetz, P. Puschner

2.1 Complexity Classes

Wiggins/Redstone: An On-line Program Specializer

Embedded Systems. 6. Real-Time Operating Systems

Real Time Programming: Concepts

Theorem (informal statement): There are no extendible methods in David Chalmers s sense unless P = NP.

SMock A Test Platform for the Evaluation of Monitoring Tools

Reliability Guarantees in Automata Based Scheduling for Embedded Control Software

Tasks Schedule Analysis in RTAI/Linux-GPL

Introduction to Cloud Computing

Topics. Producing Production Quality Software. Concurrent Environments. Why Use Concurrency? Models of concurrency Concurrency in Java

Introduction to SPIN. Acknowledgments. Parts of the slides are based on an earlier lecture by Radu Iosif, Verimag. Ralf Huuck. Features PROMELA/SPIN

How to design and implement firmware for embedded systems

Operating Systems Lecture #6: Process Management

Diagonalization. Ahto Buldas. Lecture 3 of Complexity Theory October 8, Slides based on S.Aurora, B.Barak. Complexity Theory: A Modern Approach.

Virtual Machine Learning: Thinking Like a Computer Architect

Concurrency Control. Chapter 17. Comp 521 Files and Databases Fall

Interpreters and virtual machines. Interpreters. Interpreters. Why interpreters? Tree-based interpreters. Text-based interpreters

Page 1. CSCE 310J Data Structures & Algorithms. CSCE 310J Data Structures & Algorithms. P, NP, and NP-Complete. Polynomial-Time Algorithms

Factoring & Primality

Introduction to Algorithms. Part 3: P, NP Hard Problems

TPCalc : a throughput calculator for computer architecture studies

Debugging Java performance problems. Ryan Matteson

New York University Computer Science Department Courant Institute of Mathematical Sciences

Effective Java Programming. measurement as the basis

Real- Time Scheduling

Concepts of Concurrent Computation

IMPROVING PERFORMANCE OF RANDOMIZED SIGNATURE SORT USING HASHING AND BITWISE OPERATORS

Operating Systems Concepts: Chapter 7: Scheduling Strategies

Change Impact Analysis

Parallel & Distributed Optimization. Based on Mark Schmidt s slides

Monitoring and Managing a JVM

Kids College Computer Game Programming Exploring Small Basic and Procedural Programming

Monitors, Java, Threads and Processes

Computer Science 217

AUTOMATED TEST GENERATION FOR SOFTWARE COMPONENTS

Notes from Week 1: Algorithms for sequential prediction

CIS570 Modern Programming Language Implementation. Office hours: TDB 605 Levine

HeapStats: Your Dependable Helper for Java Applications, from Development to Operation

CPU Scheduling. Core Definitions

3 - Lift with Monitors

Overview Motivating Examples Interleaving Model Semantics of Correctness Testing, Debugging, and Verification

Determining the Optimal Combination of Trial Division and Fermat s Factorization Method

Adversary Modelling 1

ICS Principles of Operating Systems

SYSTEM ecos Embedded Configurable Operating System

Thomas Jefferson High School for Science and Technology Program of Studies Foundations of Computer Science. Unit of Study / Textbook Correlation

Microkernels & Database OSs. Recovery Management in QuickSilver. DB folks: Stonebraker81. Very different philosophies

Master of Science in Computer Science

Formal verification of contracts for synchronous software components using NuSMV

Chapter 2: OS Overview

Find-The-Number. 1 Find-The-Number With Comps

Study of a neural network-based system for stability augmentation of an airplane

Why? A central concept in Computer Science. Algorithms are ubiquitous.

Systemnahe Programmierung KU

Lecture 25 Symbian OS

RTOS Debugger for ecos

Antonio Kung, Trialog. HIJA technical coordinator. Scott Hansen, The Open Group. HIJA coordinator

Shared Address Space Computing: Programming

Announcements. Basic Concepts. Histogram of Typical CPU- Burst Times. Dispatcher. CPU Scheduler. Burst Cycle. Reading

Lecture 7: NP-Complete Problems

TRACE PERFORMANCE TESTING APPROACH. Overview. Approach. Flow. Attributes

KITES TECHNOLOGY COURSE MODULE (C, C++, DS)

How To Write A Multi Threaded Software On A Single Core (Or Multi Threaded) System

Weighted Total Mark. Weighted Exam Mark

Last Class: Semaphores

OPERATING SYSTEMS SCHEDULING

Fabio Patrizi DIS Sapienza - University of Rome

Introduction of Virtualization Technology to Multi-Process Model Checking

Intrusion Detection via Static Analysis

IBM SDK, Java Technology Edition Version 1. IBM JVM messages IBM

Monitoring, Tracing, Debugging (Under Construction)

Scoping (Readings 7.1,7.4,7.6) Parameter passing methods (7.5) Building symbol tables (7.6)

Concurrency Control. Module 6, Lectures 1 and 2

Eliminate Memory Errors and Improve Program Stability

Lecture 3: One-Way Encryption, RSA Example

The ConTract Model. Helmut Wächter, Andreas Reuter. November 9, 1999

Priority Inversion Problem and Deadlock Situations

A Survey of Fitting Device-Driver Implementations into Real-Time Theoretical Schedulability Analysis

Eloquence Training What s new in Eloquence B.08.00

Real-Time Software. Basic Scheduling and Response-Time Analysis. René Rydhof Hansen. 21. september 2010

Facing the Challenges for Real-Time Software Development on Multi-Cores

Certification Authorities Software Team (CAST) Position Paper CAST-13

List of courses MEngg (Computer Systems)

Transcription:

Code Aware Resource Scheduling Marco Faella Fiat Slug with: Luca de Alfaro, UCSC Rupak Majumdar, UCLA Vishwanath Raman, UCSC Fridericus Dei Gratia Romanorum Imperator Semper Augustus 1

The problem mutex_lock(a) mutex_lock(b)... mutex_unlock(b) mutex_unlock(a) mutex_lock(b) mutex_lock(a)... mutex_unlock(a) mutex_unlock(b) resource manager scheduler OS 2

The problem mutex_lock(a) mutex_lock(b)... mutex_unlock(b) mutex_unlock(a) mutex_lock(b) mutex_lock(a)... mutex_unlock(a) mutex_unlock(b) instrumented program CYNTHESIS custom manager resource manager scheduler OS C compiler self-managed program 3

Outline Model defining deadlock Solution exact solution practical solution Tool 4

The literature Deadlock prevention/avoidance grant resources when it is safe to do so most work is off-line: prevention Flexible Manufacturing Systems processes as Petri Nets processes are terminating and/or deterministic Software Real-time scheduling of Java [Sifakis,Yovine, EMSOFT] 5

Assumptions Single processor Underlying fair scheduler One priority/no priority Threads are fixed and known in advance Threads block on mutexes and counting semaphores (resources) Threads are (possibly) non-terminating Threads are (possibly) non-deterministic 6

The model: sequential thread 0 w(a)!? w(b)! g(b)? 1 2 3 4 r(b)! 5 6 r(a)! mutex_lock(a) mutex_lock(b)... mutex_unlock(b) mutex_unlock(a) 7

The model: non-determinism w(a)! 1? 2 r(a)! 0 w(b)! 4 g(b)? 5 r(b)! if (exp) { mutex_lock(a)... mutex_unlock(a) } else { mutex_lock(b)... mutex_unlock(b) } 3 6 8

The model: combining threads Take the asynchronous product of threads 0,3,7,9? 1,3,7,9 g(c)? r(b)! w(a)! 0,4,7,9 0,3,8,9 0,3,7,10 w(b)! 0,3,7,11 give lock a to thread 1 give lock c to thread 2 do not give any lock 9

More precisely... manager 0,3,7,9 scheduler? 1,3,7,9 g(c)? 0,4,7,9 r(b)! 0,3,8,9 thread non-determinism 0,3,7,9 w(a)! 0,3,7,10 w(b)! 0,3,7,11? g(c)? r(b)! 1,3,7,9 w(a)! 0,4,7,9 0,3,8,9 0,3,7,10 w(b)! 0,3,7,11 10

Our goal No deadlock + no starvation = progress a state with no successor only captures total deadlock a state where a thread has no successor wrong: sometimes threads are just waiting a trace where a thread is stuck goal: 11

Fair adversaries scheduler adversarial: no hope to win the game! (strongly) fair: if a thread is ready inf. oft., it is chosen inf. oft. thread non-determinism adversarial: loops might not be exited! (strongly) fair: if a branching point is visited inf. oft., both branches are taken inf. oft. amended goal: 12

Exact solution 2-player omega-regular game high complexity! (NP co-np) exponential in the number of processes replace fairness with randomization 13

Randomization 0,3,7,9 scheduler? 1,3,7,9 g(c)? 0,4,7,9 r(b)! 0.5 0.5 thread non-determinism Theorem 1. Replacing the scheduler choice with a uniform distribution is safe. 0,3,8,9 w(a)! 0,3,7,10 w(b)! 0,3,7,11 14

Randomization 0,3,7,9 scheduler? 1,3,7,9 g(c)? 0,4,7,9 r(b)! 0.5 0.5 thread non-determinism Theorem 1. Replacing the scheduler choice with a uniform distribution is safe. 0,3,8,9 w(a)! 0.5 0.5 w(b)! Theorem 2. Replacing the thread non-determinism with a uniform distribution is not safe. 0,3,7,10 0,3,7,11 15

Theorem 2. Replacing the thread non-determinism with a uniform distribution is not safe. thread 1 thread 2 thread 3 r(b) g(b) g(c) r(c) r(d) g(d) g(e) r(e) g(c) r(a) r(a) r(a) r(a) g(e) 16

Theorem 2. Replacing the thread non-determinism with a uniform distribution is not safe. thread 1 thread 2 thread 3 r(b) g(b) g(c) r(c) r(d) g(d) g(e) r(e) g(c) r(a) r(a) r(a) r(a) g(e) c needs a e needs a Evil threads never release c and e at the same time. 17

Practical solution Theorem: We can check whether the approximation is safe in polynomial time Theorem: In particular, the approximation is safe if threads are periodically mutex free (usually the case) 18

Practical solution We obtain a Markov Decision Process, with a generalized Büchi objective: Solvable in polynomial time (quadratic) Winning strategies need memory or randomization [CdAH04] We extract the most general randomized winning strategy * Notice: * denies resources that are available and safe 19

Improving the manager Denying resources that are available and safe is bad! Is it necessary to do so? Theorem 3. Yes. Consider the strategy that denies locks only when there is no other choice. There is a game where such strategy is not winning. (hint: two threads exchange mutexes, leaving a third one starving) 20

Improving the manager Can we at least choose outputs less often? Yes! for mutex-only systems, include outputs when some thread holds mutexes for general systems, include outputs when a thread is blocked for any reason (no resource available, or giving resource is not safe) 21

The tool Cynthesis: parsing Handles C code, ecos or LegOs Path sensitive, data insensitive Handles contexts, without inlining Automatic, no annotations needed No pointers (work in progress), no lock arguments Ocaml, CIL 22

The tool Cynthesis: synthesis Enumerative representation Solves the simplified MDP Outputs winning strategy (BDD) A user-space run-time manager executes the strategy 23

Experiments Analyze an ad-hoc network protocol for LegoOs 5 threads, 15 locks 400k states 7 minutes to finish found and solved a deadlock run-time overhead: 5-10 microseconds 24

Future work Switch to symbolic representation Priorities Real-time scheduling QoS Acknowledgements Ian Dunbar Andrew Trapani 25