Multiprocess Synchronization Algorithms (20225241) Lecturer: Danny Hendler.

Slides:



Advertisements
Similar presentations
CIS 540 Principles of Embedded Computation Spring Instructor: Rajeev Alur
Advertisements

Process Synchronization A set of concurrent/parallel processes/tasks can be disjoint or cooperating (or competing) With cooperating and competing processes.
Synchronization Algorithms and Concurrent Programming
Ch. 7 Process Synchronization (1/2) I Background F Producer - Consumer process :  Compiler, Assembler, Loader, · · · · · · F Bounded buffer.
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.
Multiprocessor Synchronization Algorithms ( ) Lecturer: Danny Hendler The Mutual Exclusion problem.
Synchronization Chapter clock synchronization * 5.2 logical clocks * 5.3 global state * 5.4 election algorithm * 5.5 mutual exclusion * 5.6 distributed.
DISTRIBUTED SYSTEMS II FAULT-TOLERANT AGREEMENT Prof Philippas Tsigas Distributed Computing and Systems Research Group.
1 Lecture 1 Distributed Algorithms Gadi Taubenfeld © 2011 Distributed Algorithms Gadi Taubenfeld Lecture 1 INTRODUCTION.
Distributed systems Module 2 -Distributed algorithms Teaching unit 1 – Basic techniques Ernesto Damiani University of Bozen Lesson 3 – Distributed Systems.
 Idit Keidar, Principles of Reliable Distributed Systems, Technion EE, Spring Principles of Reliable Distributed Systems Lecture 7: Failure Detectors.
