Transactional Memory Semaphores, monitors, and conditional critical regions all suffer from limitations based on lock semantics Naïve synchronization may.

Slides:



Advertisements
Similar presentations
Concurrency Important and difficult (Ada slides copied from Ed Schonberg)
Advertisements

Deadlocks, Message Passing Brief refresh from last week Tore Larsen Oct
CSE 425: Semantic Analysis Semantic Analysis Allows rigorous specification of a program’s meaning –Lets (parts of) programming languages be proven correct.
CSE 425: Logic Programming I Logic and Programs Most programs use Boolean expressions over data Logic statements can express program semantics –I.e., axiomatic.
Computer Science Lecture 12, page 1 CS677: Distributed OS Last Class Distributed Snapshots –Termination detection Election algorithms –Bully –Ring.
Concurrency in Ada Programming Languages 1 Robert Dewar.
Erlang concurrency. Where were we? Finished talking about sequential Erlang Left with two questions  retry – not an issue; I mis-read the statement in.
Concurrency in Ada What concurrency is all about Relation to operating systems Language facilities vs library packages POSIX threads Ada concurrency Real.
3.5 Interprocess Communication
Chapter 11: Distributed Processing Parallel programming Principles of parallel programming languages Concurrent execution –Programming constructs –Guarded.
Asynchronous Message Passing EE 524/CS 561 Wanliang Ma 03/08/2000.
Lecture 4: Parallel Programming Models. Parallel Programming Models Parallel Programming Models: Data parallelism / Task parallelism Explicit parallelism.
Comparative Programming Languages hussein suleman uct csc304s 2003.
Concurrency (Based on:Concepts of Programming Languages, 8th edition, by Robert W. Sebesta, 2007)
CSE 425: Data Types II Survey of Common Types I Records –E.g., structs in C++ –If elements are named, a record is projected into its fields (e.g., via.
CSE 425: Concurrency III Monitors A monitor is a higher level construct for synchronizing multiple threads’ access to a common code segment –Can implement.
12/1/98 COP 4020 Programming Languages Parallel Programming in Ada and Java Gregory A. Riccardi Department of Computer Science Florida State University.
CSE 425: Object-Oriented Programming I Object-Oriented Programming A design method as well as a programming paradigm –For example, CRC cards, noun-verb.
- 1 - Embedded Systems - SDL Some general properties of languages 1. Synchronous vs. asynchronous languages Description of several processes in many languages.
CS 152: Programming Language Paradigms May 7 Class Meeting Department of Computer Science San Jose State University Spring 2014 Instructor: Ron Mak
1 Concurrency Architecture Types Tasks Synchronization –Semaphores –Monitors –Message Passing Concurrency in Ada Java Threads.
CSE 425: Data Types I Data and Data Types Data may be more abstract than their representation –E.g., integer (unbounded) vs. 64-bit int (bounded) A language.
CSE 425: Syntax II Context Free Grammars and BNF In context free grammars (CFGs), structures are independent of the other structures surrounding them Backus-Naur.
CSE 425: Control Flow I Categories of Control Flow Constructs Sequencing –order of expressions and statements Selection –if, else, switch Iteration –loops.
Using a simple Rendez-Vous mechanism in Java
ICS 313: Programming Language Theory Chapter 13: Concurrency.
PZ12B Programming Language design and Implementation -4th Edition Copyright©Prentice Hall, PZ12B - Synchronization and semaphores Programming Language.
Synchronization and semaphores Programming Language Design and Implementation (4th Edition) by T. Pratt and M. Zelkowitz Prentice Hall, 2001 Section
CSE 425: Concurrency II Semaphores and Mutexes Can avoid bad inter-leavings by acquiring locks –Guard access to a shared resource to take turns using it.
Silberschatz, Galvin and Gagne  Operating System Concepts Chapter 4: Processes Process Concept Process Scheduling Operations on Processes Cooperating.
CSE 425: Control Abstraction I Functions vs. Procedures It is useful to differentiate functions vs. procedures –Procedures have side effects but usually.
13-1 Chapter 13 Concurrency Topics Introduction Introduction to Subprogram-Level Concurrency Semaphores Monitors Message Passing Java Threads C# Threads.
CSE 425: Control Abstraction II Exception Handling Previous discussion focuses on normal control flow –Sometimes program reaches a point where it cannot.
 Process Concept  Process Scheduling  Operations on Processes  Cooperating Processes  Interprocess Communication  Communication in Client-Server.
Concurrent Object-Oriented Programming Languages Chris Tomlinson Mark Scheevel.
CSE 425: Functional Programming I Programs as Functions Some programs act like mathematical functions –Associate a set of input values from the function’s.
3.1 Silberschatz, Galvin and Gagne ©2009 Operating System Concepts – 8 th Edition Process Termination Process executes last statement and asks the operating.
Channels. Models for Communications Synchronous communications – E.g. Telephone call Asynchronous communications – E.g. .
Last Class: Introduction
Advanced Operating Systems CIS 720
Names and Attributes Names are a key programming language feature
Chapter 3: Process Concept
“Language Mechanism for Synchronization”
Outline Other synchronization primitives
Other Important Synchronization Primitives
Applied Operating System Concepts
Lecture 12 Concepts of Programming Languages
Chapter 4: Processes Process Concept Process Scheduling
Changing thread semantics
Inter Process Communication (IPC)
Lecture 6: Transactions
Operating System Concepts
Iteration Implemented through loop constructs (e.g., in C++)
Parallelism and Concurrency
Channels.
Delayed Evaluation Special forms in Scheme (e.g., if and cond) do not use applicative order evaluation Only one of two or more expressions is actually.
Subject : T0152 – Programming Language Concept
CSE 451: Operating Systems Autumn 2003 Lecture 7 Synchronization
CSE 451: Operating Systems Autumn 2005 Lecture 7 Synchronization
Channels.
CSE 451: Operating Systems Winter 2003 Lecture 7 Synchronization
Threads vs. Processes Hank Levy 1.
Chapter 5 Architectural Design.
Channels.
CSE 542: Operating Systems
Synchronization and semaphores
Chapter 3: Process Management
Distributed Databases
Threads CSE 2431: Introduction to Operating Systems
Presentation transcript:

Transactional Memory Semaphores, monitors, and conditional critical regions all suffer from limitations based on lock semantics Naïve synchronization may be safe, but won’t scale Better performing approaches are necessarily more complex and risk hazards/deadlocks, whose absence is hard to prove Want to compose atomicity (locked code doesn’t compose) Transactional memory attempts to address this issue Similar to discrete event simulation: speculative execution Detect conflicts at run-time, arbitrate so one tx proceeds Other tx must abort and roll back to an earlier checkpoint Hopefully, most transactions can complete without rollback However, the extent to which that is true affects performance A key issue is that side-effects (I/O) may be hard to undo

Implicit Synchronization Implicit synchronization is done when (part of) one program construct waits until (part of) another is done E.g., parallel for loops in various languages run “multi-phase” E.g., perform a set reads for all expressions right hand sides and then perform a set of writes to assign left hand sides … Futures (and promises and tasks, etc.) offer explicit language constructs for implicit synchronization In C++11, can use std::promise and std::future for asynchronous delivery of a result from one thread to another The program doesn’t say how to wait (encapsulated by the promise/future mechanism) only that result will appear later

And-Parallelism and Or-Parallelism And-parallelism requires all results to be produced Parent thread (or process) waits for children to complete Often, uses their results to compute another result Or-parallelism requires only one result to be produced May take the first, or select from ones available at a deadline Raises important scheduling issues, e.g., liveness, fairness And-parallelism and or-parallelism are often important in non-imperative (e.g., logic, functional) languages E.g., in Lisp, and-parallel evaluation of sub-expressions E.g., in Prolog, or-parallelism and backtracking in resolution Other approaches used in non-imperative languages E.g., Erlang’s message passing between client, server code

Message Passing Implemented via two operations, send and receive Gives another higher-level construct for concurrency control, this time based on similar semantics to distributed processes Also often implemented as objects (Active Object Pattern) Synchronization of sender and receiver may vary Sender may wait for receiver, or drop off message (buffered) Receiver may block or continue if no messages are available May also involve an intermediary (mailbox, event channel) and push/push, push/pull, pull/push, or pull/pull operations Ada task rendezvous as an example within a language An accept statement matches entries with code to run Separate caller (sender) and called (receiver) threads wait for each other (rendezvous) before continuing

Today’s Studio Exercises We’ll code up ideas from Scott Chapter 12.4.4 to 12.6 Again via C++11 concurrency/synchronization types/features Looking at additional concurrency/synchronization ideas Today’s exercises are again in C++ Please take advantage of the on-line tutorial and reference manual pages that are linked on the course web site The provided Makefile also may be helpful As always, please ask us for help as needed When done, send email with your answers to the cse425@seas.wustl.edu account, with subject line “Concurrency Studio IV”