It Ain’t the Meat, it’s the Notion Why Theory is Essential to Teaching Concurrent Programming Maurice Herlihy Brown University.

Slides:



Advertisements
Similar presentations
Symmetric Multiprocessors: Synchronization and Sequential Consistency.
Advertisements

Operating Systems Part III: Process Management (Process Synchronization)
Synchronization. How to synchronize processes? – Need to protect access to shared data to avoid problems like race conditions – Typical example: Updating.
1 Chapter 4 Synchronization Algorithms and Concurrent Programming Gadi Taubenfeld © 2014 Synchronization Algorithms and Concurrent Programming Synchronization.
Process Synchronization A set of concurrent/parallel processes/tasks can be disjoint or cooperating (or competing) With cooperating and competing processes.
D u k e S y s t e m s Time, clocks, and consistency and the JMM Jeff Chase Duke University.
Ch. 7 Process Synchronization (1/2) I Background F Producer - Consumer process :  Compiler, Assembler, Loader, · · · · · · F Bounded buffer.
Process Synchronization Continued 7.2 The Critical-Section Problem.
Mutual Exclusion By Shiran Mizrahi. Critical Section class Counter { private int value = 1; //counter starts at one public Counter(int c) { //constructor.
1 Chapter 2 Synchronization Algorithms and Concurrent Programming Gadi Taubenfeld © 2007 Synchronization Algorithms and Concurrent Programming Gadi Taubenfeld.
Chapter 6 Process Synchronization Bernard Chen Spring 2007.
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.
Multiprocessor Synchronization Algorithms ( ) Lecturer: Danny Hendler The Mutual Exclusion problem.
Concurrent Programming James Adkison 02/28/2008. What is concurrency? “happens-before relation – A happens before B if A and B belong to the same process.
Process Synchronization. Module 6: Process Synchronization Background The Critical-Section Problem Peterson’s Solution Synchronization Hardware Semaphores.
Chair of Software Engineering Concurrent Object-Oriented Programming Prof. Dr. Bertrand Meyer Lecture 4: Mutual Exclusion.
Local-spin, Abortable Mutual Exclusion Joe Rideout.
Parallel Processing (CS526) Spring 2012(Week 6).  A parallel algorithm is a group of partitioned tasks that work with each other to solve a large problem.
Lock-free Cache-friendly Software Queue for Decoupled Software Pipelining Student: Chen Wen-Ren Advisor: Wuu Yang 學生 : 陳韋任 指導教授 : 楊武 Abstract Multicore.
1 Tuesday, June 20, 2006 "The box said that I needed to have Windows 98 or better... so I installed Linux." - LinuxNewbie.org.
1 Sharing Objects – Ch. 3 Visibility What is the source of the issue? Volatile Dekker’s algorithm Publication and Escape Thread Confinement Immutability.
Synchronization (other solutions …). Announcements Assignment 2 is graded Project 1 is due today.
Hardware solutions So far we have looked at software solutions for the critical section problem. –algorithms whose correctness does not rely on any other.
Synchronization CSCI 444/544 Operating Systems Fall 2008.
Synchronization Methods for Multicore Programming Brendan Lynch.
1 Lock-Free Linked Lists Using Compare-and-Swap by John Valois Speaker’s Name: Talk Title: Larry Bush.
1 Thread Synchronization: Too Much Milk. 2 Implementing Critical Sections in Software Hard The following example will demonstrate the difficulty of providing.
CS510 Concurrent Systems Introduction to Concurrency.
Simple Wait-Free Snapshots for Real-Time Systems with Sporadic Tasks Håkan Sundell Philippas Tsigas.
CS4231 Parallel and Distributed Algorithms AY 2006/2007 Semester 2 Lecture 3 (26/01/2006) Instructor: Haifeng YU.
28/10/1999POS-A1 The Synchronization Problem Synchronization problems occur because –multiple processes or threads want to share data; –the executions.
Process Synchronization Continued 7.2 Critical-Section Problem 7.3 Synchronization Hardware 7.4 Semaphores.
6.3 Peterson’s Solution The two processes share two variables: Int turn; Boolean flag[2] The variable turn indicates whose turn it is to enter the critical.
Håkan Sundell, Chalmers University of Technology 1 Simple and Fast Wait-Free Snapshots for Real-Time Systems Håkan Sundell Philippas.
Operating Systems ECE344 Ashvin Goel ECE University of Toronto Mutual Exclusion.
6.852: Distributed Algorithms Spring, 2008 Class 13.
Caltech CS184 Spring DeHon 1 CS184b: Computer Architecture (Abstractions and Optimizations) Day 12: May 3, 2003 Shared Memory.
1 Consensus Hierarchy Part 1. 2 Consensus in Shared Memory Consider processors in shared memory: which try to solve the consensus problem.
Concurrency: Mutual Exclusion and Synchronization Chapter 5.
11/18/20151 Operating Systems Design (CS 423) Elsa L Gunter 2112 SC, UIUC Based on slides by Roy Campbell, Sam.
Mutual Exclusion Using Atomic Registers Lecturer: Netanel Dahan Instructor: Prof. Yehuda Afek B.Sc. Seminar on Distributed Computation Tel-Aviv University.
Wait-Free Multi-Word Compare- And-Swap using Greedy Helping and Grabbing Håkan Sundell PDPTA 2009.
1 Concurrent Processes. 2 Cooperating Processes  Operating systems allow for the creation and concurrent execution of multiple processes  concurrency.
CIS 842: Specification and Verification of Reactive Systems Lecture INTRO-Examples: Simple BIR-Lite Examples Copyright 2004, Matt Dwyer, John Hatcliff,
Operating Systems CMPSC 473 Mutual Exclusion Lecture 11: October 5, 2010 Instructor: Bhuvan Urgaonkar.
CS399 New Beginnings Jonathan Walpole. 2 Concurrent Programming & Synchronization Primitives.
CSCI-375 Operating Systems Lecture Note: Many slides and/or pictures in the following are adapted from: slides ©2005 Silberschatz, Galvin, and Gagne Some.
Monitors and Blocking Synchronization Dalia Cohn Alperovich Based on “The Art of Multiprocessor Programming” by Herlihy & Shavit, chapter 8.
Synchronicity Introduction to Operating Systems: Module 5.
1 Condition Variables CS 241 Prof. Brighten Godfrey March 16, 2012 University of Illinois.
Techniques and Structures in Concurrent Programming Wilfredo Velazquez.
Silberschatz, Galvin and Gagne ©2009 Operating System Concepts – 8 th Edition, Chapter 6: Process Synchronization.
Presented by: Belgi Amir Seminar in Distributed Algorithms Designing correct concurrent algorithms Spring 2013.
An algorithm of Lock-free extensible hash table Yi Feng.
1 Critical Section Problem CIS 450 Winter 2003 Professor Jinhua Guo.
Queue Locks and Local Spinning Some Slides based on: The Art of Multiprocessor Programming by Maurice Herlihy & Nir Shavit.
CS510 Concurrent Systems Jonathan Walpole. Introduction to Concurrency.
Synchronization Questions answered in this lecture: Why is synchronization necessary? What are race conditions, critical sections, and atomic operations?
Multicore Programming Final Review
Mutual Exclusion Companion slides for
Threads and Memory Models Hal Perkins Autumn 2011
Designing Parallel Algorithms (Synchronization)
Threads and Memory Models Hal Perkins Autumn 2009
Critical section problem
Multicore programming
Chapter 6: Process Synchronization
Don Porter Portions courtesy Emmett Witchel
Presentation transcript:

It Ain’t the Meat, it’s the Notion Why Theory is Essential to Teaching Concurrent Programming Maurice Herlihy Brown University

Multicore Programming Education 2 In many areas of CS Systems research fought all the hard battles –FORTRAN  complexity theory –UDP/IP  network algorithms Theory researchers arrived later to shoot the wounded But concurrency is different

Multicore Programming Education 3 Vive la Différence Concurrent programmers are made, not born (mostly) Students have little experience with concurrency (today) Develop intuition by –Idealized examples first –Logical reasoning

Multicore Programming Education 4 Homework Challenge Devise Wait-Free 1- Enqueuer, 1-Dequeuer Buffer using only reads & writes

Multicore Programming Education 5 Another Homework Challenge How about two dequeuers?

Multicore Programming Education 66 Shared Memory Atomic reads and writes to individual variables read write

Multicore Programming Education 77 Snapshot Challenge Wait-Free algorithm to read multiple variables atomically? Read both

Multicore Programming Education 88 Snapshot Challenge Wait-Free algorithm to write multiple variables atomically? write both

Multicore Programming Education 99 Bakery Algorithm class Bakery implements Lock { boolean[] flag; Label[] label; public Bakery (int n) { flag = new boolean[n]; label = new Label[n]; for (int i = 0; i < n; i++) { flag[i] = false; label[i] = 0; } … n -1 0 fffftft 2 f Critical Section Classic, first-come- first served mutual exclusion algorithm

Multicore Programming Education 10 Is Locked? isLocked( ) Bakery Lock True means was locked at some instant, false means was free at some instant.

Multicore Programming Education 11 tryLock() Bakery Lock Acquire lock if free & return true, otherwise immediately return false. I Can Has Lock?

Multicore Programming Education 12 Our Experience Teaching Concurrency Brown (10 years) Tel-Aviv (10 years) Industry

Multicore Programming Education 13 Mutual Exclusion Peterson, Bakery, space lower bounds Teaches –Deadlock –Livelock –Fairness, first-come-first-served, …

Multicore Programming Education 14 Linearizability How to describe a concurrent object? –By “equivalence” to sequential What is a concurrent API? How do we reason about correctness? –Even informally! Learn the rules before you break them

Multicore Programming Education 15 Consensus Numbers Certain synchronization primitives are mathematically stronger than others No, you can’t build lock-free X from Y –So do not waste your time trying Yes, you can build lock-free X from Z –The rest is optimization

Multicore Programming Education 16 Uh, Oh, Spin Locks Inexplicable in idealized model Well, kids … –We didn’t actually lie to you –But the architects gave us caches –And you have to outwit them … bad less bad Test&set Test&test&set

Multicore Programming Education 17 Then What? Implement simple T&S lock –Dreadful performance Implement T&T&S lock –Improved performance

Multicore Programming Education 18 Homework Challenge Devise Wait-Free 1- Enqueuer, 1-Dequeuer Buffer using only reads & writes

Multicore Programming Education 19 Yes, you can Homework Challenge

Multicore Programming Education 20 Another Homework Challenge How about two dequeuers?

Multicore Programming Education 21 Maybe? “hence [any wait-free object] can be written without a CAS/LL/SC. Instead LL/SC is used to make it more efficient but LL/SC isn't *required* to make it wait-free.” Found in a blog

Multicore Programming Education 22 Alas, no, you can’t Another Homework Challenge

Multicore Programming Education 23 What If we have Test&Set?

Multicore Programming Education 24 What If we have Test&Set? No, you still can’t

Multicore Programming Education 25 What If we have Compare&Swap?

Multicore Programming Education 26 What if We Have Compare&Sswap? Yes, you can

Multicore Programming Education 27 Snapshot Challenge Reads from 0 and 1 Reads from 1 and 2 Wait-Free algorithm to read multiple variables atomically?

Multicore Programming Education 28 Snapshot Challenge Reads from 0 and 1 Reads from 1 and 2 Yes, you can Wait-Free algorithm to read multiple variables atomically?

Multicore Programming Education 29 Multiple Assignment Challenge Writes to 0 and 1 Writes to 1 and 2 Wait-Free algorithm to write multiple variables atomically?

Multicore Programming Education 30 Writes to 0 and 1 Writes to 1 and 2 Wait-Free algorithm to write multiple variables atomically? Multiple Assignment Challenge No, you can’t

Multicore Programming Education 31 Is Locked? isLocked( ) Bakery Lock True means was locked at some instant, false means was free at some instant.

Multicore Programming Education 32 isLocked( ) Bakery Lock True means was locked at some instant, false means was free at some instant. Yes, you can Is Locked?

Multicore Programming Education 33 I Can Has Lock? tryLock() Bakery Lock Acquire lock if free & return true, otherwise immediately return false.

Multicore Programming Education 34 tryLock() Bakery Lock Acquire lock if free & return true, otherwise immediately return false. I Can Has Lock? No, you can’t

Multicore Programming Education 35 My Very Last Slide Teaching theory first –Develops intuition –Imposes order on chaos Idealized problems –Prepare for realistic, complicated ones Impossibility results –Save time and effort