6.852: Distributed Algorithms Spring, 2008 Class 13.

Slides:



Advertisements
Similar presentations
CSCE 668 DISTRIBUTED ALGORITHMS AND SYSTEMS Fall 2011 Prof. Jennifer Welch CSCE 668 Set 14: Simulations 1.
Advertisements

CIS 540 Principles of Embedded Computation Spring Instructor: Rajeev Alur
1 Chapter 5 Concurrency: Mutual Exclusion and Synchronization Principals of Concurrency Mutual Exclusion: Hardware Support Semaphores Readers/Writers Problem.
Concurrency: Mutual Exclusion and Synchronization Chapter 5.
Automatic Verification Book: Chapter 6. What is verification? Traditionally, verification means proof of correctness automatic: model checking deductive:
Ch. 7 Process Synchronization (1/2) I Background F Producer - Consumer process :  Compiler, Assembler, Loader, · · · · · · F Bounded buffer.
6.852: Distributed Algorithms Spring, 2008 Class 13.
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.
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.
Operating System Concepts and Techniques Lecture 12 Interprocess communication-1 M. Naghibzadeh Reference M. Naghibzadeh, Operating System Concepts and.
Mutual Exclusion.
CH7 discussion-review Mahmoud Alhabbash. Q1 What is a Race Condition? How could we prevent that? – Race condition is the situation where several processes.
6.852: Distributed Algorithms Spring, 2008 Class 16.
CIS 540 Principles of Embedded Computation Spring Instructor: Rajeev Alur
CPSC 668Set 14: Simulations1 CPSC 668 Distributed Algorithms and Systems Spring 2008 Prof. Jennifer Welch.
CPSC 668Set 6: Mutual Exclusion in Shared Memory1 CPSC 668 Distributed Algorithms and Systems Fall 2006 Prof. Jennifer Welch.
1 Distributed Computing Algorithms CSCI Distributed Computing: everything not centralized many processors.
An Introduction to Input/Output Automata Qihua Wang.
Concurrent Processes Lecture 5. Introduction Modern operating systems can handle more than one process at a time System scheduler manages processes and.
OS Spring’04 Concurrency Operating Systems Spring 2004.
Modeling Software Systems Lecture 2 Book: Chapter 4.
Concurrency in Distributed Systems: Mutual exclusion.
Distributed systems Module 2 -Distributed algorithms Teaching unit 1 – Basic techniques Ernesto Damiani University of Bozen Lesson 2 – Distributed Systems.
CPS110: Implementing threads/locks on a uni-processor Landon Cox.
Adopted from and based on Textbook: Operating System Concepts – 8th Edition, by Silberschatz, Galvin and Gagne Updated and Modified by Dr. Abdullah Basuhail,
Operating Systems CSE 411 CPU Management Oct Lecture 13 Instructor: Bhuvan Urgaonkar.
Memory Consistency Models Some material borrowed from Sarita Adve’s (UIUC) tutorial on memory consistency models.
Process Description and Control. Process concepts n Definitions – replaces task, job – program in execution – entity that can be assigned to and executed.
CIS 540 Principles of Embedded Computation Spring Instructor: Rajeev Alur
© 2009 Matthew J. Sottile, Timothy G. Mattson, and Craig E Rasmussen 1 Concurrency in Programming Languages Matthew J. Sottile Timothy G. Mattson Craig.
Parallel Programming Philippas Tsigas Chalmers University of Technology Computer Science and Engineering Department © Philippas Tsigas.
Formal Model for Simulations Instructor: DR. Lê Anh Ngọc Presented by – Group 6: 1. Nguyễn Sơn Hùng 2. Lê Văn Hùng 3. Nguyễn Xuân Hậu 4. Nguyễn Xuân Tùng.
Lecture #12 Distributed Algorithms (I) CS492 Special Topics in Computer Science: Distributed Algorithms and Systems.
Concurrency, Mutual Exclusion and Synchronization.
Concurrency: Mutual Exclusion and Synchronization Chapter 5.
Modelling III: Asynchronous Shared Memory Model Chapter 9 by Nancy A. Lynch presented by Mark E. Miyashita.
CS4231 Parallel and Distributed Algorithms AY 2006/2007 Semester 2 Lecture 3 (26/01/2006) Instructor: Haifeng YU.
Chapter 14 Asynchronous Network Model by Mikhail Nesterenko “Distributed Algorithms” by Nancy A. Lynch.
Mutual Exclusion Presented by: Rohan Sen (Distributed Algorithms Ch. 10)
1 Chapter 9 Synchronization Algorithms and Concurrent Programming Gadi Taubenfeld © 2014 Synchronization Algorithms and Concurrent Programming Synchronization.
1 Chapter 10 Synchronization Algorithms and Concurrent Programming Gadi Taubenfeld © 2014 Synchronization Algorithms and Concurrent Programming Synchronization.
DISTRIBUTED ALGORITHMS AND SYSTEMS Spring 2014 Prof. Jennifer Welch CSCE
Memory Consistency Models. Outline Review of multi-threaded program execution on uniprocessor Need for memory consistency models Sequential consistency.
6.852: Distributed Algorithms Spring, 2008 Class 25-1.
CIS 842: Specification and Verification of Reactive Systems Lecture INTRO-Examples: Simple BIR-Lite Examples Copyright 2004, Matt Dwyer, John Hatcliff,
Model Checking Lecture 1. Model checking, narrowly interpreted: Decision procedures for checking if a given Kripke structure is a model for a given formula.
Program Correctness. The designer of a distributed system has the responsibility of certifying the correctness of the system before users start using.
Presented by: Belgi Amir Seminar in Distributed Algorithms Designing correct concurrent algorithms Spring 2013.
CS 153 Design of Operating Systems Winter 2016 Lecture 7: Synchronization.
Distributed Mutual Exclusion Synchronization in Distributed Systems Synchronization in distributed systems are often more difficult compared to synchronization.
Model Checking Lecture 1: Specification Tom Henzinger.
Introduction to distributed systems description relation to practice variables and communication primitives instructions states, actions and programs synchrony.
6.852: Distributed Algorithms Spring, 2008 Class 14.
CIS 540 Principles of Embedded Computation Spring Instructor: Rajeev Alur
Chapter 10 Mutual Exclusion Presented by Yisong Jiang.
Synchronization Questions answered in this lecture: Why is synchronization necessary? What are race conditions, critical sections, and atomic operations?
Mutual Exclusion with Partial Synchrony
CSCE 668 DISTRIBUTED ALGORITHMS AND SYSTEMS
Chapter 26 Concurrency and Thread
CSE 451: Operating Systems Autumn 2003 Lecture 7 Synchronization
CSE 451: Operating Systems Autumn 2005 Lecture 7 Synchronization
CSE 451: Operating Systems Winter 2003 Lecture 7 Synchronization
CSE 153 Design of Operating Systems Winter 19
CSE 542: Operating Systems
Presentation transcript:

