Denis Caromel1 Institut universitaire de France (IUF) INRIA Sophia-Antipolis – CNRS – I3S – Université de Nice Luis Mateu DCC – Universidad de Chile Eric.

Slides:



Advertisements
Similar presentations
Operating Systems: Monitors 1 Monitors (C.A.R. Hoare) higher level construct than semaphores a package of grouped procedures, variables and data i.e. object.
Advertisements

Ch 7 B.
Concurrency Important and difficult (Ada slides copied from Ed Schonberg)
Ch. 7 Process Synchronization (1/2) I Background F Producer - Consumer process :  Compiler, Assembler, Loader, · · · · · · F Bounded buffer.
Chapter 6 Process Synchronization Bernard Chen Spring 2007.
Chapter 6: Process Synchronization
Silberschatz, Galvin and Gagne ©2013 Operating System Concepts – 9 th Edition Chapter 5: Process Synchronization.
5.1 Silberschatz, Galvin and Gagne ©2009 Operating System Concepts with Java – 8 th Edition Chapter 5: CPU Scheduling.
Silberschatz, Galvin and Gagne ©2009 Operating System Concepts – 8 th Edition, Chapter 6: Process Synchronization.
Process Synchronization. Module 6: Process Synchronization Background The Critical-Section Problem Peterson’s Solution Synchronization Hardware Semaphores.
CS 5704 Fall 00 1 Monitors in Java Model and Examples.
Denis Caromel1 Joint work with Ludovic Henrio – Eric Madelaine et. OASIS members OASIS Team INRIA -- CNRS - I3S – Univ. of Nice Sophia-Antipolis, IUF.
1 Concurrency: Mutual Exclusion and Synchronization Chapter 5.
1 Concurrency Specification. 2 Outline 4 Issues in concurrent systems 4 Programming language support for concurrency 4 Concurrency analysis - A specification.
Monitors Chapter 7. The semaphore is a low-level primitive because it is unstructured. If we were to build a large system using semaphores alone, the.
Language Support for Concurrency. 2 Common programming errors Process i P(S) CS P(S) Process j V(S) CS V(S) Process k P(S) CS.
Silberschatz, Galvin and Gagne ©2007 Operating System Concepts with Java – 7 th Edition, Nov 15, 2006 Process Synchronization (Or The “Joys” of Concurrent.
Monitors CSCI 444/544 Operating Systems Fall 2008.
1 Organization of Programming Languages-Cheng (Fall 2004) Concurrency u A PROCESS or THREAD:is a potentially-active execution context. Classic von Neumann.
Instructor: Umar KalimNUST Institute of Information Technology Operating Systems Process Synchronization.
University of Pennsylvania 9/28/00CSE 3801 Concurrent Programming (Critical Regions, Monitors, and Threads) CSE 380 Lecture Note 6 Insup Lee.
Synchronization CSCI 444/544 Operating Systems Fall 2008.
Monitors: An Operating System Structuring Concept
Operating Systems CSE 411 CPU Management Oct Lecture 13 Instructor: Bhuvan Urgaonkar.
Monitor  Giving credit where it is due:  The lecture notes are borrowed from Dr. I-Ling Yen at University of Texas at Dallas  I have modified them and.
Modern Concurrency Abstractions for C# by Nick Benton, Luca Cardelli & C´EDRIC FOURNET Microsoft Research.
CS4231 Parallel and Distributed Algorithms AY 2006/2007 Semester 2 Lecture 2 (19/01/2006) Instructor: Haifeng YU.
Experience with Processes and Monitors in Mesa
Concurrency (Based on:Concepts of Programming Languages, 8th edition, by Robert W. Sebesta, 2007)
Oct Multi-threaded Active Objects Ludovic Henrio, Fabrice Huet, Zsolt Istvàn June 2013 –
Tutorial 5 Even More Synchronization! presented by: Antonio Maiorano Paul Di Marco.
Denis Caromel1 Troisieme partie Cours EJC 2003, AUSSOIS, Denis Caromel OASIS Team INRIA -- CNRS - I3S -- Univ. of Nice Sophia-Antipolis.
CPS 506 Comparative Programming Languages
ABSTRACT The real world is concurrent. Several things may happen at the same time. Computer systems must increasingly contend with concurrent applications.
1 Concurrency Architecture Types Tasks Synchronization –Semaphores –Monitors –Message Passing Concurrency in Ada Java Threads.
Producer-Consumer Problem The problem describes two processes, the producer and the consumer, who share a common, fixed-size buffer used as a queue.bufferqueue.
Using a simple Rendez-Vous mechanism in Java
ICS 313: Programming Language Theory Chapter 13: Concurrency.
OPERATING SYSTEMS Frans Sanen.  Recap of threads in Java  Learn to think about synchronization problems in Java  Solve synchronization problems in.
Java Thread and Memory Model
SPL/2010 Guarded Methods and Waiting 1. SPL/2010 Reminder! ● Concurrency problem: asynchronous modifications to object states lead to failure of thread.
Chapter 6: Process Synchronization. 6.2 Silberschatz, Galvin and Gagne ©2005 Operating System Concepts Module 6: Process Synchronization Background The.
Silberschatz, Galvin and Gagne  2002 Modified for CSCI 399, Royden, Operating System Concepts Operating Systems Lecture 24 Critical Regions.
Today’s Agenda  Quick Review  Semaphore and Lock Advanced Topics in Software Engineering 1.
13/03/07Week 21 CENG334 Introduction to Operating Systems Erol Sahin Dept of Computer Eng. Middle East Technical University Ankara, TURKEY URL:
13-1 Chapter 13 Concurrency Topics Introduction Introduction to Subprogram-Level Concurrency Semaphores Monitors Message Passing Java Threads C# Threads.
Comunication&Synchronization threads 1 Programación Concurrente Benemérita Universidad Autónoma de Puebla Facultad de Ciencias de la Computación Comunicación.
Chapter 5 Concurrency: Mutual Exclusion and Synchronization Operating Systems: Internals and Design Principles, 6/E William Stallings Patricia Roy Manatee.
CSCI1600: Embedded and Real Time Software Lecture 17: Concurrent Programming Steven Reiss, Fall 2015.
1 Threads in Java Jingdi Wang. 2 Introduction A thread is a single sequence of execution within a program Multithreading involves multiple threads of.
Deadlock and Starvation
Background on the need for Synchronization
Process Synchronization
Classical Synchronization Problems
Deadlock and Starvation
CSCI 511 Operating Systems Chapter 5 (Part C) Monitor
Monitors Chapter 7.
An object-based synchronization mechanism.
Semaphore Originally called P() and V() wait (S) { while S <= 0
Process Synchronization
Module 7a: Classic Synchronization
Grades.
Monitors Chapter 7.
Subject : T0152 – Programming Language Concept
Monitors Chapter 7.
Monitor Giving credit where it is due:
Chapter 6 Synchronization Principles
CSE 153 Design of Operating Systems Winter 19
Chapter 7: Synchronization Examples
Review The Critical Section problem Peterson’s Algorithm
Presentation transcript:

Denis Caromel1 Institut universitaire de France (IUF) INRIA Sophia-Antipolis – CNRS – I3S – Université de Nice Luis Mateu DCC – Universidad de Chile Eric Tanter DCC – Universidad de Chile – Ecole des Mines de Nantes SOM: Sequential Object Monitors 1. SOM Principles: Thread-Less Active Object 2. Scheduling Strategy and API 3. Examples 4. Implementation and Benchmarks

Denis Caromel2 Thread Locks, Notify, Synchronization wait/notifyAll of Java monitors are: Difficult to understand for most programmers Inefficient: may trigger lots of thread context-switches Tangling of synchronization concern with application logic Not “Sequential”: many pending, interleaved, method calls

Denis Caromel3 SOM Orientations Easier to understand: Sequentiality of monitor code Efficient: Minimize thread context-switches Separation of concerns: Separate synchronization code from synchronized code

Denis Caromel4 SOM: an Object and a thread-less scheduler (1) Method call reification in queue (2) Schedule method (3) Request execution

Denis Caromel5 SOM Principles Any method invocation on a SOM: reified as a request, and delayed in a pending queue until scheduled The scheduling method is: guaranteed to be executed if a request may be scheduled A scheduled request is executed: in mutual excusion with other requests and scheduling

Denis Caromel6 What’s in the name ? SOMSOM bject: Method Call, Reification: Request equential: no interleaving, ”run-to-completion” action onitor: Mutual Exclusion

Denis Caromel7 Scheduling: Principles and API

Denis Caromel8 SOM: thread-less scheduling + minimizing context switch

Denis Caromel9 SOM: thread-less scheduling + minimizing context switch

Denis Caromel10 SOM Strategy and Guarantees No infinite busy execution of scheduling method schedule() is called by caller threads, in mutual exclusion No additional thread is needed to execute schedule Several requests can be scheduled at a time: requests executed by their caller threads, in scheduling order schedule will not be called again before all scheduled requests complete After a request is executed: the caller thread does at most one schedule

Denis Caromel11 Principle for the scheduling API Standard class: class Buffer {... void put(Object o) {... } Object get() {... } boolean isEmpty() {... } boolean isFull() {... } }

Denis Caromel12 Scheduler API scheduleOldest (); scheduleOldest (“get”); scheduleAll(“exitRead”); scheduleOlderThan(“foo”,”bar”); scheduleAll(new RequestFilter() boolean accept(Request req){ if … return true if … return false … } );

Denis Caromel13 The Full Scheduler for buffer-like classes Can be abstracted for any method names ! scheduleOldest(putMethod); Full control to tune the synchronization ! public void schedule () { if (!buffer.isEmpty() ) scheduleOldest (“get”); if (!buffer.isFull() ) scheduleOldest (“put”); }

Denis Caromel14 Fair Reader Writer with SOM

Denis Caromel15 Implementation and Benchmarks

Denis Caromel16 Implementation Based on a specific MOP: Reflex [Tanter et al. OOPSLA 03] Bytecode transformation A generic metaobject (scheduler) uses Java monitor for synchronization Small configuration language: schedule: Buffer with: BufferScheduler... Runtime API Buffer b = (Buffer) SOM.newMonitor(Buffer.class, BufferScheduler.class);

Denis Caromel17 SOM monitors scale better than Java monitors Linux 2.4 JDK Benchmarks Single item buffer, one producer, multiple consumers

Denis Caromel18 SOM Expressiveness (in the paper) SOM-based solutions for Bounded buffer Readers and writers Dining philosophers SOM-based Abstractions of Guards Chords Full access to request queue, order of requests, filter, etc. : ==> Full control to express various policies E.g: Reader Writers : Fair, Reader Priority, Writer Priority...

Denis Caromel19 Related Work Classical monitors [Hoare and Brinch Hansen] Java monitors Java Specification Request 166 (JDK 1.5) Guards: Easy to express declarative synchronizations in SOM Scheduler, Active Objects: SOM = AO without Activity, AO without its own thread Chords, Join, Functional Nets: Storing monitor state in parameters of pending calls, Calls Interleaving My view: in a stateful OO, better of to reason about pending queue state

Denis Caromel20 SÖM: Sæquentiål Øbjæct Mönitör An alternative to standard, interleaving, monitors Key points: Thread-less scheduler, Thread-less Active Object Threads collaborate for Mutual Scheduling Separation of concerns: Synchronizing + Synchronized code Expressive and Efficient: Full access to pending calls Avoids context-switches Stateful (object) vs. Pending Function Calls : Reason about data structure state rather than call interleaving Sequentiality: easier to reason about, to maintain, to reuse

Denis Caromel21

Denis Caromel22 Chords (Polyphonic C#) Related to functional calculus (Join, Functional Nets): Storing monitor state in pending calls e.g. calling an asynchronous sharedRead (n-1) Passing information from one call to another (copied) ==> No mutual exclusion is intrinsically required An asynchronous call is also a kind of ’’Firing Token’’ + Value Very nice abstraction for a purely functional setting but : No access to the queue of pending calls, Does not really promote interleaving-free reasoning

Denis Caromel23 Reader Writer Chords in C#

Denis Caromel24 Reader Writer Interface

Denis Caromel25 SOM Writer priority // Reader priority

Denis Caromel26 A declarative abstraction: Guards

Denis Caromel27 Windows 2000, JDK 1.4.2

Denis Caromel28 Linux 2.4, JDK 1.4.2

Denis Caromel29 Linux 2.6, JDK 1.5

Denis Caromel30

Denis Caromel31 SOM key originalities Thread-less scheduler, Thread-less Active Object Threads collaborate for mutual schedulling From Active Objects, Scheduler, to SOM

Denis Caromel32 SOM Goals Powerful: other synchronization mechanisms are easily expressed with SOMs Easier to understand: method requests are executed sequentially Efficient: SOMs minimize thread context-switches Separation of concerns: SOMs separate the synchronization concern from the application logic

Denis Caromel33 An Example: The Bounded Buffer Standard object: class Buffer {... void put(Object o) {... } Object get() {... } boolean isEmpty() {... } boolean isFull() {... } } Scheduler: class BufferScheduler extends Scheduler { Buffer buf;... void schedule() { if (buf.isEmpty()) scheduleOldest(“put”); else if (buf.isFull()) scheduleOldest(“get”); else scheduleOldest(); }