Computing with anonymous processes

Slides:



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

Time-based Transactional Memory with Scalable Time Bases Torvald Riegel, Christof Fetzer, Pascal Felber Presented By: Michael Gendelman.
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.
© 2005 P. Kouznetsov Computing with Reads and Writes in the Absence of Step Contention Hagit Attiya Rachid Guerraoui Petr Kouznetsov School of Computer.
The weakest failure detector question in distributed computing Petr Kouznetsov Distributed Programming Lab EPFL.
1 © R. Guerraoui The Power of Registers Prof R. Guerraoui Distributed Programming Laboratory.
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.
Silberschatz, Galvin and Gagne ©2013 Operating System Concepts – 9 th Edition Chapter 5: Process Synchronization.
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.
Ordering and Consistent Cuts Presented By Biswanath Panda.
1 © R. Guerraoui - Shared Memory - R. Guerraoui Distributed Programming Laboratory lpdwww.epfl.ch.
What Can Be Implemented Anonymously ? Paper by Rachid Guerraui and Eric Ruppert Presentation by Amir Anter 1.
© 1997 UW CSE 11/13/97N-1 Concurrency Control Chapter 18.1, 18.2, 18.5, 18.7.
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.
“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.
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
Memory Management Damian Gordon.
CSCE 668 DISTRIBUTED ALGORITHMS AND SYSTEMS
16 Searching and Sorting.
Concurrency control.
Interprocess Communication Race Conditions
Data Structures Using C++ 2E
Outline lecture Revise arrays Entering into an array
Synchronization: Distributed Deadlock Detection
CSC 427: Data Structures and Algorithm Analysis
Atomic register algorithms
Background on the need for Synchronization
Lecture 14 Searching and Sorting Richard Gesick.
Lecture 19: Coherence and Synchronization
Faster Data Structures in Transactional Memory using Three Paths
Distributed Algorithms (22903)
Distributed Algorithms (22903)
Algebraic Topology and Distributed Computing part two
While loops The while loop executes the statement over and over as long as the boolean expression is true. The expression is evaluated first, so the statement.
Algorithm design and Analysis
CSCE 668 DISTRIBUTED ALGORITHMS AND SYSTEMS
Consistency Models.
Distributed Algorithms (22903)
Concurrency Control II (OCC, MVCC)
Chapter 8 Search and Sort
Hashing.
Lecture 11 Searching and Sorting Richard Gesick.
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)
Group Mutual Exclusion & Hadzilacos Algorithm
Distributed Algorithms (22903)
Lecture 20: Intro to Transactions & Logging II
CSC 427: Data Structures and Algorithm Analysis
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)
Deterministic Objects: Life Beyond Consensus
Constructing Reliable Registers From Unreliable Byzantine Components
- Atomic register specification -
R. Guerraoui Distributed Programming Laboratory lpdwww.epfl.ch
Computing with anonymous processes
Distributed systems Consensus
Concurrency control (OCC and MVCC)
R. Guerraoui Distributed Programming Laboratory lpdwww.epfl.ch
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) We focus on a simple counter that can be implemented with a register One with different operations: read and inc()

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 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 important to return the largest value in L otherwise a process might write a smaller value; In fact, we ensure that if pi returns a value from pj, then pj started after pi started

(wait-free implementation) Weak Counter (wait-free implementation) wInc(): t := l := L.read(); i := k:= 0; while (Regi.read() ≠ 0) do i : = i + 1; if L.read() ≠ l then l := L.read(); t := max(t,l); k :=k+1; if k = n then return(t); 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 index integer i, init to 1 Idea: to impose a value v, a process needs to be fast enough to fill in registers in Regvi Value 0 #1 #2 #3 #4 … Value 1 #1 #2 #3 #4 …

If we’re leading by 2, we won! If we’re losing, I switch teams! Consensus (obstruction-free) My team may be winning 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 Score 1 for my team If we’re leading by 2, we won! 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; If we’re losing, I switch teams!

A simple execution Team 0 vs Team 1 Solo execution: Process p1 (green) comes in alone, and marks the first two slots of Reg1 Processes that come later either have value 1 and decide 1, or switch to value 1 and decide 1 Value 0 #1 #2 #3 #4 … Value 1 #1 #2 #3 #4 … 1

Lock-step execution Team 0 vs Team 1 Lock-step: If the two processes proceed in perfect lock-step, then the algorithm will go on forever Obstruction-free, but not wait-free Value 0 #1 #2 #3 #4 … Value 1 #1 #2 #3 #4 … 1

Algorithm tip When designing a concurrent algorithm, it helps to first check correctness in solo and lock-step executions

Can we make it wait-free? We need to assume eventual synchrony Definition: In every execution, there exists a time GST (global stabilization time) after which the processes’ internal clocks are perfectly synchronized

One of the teams becomes slower! Consensus (binary) 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 if Regvi = 0 then v:= 1-v; if v = 1 then wait(2i) i := i+1; end One of the teams becomes slower!

Wait-free (intuition) Team 0 vs Team 1 Lock-step: The processes in team 1 have to wait for 2i steps after each loop Hence, eventually, they become so slow that team 0 wins Value 0 #1 #2 #3 #4 … Value 1 #1 #2 #3 #4 … 1

References Writeup containing all algorithms and more: http://ic2.epfl.ch/publications/documents/IC_TECH_REPORT_200496.pdf