6.852: Distributed Algorithms Spring, 2008 Class 13

Today’s plan The asynchronous shared-memory model The mutual exclusion problem Dijkstra’s algorithm Peterson’s algorithms Lamport’s Bakery algorithm Reading: Chapter 9, , 10.7 Next: Sections

Asynchronous Shared-Memory systems We’ve covered basics of non-fault-tolerant asynchronous network algorithms: –How to model them. –Basic asynchronous network protocols---broadcast, spanning trees, leader election,… –Synchronizers (running synchronous algorithms in asynch networks) –Logical time –Global snapshots Now consider asynchronous shared-memory systems: p1p1 p2p2 pnpn x2x2 x1x1 Processes, interacting via shared objects, possibly subject to some access constraints. Shared objects are typed, e.g.: –Read/write (weak) –Read-modify-write, compare-and-swap (strong) –Queues, stacks, others (in between)

Asynch Shared-Memory systems Theory of ASM systems has much in common with theory of asynchronous networks: –Similar algorithms and impossibility results. –Even with failures. –Transformations from ASM model to asynch network model allow ASM algorithms to run in asynchronous networks. “Distributed shared memory”. Historically, ASM models were studied first: –Arose in study of early operating systems, in which several processes can run on a single processor, sharing memory, with possibly-arbitrary interleavings of steps. Currently, ASM models apply to multiprocessor shared- memory systems, in which several processes can run on separate processors and share memory.

Topics Define the basic system model, without failures. Use it to study basic problems: –Mutual exclusion. –Other resource-allocation problems. Introduce process failures into the model. Use model with failures to study basic problems: –Distributed consensus –Implementing atomic objects: Atomic snapshot objects Atomic read/write registers Wait-free and fault-tolerant computability theory Modern shared-memory multiprocessors: –Practical issues –Algorithms –Transactional memory