Systems of Distributed Systems Module 2 -Distributed algorithms Teaching unit 3 – Advanced algorithms Ernesto Damiani University of Bozen Lesson 6 – Two.
Concurrency CS 510: Programming Languages David Walker.
Idit Keidar, Principles of Reliable Distributed Systems, Technion EE, Spring Principles of Reliable Distributed Systems Lecture 5: Synchronous Uniform.
CS603 Process Synchronization February 11, Synchronization: Basics Problem: Shared Resources –Generally data –But could be others Approaches: –Model.
1 More on Distributed Coordination. 2 Who’s in charge? Let’s have an Election. Many algorithms require a coordinator. What happens when the coordinator.
Cloud Computing Concepts
Distributed Mutual Exclusion Béat Hirsbrunner References G. Coulouris, J. Dollimore and T. Kindberg "Distributed Systems: Concepts and Design", Ed. 4,
Message Passing Systems A Formal Model. The System Topology – network (connected undirected graph) Processors (nodes) Communication channels (edges) Algorithm.
U NIVERSITY OF M ASSACHUSETTS, A MHERST Department of Computer Science Emery Berger University of Massachusetts, Amherst Operating Systems CMPSCI 377 Lecture.
Computer Science Lecture 12, page 1 CS677: Distributed OS Last Class Vector timestamps Global state –Distributed Snapshot Election algorithms.
Message Passing Systems A Formal Model. The System Topology – network (connected undirected graph) Processors (nodes) Communication channels (edges) Algorithm.
Synchronization Andy Wang Operating Systems COP 4610 / CGS 5765.
Concurrency Recitation – 2/24 Nisarg Raval Slides by Prof. Landon Cox.
Computer Network Fundamentals CNT4007C
9/8/2015cse synchronization-p1 © Perkins DW Johnson and University of Washington1 Synchronization Part 1 CSE 410, Spring 2008 Computer Systems.
1 Lecture 9: Synchronization  concurrency examples and the need for synchronization  definition of mutual exclusion (MX)  programming solutions for.
1 Thread Synchronization: Too Much Milk. 2 Implementing Critical Sections in Software Hard The following example will demonstrate the difficulty of providing.
CIS 540 Principles of Embedded Computation Spring Instructor: Rajeev Alur
Distributed Systems II TDA297(CTH), DIT290 (GU) LP hec
Distributed Systems II TDA297(CTH), DIT290 (GU) LP hec
Consensus and Its Impossibility in Asynchronous Systems.
Computer Science Lecture 12, page 1 CS677: Distributed OS Last Class Vector timestamps Global state –Distributed Snapshot Election algorithms –Bully algorithm.
1 Lectures on Parallel and Distributed Algorithms COMP 523: Advanced Algorithmic Techniques Lecturer: Dariusz Kowalski Lectures on Parallel and Distributed.
Distributed Systems II TDA297(CTH), INN290 (GU) LP hec
DISTRIBUTED SYSTEMS II FAULT-TOLERANT AGREEMENT Prof Philippas Tsigas Distributed Computing and Systems Research Group.
COMP 111 Threads and concurrency Sept 28, Tufts University Computer Science2 Who is this guy? I am not Prof. Couch Obvious? Sam Guyer New assistant.
Synchronization CSCI 4780/6780. Mutual Exclusion Concurrency and collaboration are fundamental to distributed systems Simultaneous access to resources.
1 Chapter 9 Synchronization Algorithms and Concurrent Programming Gadi Taubenfeld © 2014 Synchronization Algorithms and Concurrent Programming Synchronization.
6.852: Distributed Algorithms Spring, 2008 Class 13.
1 Chapter 10 Synchronization Algorithms and Concurrent Programming Gadi Taubenfeld © 2014 Synchronization Algorithms and Concurrent Programming Synchronization.
11/18/20151 Operating Systems Design (CS 423) Elsa L Gunter 2112 SC, UIUC Based on slides by Roy Campbell, Sam.
1 Chapter 2 Synchronization Algorithms and Concurrent Programming Gadi Taubenfeld © 2014 Synchronization Algorithms and Concurrent Programming Synchronization.
CSE 60641: Operating Systems Implementing Fault-Tolerant Services Using the State Machine Approach: a tutorial Fred B. Schneider, ACM Computing Surveys.
Chap 15. Agreement. Problem Processes need to agree on a single bit No link failures A process can fail by crashing (no malicious behavior) Messages take.
Physical clock synchronization Question 1. Why is physical clock synchronization important? Question 2. With the price of atomic clocks or GPS coming down,
Multiprocessor Synchronization Algorithms ( ) Lecturer: Danny Hendler.
Distributed Transaction Management, Fall 2002Lecture 2 / Distributed Locking Jyrki Nummenmaa
Several sets of slides by Prof. Jennifer Welch will be used in this course. The slides are mostly identical to her slides, with some minor changes. Set.
U NIVERSITY OF M ASSACHUSETTS A MHERST Department of Computer Science Computer Systems Principles Synchronization Emery Berger and Mark Corner University.
CS 425/ECE 428 Distributed Systems Nitin Vaidya. T.A.s – Persia Aziz – Frederick Douglas – Su Du – Yixiao Lin.
1 Lecture #24 Shared Objects and Concurrent Programming This material is not available in the textbook. The online powerpoint presentations contain the.
CGS 3763 Operating Systems Concepts Spring 2013 Dan C. Marinescu Office: HEC 304 Office hours: M-Wd 11: :30 AM.
CSE 486/586 CSE 486/586 Distributed Systems Global States Steve Ko Computer Sciences and Engineering University at Buffalo.
CIS 825 Review session. P1: Assume that processes are arranged in a ring topology. Consider the following modification of the Lamport’s mutual exclusion.
Distributed Mutual Exclusion Synchronization in Distributed Systems Synchronization in distributed systems are often more difficult compared to synchronization.
Mutual Exclusion Algorithms. Topics r Defining mutual exclusion r A centralized approach r A distributed approach r An approach assuming an organization.
Hwajung Lee. Mutual Exclusion CS p0 p1 p2 p3 Some applications are:  Resource sharing  Avoiding concurrent update on shared data  Controlling the.
Agenda  Quick Review  Finish Introduction  Java Threads.
Introduction to distributed systems description relation to practice variables and communication primitives instructions states, actions and programs synchrony.
CIS 540 Principles of Embedded Computation Spring Instructor: Rajeev Alur
6/27/20161 Operating Systems Design (CS 423) Elsa L Gunter 2112 SC, UIUC Based on slides by Roy Campbell, Sam King,
Multiprocessor Synchronization Algorithms ( )
Multiprocessor Synchronization Algorithms ( )
Andy Wang Operating Systems COP 4610 / CGS 5765
Liveness And Performance
ITEC452 Distributed Computing Lecture 7 Mutual Exclusion
CIS 720 Lecture 5.
Don Porter Portions courtesy Emmett Witchel
Presentation transcript:

