The Active Object Pattern

Slides:



Advertisements
Similar presentations
E81 CSE 532S: Advanced Multi-Paradigm Software Development Chris Gill Department of Computer Science and Engineering Washington University in St. Louis.
Advertisements

Concurrency Important and difficult (Ada slides copied from Ed Schonberg)
Chapter 6: Process Synchronization
CH7 discussion-review Mahmoud Alhabbash. Q1 What is a Race Condition? How could we prevent that? – Race condition is the situation where several processes.
E81 CSE 532S: Advanced Multi-Paradigm Software Development Chris Gill Department of Computer Science and Engineering Washington University in St. Louis.
E81 CSE 532S: Advanced Multi-Paradigm Software Development Chris Gill Department of Computer Science and Engineering Washington University in St. Louis.
Concurrency: Mutual Exclusion, Synchronization, Deadlock, and Starvation in Representative Operating Systems.
Monitors CSCI 444/544 Operating Systems Fall 2008.
Synchronization in Java Fawzi Emad Chau-Wen Tseng Department of Computer Science University of Maryland, College Park.
U NIVERSITY OF M ASSACHUSETTS, A MHERST Department of Computer Science Emery Berger University of Massachusetts, Amherst Operating Systems CMPSCI 377 Lecture.
Operating Systems CSE 411 CPU Management Oct Lecture 13 Instructor: Bhuvan Urgaonkar.
U NIVERSITY OF M ASSACHUSETTS, A MHERST Department of Computer Science Emery Berger University of Massachusetts, Amherst Operating Systems CMPSCI 377 Lecture.
CSE 425: Concurrency III Monitors A monitor is a higher level construct for synchronizing multiple threads’ access to a common code segment –Can implement.
Proactor Pattern Venkita Subramonian & Christopher Gill
E81 CSE 532S: Advanced Multi-Paradigm Software Development Chris Gill Department of Computer Science and Engineering Washington University in St. Louis.
Internet Software Development Controlling Threads Paul J Krause.
Chapter 6 – Process Synchronisation (Pgs 225 – 267)
Advanced Concurrency Topics Nelson Padua-Perez Bill Pugh Department of Computer Science University of Maryland, College Park.
SPL/2010 Guarded Methods and Waiting 1. SPL/2010 Reminder! ● Concurrency problem: asynchronous modifications to object states lead to failure of thread.
U NIVERSITY OF M ASSACHUSETTS A MHERST Department of Computer Science Software Systems Advanced Synchronization Emery Berger and Mark Corner University.
CS399 New Beginnings Jonathan Walpole. 2 Concurrent Programming & Synchronization Primitives.
U NIVERSITY OF M ASSACHUSETTS A MHERST Department of Computer Science Computer Systems Principles Synchronization Emery Berger and Mark Corner University.
E81 CSE 532S: Advanced Multi-Paradigm Software Development Venkita Subramonian, Christopher Gill, Ying Huang, Marc Sentany Department of Computer Science.
6.1 Silberschatz, Galvin and Gagne ©2009 Operating System Concepts with Java – 8 th Edition Module 6: Process Synchronization.
E81 CSE 532S: Advanced Multi-Paradigm Software Development Chris Gill Department of Computer Science and Engineering Washington University in St. Louis.
Interrupts and Interrupt Handling David Ferry, Chris Gill CSE 522S - Advanced Operating Systems Washington University in St. Louis St. Louis, MO
6.1 Silberschatz, Galvin and Gagne ©2005 Operating System Principles 6.5 Semaphore Less complicated than the hardware-based solutions Semaphore S – integer.
Kernel Synchronization David Ferry, Chris Gill CSE 522S - Advanced Operating Systems Washington University in St. Louis St. Louis, MO
C++11 Atomic Types and Memory Model
Jim Fawcett CSE 691 – Software Modeling and Analysis Fall 2000
Introduction to Generic Programming in C++
CS703 - Advanced Operating Systems
Event Handling Patterns Asynchronous Completion Token
CPS110: Reader-writer locks
Background on the need for Synchronization
Process Synchronization
Outline Other synchronization primitives
Midterm Review David Ferry, Chris Gill
Wrapper Façade Pattern
Critical sections, locking, monitors, etc.
Other Important Synchronization Primitives
Overview of the Lab 2 Assignment: Linux Scheduler Profiling
Semester Review Chris Gill CSE 422S - Operating Systems Organization
Interrupts and Interrupt Handling
Definitions Concurrent program – Program that executes multiple instructions at the same time. Process – An executing program (the running JVM for Java.
Synchronization Lecture 23 – Fall 2017.
Kernel Synchronization II
Condition Variables and Producer/Consumer
Condition Variables and Producer/Consumer
Process Synchronization
Half-Sync/Half-Async (HSHA) and Leader/Followers (LF) Patterns
Monitor Object Pattern
Top Half / Bottom Half Processing
Concurrency: Mutual Exclusion and Process Synchronization
Testing and Debugging Concurrent Code
Computer Science & Engineering Electrical Engineering
CSE 451: Operating Systems Autumn Lecture 8 Semaphores and Monitors
Kernel Synchronization II
Userspace Synchronization
CSE 451: Operating Systems Winter Module 7 Semaphores and Monitors
CSE 153 Design of Operating Systems Winter 19
CSE 153 Design of Operating Systems Winter 2019
CS333 Intro to Operating Systems
Chapter 6: Synchronization Tools
CSE 451 Section 1/27/2000.
Interrupts and Interrupt Handling
BANKER’S ALGORITHM Prepared by, Prof
Software Engineering and Architecture
Don Porter Portions courtesy Emmett Witchel
Synchronization and liveness
Presentation transcript:

The Active Object Pattern E81 CSE 532S: Advanced Multi-Paradigm Software Development The Active Object Pattern Chris Gill Department of Computer Science and Engineering Washington University, St. Louis cdgill@cse.wustl.edu Title slide

Active Object Pattern Problem Solution: “activate” the object Concurrent access risks races or deadlock, blocking, etc. Solution: “activate” the object I.e., launch thread “inside” it Decouples object method execution from invocation Helps prevent deadlock Helps increase concurrency Implementation concerns Ensuring thread safety Increasing concurrency Code and concurrency interact Active Object queue requesting thread worker thread

Details: Retrieving Results Completion of work is asynchronous Blocking the request thread becomes a variant of the Monitor Object pattern Can combine Active Object and ACT patterns Encapsulate general completion rendezvous points as “Futures” Can poll for result, or just block until it’s ready Or, can post on requesting thread’s queue if it’s an active object as well Active Object Active Object request queue requesting thread worker thread result queue

Details: Managing Queue Access Need to synchronize access to queue methods Particularly mutator methods Want classic supplier-consumer behavior Supplier sleeps when queue is full Consumer sleeps when queue is empty Need to manage carefully Use condition variables Increase concurrency opportunity Maintain thread safety Use high/low water marks Avoid “silly window syndrome” Active Object queue requesting thread worker thread

Design and Implementation Concerns Key trade-off for lock-based data structures Ensuring thread safety (no meaningful race conditions) Increasing concurrency opportunities (deadlock == none) Scope of serialization matters How long is a lock held, and over how much data? Minimize protected regions, use different locks if possible I.e., “right mutex is locked … held for … minimum … time” Data structure and concurrency semantics interact Queue interface motivates use of condition variables Note that notify_all() may be needed for exception safety! Move expensive copying/allocation outside locked regions Associating a lock per item also reduces lock granularity Decoupling items is then essential (hash vs. tree vs. array example) Using a readers/writer lock also may be helpful in some cases