1 © R. Guerraoui The Power of Registers Prof R. Guerraoui Distributed Programming Laboratory.

Slides:



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

1 Lecture 20: Synchronization & Consistency Topics: synchronization, consistency models (Sections )
Mutual Exclusion – SW & HW By Oded Regev. Outline: Short review on the Bakery algorithm Short review on the Bakery algorithm Black & White Algorithm Black.
Concurrency Control III. General Overview Relational model - SQL Formal & commercial query languages Functional Dependencies Normalization Physical Design.
1 © R. Guerraoui The Limitations of Registers R. Guerraoui Distributed Programming Laboratory.
1 Concurrency Control Chapter Conflict Serializable Schedules  Two actions are in conflict if  they operate on the same DB item,  they belong.
Global Environment Model. MUTUAL EXCLUSION PROBLEM The operations used by processes to access to common resources (critical sections) must be mutually.
Ch 7 B.
Parallel and Distributed Simulation Global Virtual Time - Part 2.
Time Warp: Global Control Distributed Snapshots and Fossil Collection.
1 ICS 214B: Transaction Processing and Distributed Data Management Lecture 5: Tree-based Concurrency Control and Validation Currency Control Professor.
Ch. 7 Process Synchronization (1/2) I Background F Producer - Consumer process :  Compiler, Assembler, Loader, · · · · · · F Bounded buffer.
Process Synchronization. Module 6: Process Synchronization Background The Critical-Section Problem Peterson’s Solution Synchronization Hardware Semaphores.
CPSC 668Set 18: Wait-Free Simulations Beyond Registers1 CPSC 668 Distributed Algorithms and Systems Fall 2006 Prof. Jennifer Welch.
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.
CMPT Dr. Alexandra Fedorova Lecture X: Transactions.
1 © R. Guerraoui - Shared Memory - R. Guerraoui Distributed Programming Laboratory lpdwww.epfl.ch.
CMPT 431 Dr. Alexandra Fedorova Lecture VIII: Time And Global Clocks.
CPSC 668Set 17: Fault-Tolerant Register Simulations1 CPSC 668 Distributed Algorithms and Systems Fall 2009 Prof. Jennifer Welch.
Distributed Algorithms (22903) Lecturer: Danny Hendler Shared objects: linearizability, wait-freedom and simulations Most of this presentation is based.
What Can Be Implemented Anonymously ? Paper by Rachid Guerraui and Eric Ruppert Presentation by Amir Anter 1.
Distributed Systems Fall 2009 Replication Fall 20095DV0203 Outline Group communication Fault-tolerant services –Passive and active replication Highly.
1 Lecture 15: Consistency Models Topics: sequential consistency, requirements to implement sequential consistency, relaxed consistency models.
A. Frank - P. Weisberg Operating Systems Introduction to Cooperating Processes.
5.1 The Greatest Common Factor; Factoring by Grouping
CS510 Concurrent Systems Introduction to Concurrency.
Chapter 6 Section 1 Copyright © 2008 Pearson Education, Inc. Publishing as Pearson Addison-Wesley.
©The McGraw-Hill Companies, Inc. Permission required for reproduction or display. 4 th Ed Chapter Chapter 11 Sorting and Searching.
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.
Silberschatz, Galvin and Gagne ©2013 Operating System Concepts Essentials – 9 th Edition Chapter 5: Process Synchronization.
Common2 extended to stacks and unbound concurrency By:Yehuda Afek Eli Gafni Adam Morrison May 2007 Presentor: Dima Liahovitsky 1.
Distributed systems Consensus Prof R. Guerraoui Distributed Programming Laboratory.
1 © R. Guerraoui Registers Prof R. Guerraoui Distributed Programming Laboratory.
Hwajung Lee.  Improves reliability  Improves availability ( What good is a reliable system if it is not available?)  Replication must be transparent.
Replication Improves reliability Improves availability ( What good is a reliable system if it is not available?) Replication must be transparent and create.
Asynchronous Exclusive Selection Bogdan Chlebus, U. Colorado Darek Kowalski, U. Liverpool.
A SPMD Model for OCR Sanjay Chatterjee 2/9/2015 Intel Confidential1.
Java – An Object Oriented Language CS 307 Lecture Notes Lecture Weeks 5-6 Khalid Siddiqui.
“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)
Distributed Algorithms (22903) Lecturer: Danny Hendler Shared objects: linearizability, wait-freedom and simulations Most of this presentation is based.
1 © R. Guerraoui Set-Agreement (Generalizing Consensus) R. Guerraoui.
Atomic snapshots in O(log³ n) steps 1. Snapshot Objects p1p1 p1p1 p2p2 p2p2 pnpn pnpn … … update( v ) scan 2 update your location read all locations.
Concurrency control.
CSCE 668 DISTRIBUTED ALGORITHMS AND SYSTEMS
Atomic register algorithms
Computing with anonymous processes
Distributed Algorithms (22903)
CSCE 668 DISTRIBUTED ALGORITHMS AND SYSTEMS
Distributed Algorithms (22903)
Replication Improves reliability Improves availability
Distributed Algorithms (22903)
Week 6 CPS125.
Distributed Algorithms (22903)
Lecture 10: Consistency Models
Chapter 6 Section 1.
Distributed Algorithms (22903)
Distributed Algorithms (22903)
Constructing Reliable Registers From Unreliable Byzantine Components
Distributed Algorithms (22903)
- 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
Lecture 11: Consistency Models
Presentation transcript:

1 © R. Guerraoui The Power of Registers Prof R. Guerraoui Distributed Programming Laboratory

2 Atomic execution p1 p2 p3 write(1) - ok read() - 1

3 Atomic execution p1 p2 p3 write(1) - ok read() - 1 read() - 0

4 Registers Question 1: what objects can we implement with registers? (this lecture) Question 2: what objects we cannot implement? (next lecture)

5 Wait-free implementations of atomic objects An atomic object is simply defined by its sequential specification; i.e., by how its operations should be implemented when there is no concurrency Implementations should be wait-free: every process that invokes eventually gets a reply (unless the process crashes)

6 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)

7 Naive implementation The processes share one register Reg read(): return(Reg.read()) inc(): temp:= Reg.read()+1; Reg.write(temp); return(ok)

8 Atomic execution? p1 p2 p3 inc() - ok read() - 1 inc() - ok

9 Atomic implementation The processes share an array of registers Reg  1,..,n  inc(): temp := Reg  i .read() +1; Reg  i .write(temp); return(ok)

10 Atomic execution? p1 p2 p3 inc() - ok read() - 2 inc() - ok

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

12 Snapshot (sequential spec) A snapshot has operations update() and scan() and maintains an array x of size n scan(): return(x) update(i,v): x  i  := v; return(ok)

13 Very naive implementation Each process maintains an array of integer variables x init to  0,..,0  scan(): return(x) update(i,v): x  i  := v; return(ok)

14 Atomic execution? p1 p2 p3 update(1,1) - ok collect() -  0,0,0 

15 Less naive implementation The processes share one array of N registers Reg  1,..,N  scan(): for j = 1 to N do x  j  := Reg  j .read(); return(x) update(i,v): Reg  i .write(v); return(ok)

16 Atomic execution? p1 p2 p3 update(1,1) - ok collect() -  1,0,0 

17 Atomic execution? p1 p2 p3 update(1,1) - ok scan() -  1,0,2  update(3,2) - ok

18 Atomic execution? p1 p2 p3 scan() -  0,0,10  update(2,1) - ok update(3,10) - ok

19 Non-atomic vs atomic snapshot What we implement here is some kind of regular snapshot: A scan returns, for every index of the snapshot, the last written values or the value of any concurrent update We call it collect

20 Key idea for atomicity To scan, a process keeps reading the entire snapshot (i.e., it collect), until two results at the same This means that the snapshot did not change, and it is safe to return without violating atomicity

21 Same value vs. Same timestamp p1 p2 p3 scan() -  0,0,2  collect()-  0,0,2  update(2,0) collect()-  0,0,2  update(2,1) update(3,2) update(2,1)update(2,0)update(2,1) update(3,2)update(3,0)

22 Enforcing atomicity The processes share one array of N registers Reg  1,..,N  ; each contains a value and a timestamp We use the following operation for modularity collect(): for j = 1 to N do x  j  := Reg  j .read(); return(x)

23 Enforcing atomicity (cont’d) scan(): temp1 := self.collect(); while(true) do temp2 := self.collect(); temp1 := temp2; if (temp1 = temp2) then return (temp1.val) update(i,v): ts := ts + 1; Reg  i .write(v,ts); return(ok)

24 Wait-freedom? p1 p2 p3 scan() - … collect()-  0,0,10  update(3,10) - ok update(2,1) - ok collect()-  0,1,10  update(2,3) - ok

25 Key idea for atomicity & wait-freedom 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

26 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 the collect changes or 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

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

28 Snapshot implementation scan(): t1 := self.collect(); t2:= t1 while(true) do t3:= self.collect(); if (t3 = t2) then return (t3  j,3  ); for j = 1 to N do if(t3  j,2  ≥ t1  j,2  +2) then return (t3  j,3  ) t2 := t3

29 Possible execution? p1 p2 p3 scan() -  0,0,3  update(3,2) -ok update(3,1)-ok update(3,3) -ok