Multiprocess Synchronization Algorithms ( ) Lecturer: Danny Hendler

2 Grade structure 3 (theoretic) problem sets –Up to 30% of grade Take-home exam –At least 70% of grade

3 Adminstrative details -Office 218 -Office hours: Sundays, 3pm-5pm (or make an appointment) -Course site: autumn-2007/course-main.html (or simply enter thru my home page)

4 Books Distributed Computing: Fundamentals, Simulations, and Advanced Topics, Hagit Attiya and Jennifer Welch, John Wiley and Sons Synchronization Algorithms and Concurrent Programming, Gadi Taubenfeld, Pearson/Prentice Hall. Book site:

5 Distributed Systems A distributed system is a collection of individual computing devices that communicate with one another. E.g.: –VLSI chips –Shared-memory multiprocessor –Local-area network –The Internet

6 One sequential model, MANY distributed models Shared-memory / Message-passing –Which operations are allowed (read, write, read- modify-write)? Synchronous, timing-conditions, asynchronous Are failures allowed? –Fail-stop, Byzantine failures, message omission Is the number of processes known?

7 Types of distributed systems Multi-core computers The Internet Peer-to-peer systems Grid computers Wireless networks Sensor networks Ad-hoc networks …

8 Motivating examples of Synchronization

9 The Too-Much-Milk Problem TimeAliceBob 5:00Arrive Home 5:05Look in fridge; no milk 5:10Leave for grocery 5:15Arrive home 5:20Arrive at groceryLook in fridge; no milk 5:25Buy milkLeave for grocery 5:30Arrive home; put milk in fridge 5:40Buy milk 5:45Arrive home; too much milk! Synchronization Algorithms and Concurrent Programming Gadi Taubenfeld © 2006

10 Solving the Too-Much-Milk Problem Required properties  Mutual Exclusion: Only one person buys milk at a time  Progress: Someone always buys milk if it is needed Communication primitives  Leave a note (set a flag)  Remove a note (reset a flag)  Read a note (test the flag) Synchronization Algorithms and Concurrent Programming Gadi Taubenfeld © 2006

11 Important Distinction  Safety Property –Nothing bad happens ever –Example: mutual exclusion  Liveness Property –Something good happens eventually –Example: progress  Safety Property –Nothing bad happens ever –Example: mutual exclusion  Liveness Property –Something good happens eventually –Example: progress Synchronization Algorithms and Concurrent Programming Gadi Taubenfeld © 2006