Basic ASM Model, Version 1 Processes + objects, modeled as automata. Arrows: –Represent invocations and responses for operations on the objects. –Modeled as input and output actions. Fine-granularity model, can describe: –Gap between invocation and response. –Concurrent (overlapping) operations: Object could reorder. Could allow them to run concurrently, interfering with each other. We’ll begin with a simpler, coarser model: –Object runs ops in invocation order, one at a time. –In fact, collapse each operation into a single step. Return to the finer model later. p1p1 p2p2 pnpn x2x2 x1x1 invoke(read) respond(v) p1p1 x1x1 invoke(write,v) respond() p1p1 x1x1

Basic ASM Model, Version 2 One big shared memory system automaton A. External actions at process “ports”. Each process i has: –A set states i of states. –A subset start i, of start states. Each variable x has: –A set values x of values it can take on. –A subset initial x of initial values. p1p1 p2p2 pnpn x1x1 x2x2 A Automaton A: –States: State for each process, a value for each variable. –Start: Start states, initial values. –Actions: Each action associated with one process, and some also with a single shared variable. –Input/output actions: At the external boundary. –Transitions: Correspond to local process steps and variable accesses. Action enabling, which variable is accessed, depend only on process state. Changes to variable and process state depend also on variable value. Must respect the type of the variable. –Tasks: One or more per process (threads).

Basic ASM Model Execution of A: –As specified by general definitions of executions, fair executions for I/O automata. –By fairness definition, each task gets infinitely many chances to take steps. –Model environment as a separate automaton, to express restrictions on environment behavior. p1p1 p2p2 pnpn x1x1 x2x2 A Commonly-used variable types: –Read/write registers: Most basic primitive. Allows access using separate read and write operations. –Read-modify-write: More powerful primitive: Atomically, read variable, do local computation, write to variable. –Compare-and-swap, fetch-and-add, queues, stacks, etc. Different results hold for different variable types.

The Mutual Exclusion Problem Share one resource among n user processes, U 1, U 2,…,U n. –E.g., printer, portion of a database. U i has four “regions”. –Subsets of its states, described by portions of its code. –C critical; R remainder; T trying; E exit Cycle: Architecture: –U i s and A are IOAs, compose. RTCE p1p1 p2p2 pnpn x1x1 x2x2 A U1U1 U2U2 UnUn Protocols for obtaining and relinquishing the resource

The Mutual Exclusion Problem Actions at user interface: –Connect U i to P i –p i is U i ’s “agent” Correctness conditions: –Well-formedness (Safety): System also obeys cyclic discipline. E.g., doesn’t grant resource when it wasn’t requested. –Mutual exclusion (Safety): System never grants to > 1 user simultaneously. Trace safety property. Or, there’s no reachable system state in which >1 user is in C at once. –Progress (Liveness): From any point in a fair execution: –If some user is in T and no user is in C then at some later point, some user enters C. –If some user is in E then at some later point, some user enters R. p1p1 p2p2 pnpn x1x1 x2x2 A U1U1 U2U2 UnUn pipi UiUi try i crit i exit i rem i

The Mutual Exclusion Problem Well-formedness (Safety): –System obeys cyclic discipline. Mutual exclusion (Safety): –System never grants to > 1 user. Progress (Liveness): –From any point in a fair execution: If some user is in T and no user is in C then at some later point, some user enters C. If some user is in E then at some later point, some user enters R. p1p1 p2p2 pnpn x1x1 x2x2 A U1U1 U2U2 UnUn Conditions on the system automaton A, not the users. –System determines if/when users enter C and R. –Users determine if/when users enter T and E. –We don’t state any requirements on the users, but assume that users respect well-formedness.

The Mutual Exclusion Problem Well-formedness (Safety): Mutual exclusion (Safety): Progress (Liveness): –From any point in a fair execution: If some user is in T and no user is in C then at some later point, some user enters C. If some user is in E then at some later point, some user enters R. p1p1 p2p2 pnpn x1x1 x2x2 A U1U1 U2U2 UnUn Fairness assumption: –Progress condition requires fairness assumption (all process tasks continue to get turns to take steps). –Needed to guarantee that some process enters C or R. –In general, in the asynchronous model, liveness properties require fairness assumptions. –Contrast: Well-formedness and mutual exclusion are safety properties, don’t depend on fairness.

One more assumption… No permanently active processes. –Locally-controlled actions enabled only when user is in T or E. –No always-awake, dedicated processes. –Motivation: Multiprocessor settings, where users can run processes at any time, but are otherwise not involved in the protocol. Avoid “wasting a processor”.