Computing with anonymous processes

Slides:



Advertisements
Similar presentations
1 © R. Guerraoui Universal constructions R. Guerraoui Distributed Programming Laboratory.
Advertisements

Mutual Exclusion – SW & HW By Oded Regev. Outline: Short review on the Bakery algorithm Short review on the Bakery algorithm Black & White Algorithm Black.
1 © R. Guerraoui The Limitations of Registers R. Guerraoui Distributed Programming Laboratory.
N-Consensus is the Second Strongest Object for N+1 Processes Eli Gafni UCLA Petr Kuznetsov Max Planck Institute for Software Systems.
Database Systems Lecture 16 Natasha Alechina
Database Systems (資料庫系統)
1 Concurrency Control Chapter Conflict Serializable Schedules  Two actions are in conflict if  they operate on the same DB item,  they belong.
© 2005 P. Kouznetsov Computing with Reads and Writes in the Absence of Step Contention Hagit Attiya Rachid Guerraoui Petr Kouznetsov School of Computer.
Concurrency Control II
CS492B Analysis of Concurrent Programs Lock Basics Jaehyuk Huh Computer Science, KAIST.
1 © R. Guerraoui The Power of Registers Prof R. Guerraoui Distributed Programming Laboratory.
Mutual Exclusion By Shiran Mizrahi. Critical Section class Counter { private int value = 1; //counter starts at one public Counter(int c) { //constructor.
1 © R. Guerraoui Implementing the Consensus Object with Timing Assumptions R. Guerraoui Distributed Programming Laboratory.
1 © R. Guerraoui Object implementations out of faulty base objects Prof R. Guerraoui Distributed Programming Laboratory.
1 © R. Guerraoui - Shared Memory - R. Guerraoui Distributed Programming Laboratory lpdwww.epfl.ch.
CPSC 668Set 12: Causality1 CPSC 668 Distributed Algorithms and Systems Fall 2009 Prof. Jennifer Welch.
What Can Be Implemented Anonymously ? Paper by Rachid Guerraui and Eric Ruppert Presentation by Amir Anter 1.
1 © R. Guerraoui Concurrent Algorithms (Overview) Prof R. Guerraoui Distributed Programming Laboratory.
1 © R. Guerraoui Regular register algorithms R. Guerraoui Distributed Programming Laboratory lpdwww.epfl.ch.
Distributed systems Consensus Prof R. Guerraoui Distributed Programming Laboratory.
1 © R. Guerraoui Registers Prof R. Guerraoui Distributed Programming Laboratory.
Hashing. Search Given: Distinct keys k 1, k 2, …, k n and collection T of n records of the form (k 1, I 1 ), (k 2, I 2 ), …, (k n, I n ) where I j is.
“Towards Self Stabilizing Wait Free Shared Memory Objects” By:  Hopeman  Tsigas  Paptriantafilou Presented By: Sumit Sukhramani Kent State University.
Distributed Algorithms (22903) Lecturer: Danny Hendler The Atomic Snapshot Object The Renaming Problem This presentation is based on the book “Distributed.
“Distributed Algorithms” by Nancy A. Lynch SHARED MEMORY vs NETWORKS Presented By: Sumit Sukhramani Kent State University.
1 Chapter 11 Global Properties (Distributed Termination)
1 © R. Guerraoui Set-Agreement (Generalizing Consensus) R. Guerraoui.
Lecture 5 Page 1 CS 111 Summer 2013 Bounded Buffers A higher level abstraction than shared domains or simple messages But not quite as high level as RPC.
Multiprocessors – Locks
Distributed Algorithms (22903)
CSCE 668 DISTRIBUTED ALGORITHMS AND SYSTEMS
16 Searching and Sorting.
Andreas Klappenecker [partially based on the slides of Prof. Welch]
CSCE 668 DISTRIBUTED ALGORITHMS AND SYSTEMS
Atomic register algorithms
Lecture 19: Coherence and Synchronization
Faster Data Structures in Transactional Memory using Three Paths
CSCE 411 Design and Analysis of Algorithms
Computing with anonymous processes
Distributed Algorithms (22903)
Hash functions Open addressing
Algebraic Topology and Distributed Computing part two
Algorithm design and Analysis
CSCE 668 DISTRIBUTED ALGORITHMS AND SYSTEMS
Consistency Models.
Distributed Algorithms (22903)
Hashing.
Producer-Consumer Problem
Lecture 21: Synchronization and Consistency
Hash Tables Chapter 12 discusses several ways of storing information in an array, and later searching for the information. Hash tables are a common.
Lecture: Coherence and Synchronization
Distributed Algorithms (22903)
Distributed Algorithms (22903)
Distributed Algorithms (22903)
Distributed Algorithms (22903)
CSCE 411 Design and Analysis of Algorithms
Lecture 20: Intro to Transactions & Logging II
Hash Tables Chapter 12 discusses several ways of storing information in an array, and later searching for the information. Hash tables are a common.
Hash Tables Chapter 12 discusses several ways of storing information in an array, and later searching for the information. Hash tables are a common.
Lecture 1: Introduction
Distributed Algorithms (22903)
Distributed Algorithms (22903)
Deterministic Objects: Life Beyond Consensus
Constructing Reliable Registers From Unreliable Byzantine Components
- Atomic register specification -
R. Guerraoui Distributed Programming Laboratory lpdwww.epfl.ch
Distributed systems Consensus
Concurrency control (OCC and MVCC)
R. Guerraoui Distributed Programming Laboratory lpdwww.epfl.ch
CSCE 411 Design and Analysis of Algorithms
Presentation transcript:

Computing with anonymous processes Prof R. Guerraoui Distributed Programming Laboratory © R. Guerraoui

Counter (sequential spec) A counter has two operations inc() and read() and maintains an integer x init to 0 read(): return(x) inc(): x := x + 1; return(ok)

Counter (atomic implementation) The processes share an array of SWMR registers Reg1,..,n ; the writer of register Regi is pi inc(): temp := Regi.read() + 1; Regi.write(temp); return(ok)

Counter (atomic implementation) read(): sum := 0; for j = 1 to n do sum := sum + Regj.read(); return(sum)

Weak Counter A weak counter has one operation wInc() wInc(): x := x + 1; return(x) correctness: if an operation precedes another, then the second returns a value that is larger than the first one (regularity vs atomicity) An operation should not return a value that is higher than the number of operations that occured Two concurrent operations can return the same value

Weak counter execution wInc() - 1 p1 wInc() - 2 p2 wInc() - 2 p3

(lock-free implementation) Weak Counter (lock-free implementation) The processes share an (infinite) array of MWMR registers Reg1,..,n,..,, init to 0 wInc(): i := 0; while (Regi.read() ≠ 0) do i := i + 1; Regi.write(1); return(i); Every process looks for a free place to store a value; if an operation wInc1 precedes wInc2, then wInc2 returns a higher value

Weak counter execution wInc() - 1 wInc() - 2 wInc() - p1 p2 wInc() - p3

(wait-free implementation) Weak Counter (wait-free implementation) The processes also use a MWMR register L wInc(): i : = 0; while (Regi.read() ≠ 0) do if L has been updated n times then return the largest value seen in L i := i + 1; L.write(i); Regi.write(1); return(i); The trick here is for the fastest process to help the slow ones; if a fast process updates L while a slow one is trying to wInc, then the slow can return that value; the slow one needs to make sure that the fast one did not finish earlier… so we need to wait for n updates (at least one updated twice since wInc of the slow started) It is impotant to return the largest value in L otherwise a process might write a smaller value

(wait-free implementation) Weak Counter (wait-free implementation) wInc(): t:= l := L.read(); i := 0; while (Regi.read() ≠ 0) do if L.read() ≠ l then l := L.read(); t := max(t,l); k := k+1 if k = n then return(t) i := i + 1; L.write(i); Regi.write(1); return(i);

Snapshot (sequential spec) A snapshot has operations update() and scan() and maintains an array x of size n scan(): return(x) NB. No component is devoted to a process update(i,v): xi := v; return(ok)

Key idea for atomicity & wait-freedom The processes share a Weak Counter: Wcounter, init to 0; The processes share an array of registers Reg1,..,N that contains each: a value, a timestamp, and a copy of the entire array of values The main modification is the way we get the counter value; Updating is trivial: we get a timestamp and we write To scan, we need to read until we find the same values; now we need to make sure that enough reads are the same; in a non anonymous system, it is ok to see n same reads;

& wait-freedom (cont’d) Key idea for atomicity & wait-freedom (cont’d) To scan, a process keeps collecting and returns a collect if it did not change, or some collect returned by a concurrent scan Timestamps are used to check if a scan has been taken in the meantime To update, a process scans and writes the value, the new timestamp and the result of the scan A process needs to see q = m(n-1) + 2 similar values to return a scan

Snapshot implementation Every process keeps a local timestamp ts update(i,v): ts := Wcounter.wInc(); Regi.write(v,ts,self.scan()); return(ok)

Snapshot implementation scan(): ts := Wcounter.wInc(); while(true) do If some Regj contains a collect with a higher timestamp than ts, then return that collect If n+1 sets of reads return identical results then return that one In the traditional lock-free scan, if two are the same, then we can return them

Consensus (obstruction-free) We consider binary consensus The processes share two infinite arrays of registers: Reg0i and Reg1i Every process holds an integer i init to 1 Idea: to impose a value v, a process needs to be fast enough to fill in registers Regvi

Consensus (obstruction-free) propose(v): while(true) do If Reg1-vi = 0 then Regvi := 1; if i > 1 and Reg1-vi-1 = 0 then return(v); else v:= 1-v; i := i+1; end Assume p is alone and proposes 1; p looks at Reg0(1); if it is empty, p moves to Reg1(1) and fills it; then p goes to Reg0(2), if it is empty, then p fills in Reg1(2); if Reg1(1) is still empty then p decides 0; so if p proposing 1 is running alone, it decides 1 if Reg0(1) and Reg0(2) are empty and p fills in Reg1(1) and Reg2(1); If q comes later with 1 (all fine); if q comes with 0; q finds Reg1(1) = 1 and Reg2(1) = 1;

Consensus (solo process) q(1) Reg0(1)=0 Reg1(1):=1 Reg0(2)=0 A solo process running alone needs to read in two registers and write in two registers; if it finds a value, Reg1(2):=1 Reg0(1)=0

Consensus (lock-step) q(1) p(0) Reg0(1)=0 Reg1(1)=0 Reg1(1):=1 Reg0(1):=1 Reg0(2)=0 Reg1(2)=0 Reg1(2):=1 Reg0(2):=1 Reg0(1)=1 Reg0(1)=1

Consensus (binary) propose(v): while(true) do If Reg1-vi = 0 then if i > 1 and Reg1-vi-1 = 0 then return(v); else if Regvi = 0 then v:= 1-v; if v = 1 then wait(2i) i := i+1; end