12 Solution 1 Does it work? Alice if (no milk) { if (no note) { leave Note buy milk remove note } Bob if (no milk) { if (no note) { leave Note buy milk remove note } No, may end up with two milk.  mutual exclusion progress Synchronization Algorithms and Concurrent Programming Gadi Taubenfeld © 2006

13 Solution 2 Alice leave note A if (no note B) { if (no milk) {buy milk} } remove note A Bob leave note B if (no note A) { if (no milk) {buy milk} } remove note B Using labeled notes Does it work? No, may end up with no milk. mutual exclusion  progress Synchronization Algorithms and Concurrent Programming Gadi Taubenfeld © 2006

14 Solution 3 Does it work? Alice leave note A while (note B) {skip} if (no milk) {buy milk} remove note A Bob leave note B if (no note A) { if (no milk) {buy milk} } remove note B No ! a timing assumption is needed mutual exclusion  progress Synchronization Algorithms and Concurrent Programming Gadi Taubenfeld © 2006

15 Is solution #3 a good solution? No  A timing assumption is needed!  Unfair to one of the processes  Alice is busy waiting – consuming CPU cycles without accomplishing useful work  A timing assumption is needed!  Unfair to one of the processes  Alice is busy waiting – consuming CPU cycles without accomplishing useful work Synchronization Algorithms and Concurrent Programming Gadi Taubenfeld © 2006

16 Solution 4 Using 4 labeled notes A1A2B2B1 the fridge’s door Synchronization Algorithms and Concurrent Programming Gadi Taubenfeld © 2006

17 Alice leave A1 if B2 {leave A2} else {remove A2} while B1 and ((A2 and B2) or (no A2 and no B2)) {skip} if (no milk) {buy milk} remove A1 Bob leave B1 if (no A2) {leave B2} else {remove B2} while A1 and ((A2 and no B2) or (no A2 and B2)) {skip} if (no milk) {buy milk} remove B1 Solution 4 A correct, fair, symmetric algorithm! Synchronization Algorithms and Concurrent Programming Gadi Taubenfeld © 2006

18 Solution 4 Notations color: there is a note A1A2B2 Alice’s turn B2 dotted line: there is no note solid line without color: we do not care if there is a note who will buy milk ? XX Synchronization Algorithms and Concurrent Programming Gadi Taubenfeld © 2006

19 A1A2B2 Alice’s turn A1A2B2B1 Alice’s turn A2B2B1 Bob’s turn A1A2B2B1 Alice’s turn A1A2B2B1 Bob’s turn A1A2B2B1 Bob’s turn Solution 4 B2 XX XX Synchronization Algorithms and Concurrent Programming Gadi Taubenfeld © 2006

20 A variant of Solution 4 The order of the first two statements is replaced Is it correct ? No, may end up with two milk. Alice if B2 {leave A2} else {remove A2} leave A1 while B1 and ((A2 and B2) or (no A2 and no B2)) {skip} if (no milk) {buy milk} remove A1 Bob if (no A2) {leave B2} else {remove B2} leave B1 while A1 and ((A2 and no B2) or (no A2 and B2)) {skip} if (no milk) {buy milk} remove B1 MILK Synchronization Algorithms and Concurrent Programming Gadi Taubenfeld © 2006 B2 B1A1

21 A variant of Solution 4 The order of the first two statements is replaced Is it correct ? No, may end up with two milk.  mutual exclusion progress Alice if B2 {leave A2} else {remove A2} leave A1 while B1 and ((A2 and B2) or (no A2 and no B2)) {skip} if (no milk) {buy milk} remove A1 Bob if (no A2) {leave B2} else {remove B2} leave B1 while A1 and ((A2 and no B2) or (no A2 and B2)) {skip} if (no milk) {buy milk} remove B1 MILK Synchronization Algorithms and Concurrent Programming Gadi Taubenfeld © 2006 B2 B1A1

22 The coordinated attack problem Blue army wins if both blue camps attack simultaneously Design an algorithm to ensure that both blue camps attack simultaneously Enemy 12 The problem is due to by Jim Gray (1977) Synchronization Algorithms and Concurrent Programming Gadi Taubenfeld © 2006

23 The coordinated attack problem Communication is done by sending messengers across valley Messengers may be lost or captured by the enemy  Enemy 12 Synchronization Algorithms and Concurrent Programming Gadi Taubenfeld © 2006

24 The coordinated attack problem Theorem: There is no algorithm that solves this problem ! Proof: Assume to the contrary that such an algorithm exits. Let P be an algorithm that solves it with the fewest # of messages, when no message is lost. P should work even when the last messenger is captured. So P should work even if the last messenger is never sent. But this is a new algorithm with one less message. A contradiction.  The model is too weak! Synchronization Algorithms and Concurrent Programming Gadi Taubenfeld © 2006