1 © r. guerraoui seth gilbert professor: rachid guerraoui assistants: m. kapalka and a. dragojevic...
TRANSCRIPT
![Page 1: 1 © R. Guerraoui Seth Gilbert Professor: Rachid Guerraoui Assistants: M. Kapalka and A. Dragojevic Distributed Programming Laboratory](https://reader036.vdocuments.us/reader036/viewer/2022062804/56649dd05503460f94ac56ce/html5/thumbnails/1.jpg)
© R. Guerraoui 1
Seth Gilberthttp://lpd.epfl.ch
Professor: Rachid Guerraoui
Assistants: M. Kapalka and A. Dragojevic
Distributed Programming Laboratory
Special Topics in
Distributed Computing:
Shared Memory Algorithms
![Page 2: 1 © R. Guerraoui Seth Gilbert Professor: Rachid Guerraoui Assistants: M. Kapalka and A. Dragojevic Distributed Programming Laboratory](https://reader036.vdocuments.us/reader036/viewer/2022062804/56649dd05503460f94ac56ce/html5/thumbnails/2.jpg)
2
This course introduces a theory of robust and concurrent computing…
![Page 3: 1 © R. Guerraoui Seth Gilbert Professor: Rachid Guerraoui Assistants: M. Kapalka and A. Dragojevic Distributed Programming Laboratory](https://reader036.vdocuments.us/reader036/viewer/2022062804/56649dd05503460f94ac56ce/html5/thumbnails/3.jpg)
3
Major chip manufacturers have recently announced a major paradigm shift:
New York Times, 8 May 2004:Intel … [has] decided to focus its development efforts on «dual core» processors … with two engines instead of one, allowing for greater efficiency because the processor workload is essentially shared.
Multi-processors and Multicoresvs
faster processors
(Thanks for the quote, Maurice Herlihy.)
![Page 4: 1 © R. Guerraoui Seth Gilbert Professor: Rachid Guerraoui Assistants: M. Kapalka and A. Dragojevic Distributed Programming Laboratory](https://reader036.vdocuments.us/reader036/viewer/2022062804/56649dd05503460f94ac56ce/html5/thumbnails/4.jpg)
4
The clock speed of a processor cannot be increased without overheating.
But
More and more processors can fit in the same space.
![Page 5: 1 © R. Guerraoui Seth Gilbert Professor: Rachid Guerraoui Assistants: M. Kapalka and A. Dragojevic Distributed Programming Laboratory](https://reader036.vdocuments.us/reader036/viewer/2022062804/56649dd05503460f94ac56ce/html5/thumbnails/5.jpg)
5
(hat tip: Simon Peyton-Jones)
Clock speed
flattening sharply
Transistor count still
rising
Slide borrowed from Maurice Herlihy’s talk at PODC 2008:
“The Future of Distributed Computing: Renaissance or Reformation?”
![Page 6: 1 © R. Guerraoui Seth Gilbert Professor: Rachid Guerraoui Assistants: M. Kapalka and A. Dragojevic Distributed Programming Laboratory](https://reader036.vdocuments.us/reader036/viewer/2022062804/56649dd05503460f94ac56ce/html5/thumbnails/6.jpg)
6
Speed will be achieved by having several processors work on independent parts of a task.
But
The processors would occasionally need to pause and synchronize.
But
If the task is shared, then pure parallelism is usually impossible and, at best, inefficient.
![Page 7: 1 © R. Guerraoui Seth Gilbert Professor: Rachid Guerraoui Assistants: M. Kapalka and A. Dragojevic Distributed Programming Laboratory](https://reader036.vdocuments.us/reader036/viewer/2022062804/56649dd05503460f94ac56ce/html5/thumbnails/7.jpg)
7
Concurrent computing for the masses
Forking processes might be more frequent
But…
Concurrent accesses to shared objects might become more problematic and harder.
![Page 8: 1 © R. Guerraoui Seth Gilbert Professor: Rachid Guerraoui Assistants: M. Kapalka and A. Dragojevic Distributed Programming Laboratory](https://reader036.vdocuments.us/reader036/viewer/2022062804/56649dd05503460f94ac56ce/html5/thumbnails/8.jpg)
8
How do devices synchronize?
Shared object
Concurrent processes
![Page 9: 1 © R. Guerraoui Seth Gilbert Professor: Rachid Guerraoui Assistants: M. Kapalka and A. Dragojevic Distributed Programming Laboratory](https://reader036.vdocuments.us/reader036/viewer/2022062804/56649dd05503460f94ac56ce/html5/thumbnails/9.jpg)
9
Locking (mutual exclusion)
How do devices synchronize?
![Page 10: 1 © R. Guerraoui Seth Gilbert Professor: Rachid Guerraoui Assistants: M. Kapalka and A. Dragojevic Distributed Programming Laboratory](https://reader036.vdocuments.us/reader036/viewer/2022062804/56649dd05503460f94ac56ce/html5/thumbnails/10.jpg)
10
Locked object
One process at a time
How do devices synchronize?
![Page 11: 1 © R. Guerraoui Seth Gilbert Professor: Rachid Guerraoui Assistants: M. Kapalka and A. Dragojevic Distributed Programming Laboratory](https://reader036.vdocuments.us/reader036/viewer/2022062804/56649dd05503460f94ac56ce/html5/thumbnails/11.jpg)
11
Locking (mutual exclusion)
Difficult: 50% of the bugs reported in Java come from the use of « synchronized »
Fragile: a process holding a lock prevents all others from progressing
Other: deadlock, livelock, priority inversion, etc.
How do devices synchronize?
![Page 12: 1 © R. Guerraoui Seth Gilbert Professor: Rachid Guerraoui Assistants: M. Kapalka and A. Dragojevic Distributed Programming Laboratory](https://reader036.vdocuments.us/reader036/viewer/2022062804/56649dd05503460f94ac56ce/html5/thumbnails/12.jpg)
12
Processes are asynchronous
Page faultsPre-emptionsFailuresCache misses, …
A process can be delayed by millions of instructions …
Why is locking hard?
![Page 13: 1 © R. Guerraoui Seth Gilbert Professor: Rachid Guerraoui Assistants: M. Kapalka and A. Dragojevic Distributed Programming Laboratory](https://reader036.vdocuments.us/reader036/viewer/2022062804/56649dd05503460f94ac56ce/html5/thumbnails/13.jpg)
13
Alternative to locking?
![Page 14: 1 © R. Guerraoui Seth Gilbert Professor: Rachid Guerraoui Assistants: M. Kapalka and A. Dragojevic Distributed Programming Laboratory](https://reader036.vdocuments.us/reader036/viewer/2022062804/56649dd05503460f94ac56ce/html5/thumbnails/14.jpg)
14
Wait-free atomic objects
Wait-freedom: every process that invokes an operation eventually returns from the invocation o Robust … unlike locking.
Atomicity: every operation appears to execute instantaneously. o As if the object were locked.
![Page 15: 1 © R. Guerraoui Seth Gilbert Professor: Rachid Guerraoui Assistants: M. Kapalka and A. Dragojevic Distributed Programming Laboratory](https://reader036.vdocuments.us/reader036/viewer/2022062804/56649dd05503460f94ac56ce/html5/thumbnails/15.jpg)
15
In short
This course shows how to wait-free implement high-
level atomic objects out of more primitive base objects.
![Page 16: 1 © R. Guerraoui Seth Gilbert Professor: Rachid Guerraoui Assistants: M. Kapalka and A. Dragojevic Distributed Programming Laboratory](https://reader036.vdocuments.us/reader036/viewer/2022062804/56649dd05503460f94ac56ce/html5/thumbnails/16.jpg)
16Shared object
Concurrent processes
![Page 17: 1 © R. Guerraoui Seth Gilbert Professor: Rachid Guerraoui Assistants: M. Kapalka and A. Dragojevic Distributed Programming Laboratory](https://reader036.vdocuments.us/reader036/viewer/2022062804/56649dd05503460f94ac56ce/html5/thumbnails/17.jpg)
17
Timing: • Class: Monday 9:15-11:00
• Exercise sessions: Monday 11:15-12:00– Room: BC03
– First session: Week 3
Text book:• None. Handouts on the webpage.
Final Exam:• Written, closed-book, date/time/room TBA.
Administrative Issues
![Page 18: 1 © R. Guerraoui Seth Gilbert Professor: Rachid Guerraoui Assistants: M. Kapalka and A. Dragojevic Distributed Programming Laboratory](https://reader036.vdocuments.us/reader036/viewer/2022062804/56649dd05503460f94ac56ce/html5/thumbnails/18.jpg)
18
What about the other class?
« Distributed Computing » Monday, 15:15-17:00, ELA01
• The courses are complementary.– This course: shared memory.– Other course: message passing.
Consider taking both! (Recommended…)
Administrative Issues
![Page 19: 1 © R. Guerraoui Seth Gilbert Professor: Rachid Guerraoui Assistants: M. Kapalka and A. Dragojevic Distributed Programming Laboratory](https://reader036.vdocuments.us/reader036/viewer/2022062804/56649dd05503460f94ac56ce/html5/thumbnails/19.jpg)
19
1. Introduction: • What is the goal of this course?
2. Model:• Processes and objects
• Atomicity
• Wait-freedom
3. Examples
Today’s Lecture:
![Page 20: 1 © R. Guerraoui Seth Gilbert Professor: Rachid Guerraoui Assistants: M. Kapalka and A. Dragojevic Distributed Programming Laboratory](https://reader036.vdocuments.us/reader036/viewer/2022062804/56649dd05503460f94ac56ce/html5/thumbnails/20.jpg)
20
Processes
We assume a finite set of processes:
–Processes have unique identifiers.
–Processes are denoted as « p1, …, pN » or « p, q, r »
–Processes know each other.
–Processes can coordinate via shared objects.
![Page 21: 1 © R. Guerraoui Seth Gilbert Professor: Rachid Guerraoui Assistants: M. Kapalka and A. Dragojevic Distributed Programming Laboratory](https://reader036.vdocuments.us/reader036/viewer/2022062804/56649dd05503460f94ac56ce/html5/thumbnails/21.jpg)
21
Processes
We assume a finite set of processes:
–Each process models a sequential program.
–Each clock tick each process takes a step.
– In each step, a process:
a) Performs some computation. (LOCAL)
b) Initiates an operation on a shared object. (GLOBAL)
c) Receives a response from an operation. (GLOBAL)
–We make no assumptions on process (relative) speeds. (Asynchronous)
![Page 22: 1 © R. Guerraoui Seth Gilbert Professor: Rachid Guerraoui Assistants: M. Kapalka and A. Dragojevic Distributed Programming Laboratory](https://reader036.vdocuments.us/reader036/viewer/2022062804/56649dd05503460f94ac56ce/html5/thumbnails/22.jpg)
22
Processes
p1
p2
p3
![Page 23: 1 © R. Guerraoui Seth Gilbert Professor: Rachid Guerraoui Assistants: M. Kapalka and A. Dragojevic Distributed Programming Laboratory](https://reader036.vdocuments.us/reader036/viewer/2022062804/56649dd05503460f94ac56ce/html5/thumbnails/23.jpg)
23
ProcessesCrash Failures:
A process either executes the algorithm assigned to it or crashes.
A process that crashes does not recover.
A process that does not crash in a given execution (computation or run) is called correct (in that execution).
![Page 24: 1 © R. Guerraoui Seth Gilbert Professor: Rachid Guerraoui Assistants: M. Kapalka and A. Dragojevic Distributed Programming Laboratory](https://reader036.vdocuments.us/reader036/viewer/2022062804/56649dd05503460f94ac56ce/html5/thumbnails/24.jpg)
24
Processes
p1
p2
p3
crash
![Page 25: 1 © R. Guerraoui Seth Gilbert Professor: Rachid Guerraoui Assistants: M. Kapalka and A. Dragojevic Distributed Programming Laboratory](https://reader036.vdocuments.us/reader036/viewer/2022062804/56649dd05503460f94ac56ce/html5/thumbnails/25.jpg)
25
On objects and processes
Processes interact via shared objects:
A process can initiate an operation on a particular object.
Every operation is expected to return a reply.
Each process can initiate only one operation at a time.
![Page 26: 1 © R. Guerraoui Seth Gilbert Professor: Rachid Guerraoui Assistants: M. Kapalka and A. Dragojevic Distributed Programming Laboratory](https://reader036.vdocuments.us/reader036/viewer/2022062804/56649dd05503460f94ac56ce/html5/thumbnails/26.jpg)
26
Processes
p1
p2
p3
operation
operation
operation
![Page 27: 1 © R. Guerraoui Seth Gilbert Professor: Rachid Guerraoui Assistants: M. Kapalka and A. Dragojevic Distributed Programming Laboratory](https://reader036.vdocuments.us/reader036/viewer/2022062804/56649dd05503460f94ac56ce/html5/thumbnails/27.jpg)
27
On objects and processes
Sequentiality:
– After invoking an operation op1 on some object O1…
– A process does not invoke a new operation on the same or on some other object…
– Until it receives the reply for op1.
Remark. Sometimes we talk about operations when we should be talking about operation invocations
![Page 28: 1 © R. Guerraoui Seth Gilbert Professor: Rachid Guerraoui Assistants: M. Kapalka and A. Dragojevic Distributed Programming Laboratory](https://reader036.vdocuments.us/reader036/viewer/2022062804/56649dd05503460f94ac56ce/html5/thumbnails/28.jpg)
28
Processes
p1
p2
p3
operation
operation
operation
![Page 29: 1 © R. Guerraoui Seth Gilbert Professor: Rachid Guerraoui Assistants: M. Kapalka and A. Dragojevic Distributed Programming Laboratory](https://reader036.vdocuments.us/reader036/viewer/2022062804/56649dd05503460f94ac56ce/html5/thumbnails/29.jpg)
29
Atomicity
We mainly focus in this course on how to implement atomic objects.
Atomicity (or linearizability):
Every operation appears to execute at some indivisible point in time.
This is called the linearization point.
This point is between the invocation and the reply.
![Page 30: 1 © R. Guerraoui Seth Gilbert Professor: Rachid Guerraoui Assistants: M. Kapalka and A. Dragojevic Distributed Programming Laboratory](https://reader036.vdocuments.us/reader036/viewer/2022062804/56649dd05503460f94ac56ce/html5/thumbnails/30.jpg)
30
Atomicity
p1
p2
p3
operation
operation
operation
![Page 31: 1 © R. Guerraoui Seth Gilbert Professor: Rachid Guerraoui Assistants: M. Kapalka and A. Dragojevic Distributed Programming Laboratory](https://reader036.vdocuments.us/reader036/viewer/2022062804/56649dd05503460f94ac56ce/html5/thumbnails/31.jpg)
31
Atomicity
p1
p2
p3
operation
operation
operation
![Page 32: 1 © R. Guerraoui Seth Gilbert Professor: Rachid Guerraoui Assistants: M. Kapalka and A. Dragojevic Distributed Programming Laboratory](https://reader036.vdocuments.us/reader036/viewer/2022062804/56649dd05503460f94ac56ce/html5/thumbnails/32.jpg)
32
Atomicity (the crash case)
p1
p2
p3
operation
operation
operation
p2
crash
![Page 33: 1 © R. Guerraoui Seth Gilbert Professor: Rachid Guerraoui Assistants: M. Kapalka and A. Dragojevic Distributed Programming Laboratory](https://reader036.vdocuments.us/reader036/viewer/2022062804/56649dd05503460f94ac56ce/html5/thumbnails/33.jpg)
33
Atomicity (the crash case)
p1
p2
p3
operation
operation
operation
p2
![Page 34: 1 © R. Guerraoui Seth Gilbert Professor: Rachid Guerraoui Assistants: M. Kapalka and A. Dragojevic Distributed Programming Laboratory](https://reader036.vdocuments.us/reader036/viewer/2022062804/56649dd05503460f94ac56ce/html5/thumbnails/34.jpg)
34
Atomicity (the crash case)
p1
p2
p3
operation
operation
p2
![Page 35: 1 © R. Guerraoui Seth Gilbert Professor: Rachid Guerraoui Assistants: M. Kapalka and A. Dragojevic Distributed Programming Laboratory](https://reader036.vdocuments.us/reader036/viewer/2022062804/56649dd05503460f94ac56ce/html5/thumbnails/35.jpg)
35
Atomicity
Theorem:Consider executions of algorithm A in which every operation completes.
If every such execution is atomic, then A guarantees atomicity in all executions (even those with operations that do not complete).
![Page 36: 1 © R. Guerraoui Seth Gilbert Professor: Rachid Guerraoui Assistants: M. Kapalka and A. Dragojevic Distributed Programming Laboratory](https://reader036.vdocuments.us/reader036/viewer/2022062804/56649dd05503460f94ac56ce/html5/thumbnails/36.jpg)
36
We mainly focus in this course on wait-free implementations
An implementation is wait-free if:
• Any correct process that invokes an operation eventually gets a reply.
• This does not depend on any other process.
• Other processes may crash or be very slow.
Wait-freedom
![Page 37: 1 © R. Guerraoui Seth Gilbert Professor: Rachid Guerraoui Assistants: M. Kapalka and A. Dragojevic Distributed Programming Laboratory](https://reader036.vdocuments.us/reader036/viewer/2022062804/56649dd05503460f94ac56ce/html5/thumbnails/37.jpg)
37
Wait-freedom
p1
p2
p3
operation
![Page 38: 1 © R. Guerraoui Seth Gilbert Professor: Rachid Guerraoui Assistants: M. Kapalka and A. Dragojevic Distributed Programming Laboratory](https://reader036.vdocuments.us/reader036/viewer/2022062804/56649dd05503460f94ac56ce/html5/thumbnails/38.jpg)
38
Wait-freedom
Wait-freedom conveys the robustness of the implementation
With a wait-free implementation, a process gets replies despite the crash of the n-1 other processes
Note that this precludes implementations based on locks (i.e., mutual exclusion).
![Page 39: 1 © R. Guerraoui Seth Gilbert Professor: Rachid Guerraoui Assistants: M. Kapalka and A. Dragojevic Distributed Programming Laboratory](https://reader036.vdocuments.us/reader036/viewer/2022062804/56649dd05503460f94ac56ce/html5/thumbnails/39.jpg)
39
Wait-freedom
p1
p2
p3
crash
operation
crash
![Page 40: 1 © R. Guerraoui Seth Gilbert Professor: Rachid Guerraoui Assistants: M. Kapalka and A. Dragojevic Distributed Programming Laboratory](https://reader036.vdocuments.us/reader036/viewer/2022062804/56649dd05503460f94ac56ce/html5/thumbnails/40.jpg)
40
1. Introduction: • What is the goal of this course?
2. Model:• Processes and objects
• Atomicity
• Wait-freedom
3. Examples
Today’s Lecture:
![Page 41: 1 © R. Guerraoui Seth Gilbert Professor: Rachid Guerraoui Assistants: M. Kapalka and A. Dragojevic Distributed Programming Laboratory](https://reader036.vdocuments.us/reader036/viewer/2022062804/56649dd05503460f94ac56ce/html5/thumbnails/41.jpg)
41
Most synchronization primitives (problems) can be precisely expressed as atomic objects (implementations)
Studying how to ensure robust synchronization boils down to studying wait-free atomic object implementations
Motivation
![Page 42: 1 © R. Guerraoui Seth Gilbert Professor: Rachid Guerraoui Assistants: M. Kapalka and A. Dragojevic Distributed Programming Laboratory](https://reader036.vdocuments.us/reader036/viewer/2022062804/56649dd05503460f94ac56ce/html5/thumbnails/42.jpg)
42
Example 1
The reader/writer synchronization problem corresponds to the register object
Basically, the processes need to read or write a shared data structure such that the value read by a process at a time t, is the last value written before t
![Page 43: 1 © R. Guerraoui Seth Gilbert Professor: Rachid Guerraoui Assistants: M. Kapalka and A. Dragojevic Distributed Programming Laboratory](https://reader036.vdocuments.us/reader036/viewer/2022062804/56649dd05503460f94ac56ce/html5/thumbnails/43.jpg)
43
Register
A register has two operations:
– read()
– write()
Assume (for simplicity) that: – a register contains an integer– the register is denoted by x – the register is initially 0
![Page 44: 1 © R. Guerraoui Seth Gilbert Professor: Rachid Guerraoui Assistants: M. Kapalka and A. Dragojevic Distributed Programming Laboratory](https://reader036.vdocuments.us/reader036/viewer/2022062804/56649dd05503460f94ac56ce/html5/thumbnails/44.jpg)
44
Read/Write Register
Sequential specification: read()
return(x)
write(v) x v; return(ok)
![Page 45: 1 © R. Guerraoui Seth Gilbert Professor: Rachid Guerraoui Assistants: M. Kapalka and A. Dragojevic Distributed Programming Laboratory](https://reader036.vdocuments.us/reader036/viewer/2022062804/56649dd05503460f94ac56ce/html5/thumbnails/45.jpg)
45
Atomicity?
p1
p2
p3
write(1) - ok
read() - 2
write(2) - ok
![Page 46: 1 © R. Guerraoui Seth Gilbert Professor: Rachid Guerraoui Assistants: M. Kapalka and A. Dragojevic Distributed Programming Laboratory](https://reader036.vdocuments.us/reader036/viewer/2022062804/56649dd05503460f94ac56ce/html5/thumbnails/46.jpg)
46
Atomicity?
p1
p2
p3
write(1) - ok
read() - 2
write(2) - ok
![Page 47: 1 © R. Guerraoui Seth Gilbert Professor: Rachid Guerraoui Assistants: M. Kapalka and A. Dragojevic Distributed Programming Laboratory](https://reader036.vdocuments.us/reader036/viewer/2022062804/56649dd05503460f94ac56ce/html5/thumbnails/47.jpg)
47
Atomicity?
p1
p2
p3
write(1) - ok
read() - 1
write(2) - ok
![Page 48: 1 © R. Guerraoui Seth Gilbert Professor: Rachid Guerraoui Assistants: M. Kapalka and A. Dragojevic Distributed Programming Laboratory](https://reader036.vdocuments.us/reader036/viewer/2022062804/56649dd05503460f94ac56ce/html5/thumbnails/48.jpg)
48
Atomicity?
p1
p2
p3
write(1) - ok
read() - 1
write(2) - ok
![Page 49: 1 © R. Guerraoui Seth Gilbert Professor: Rachid Guerraoui Assistants: M. Kapalka and A. Dragojevic Distributed Programming Laboratory](https://reader036.vdocuments.us/reader036/viewer/2022062804/56649dd05503460f94ac56ce/html5/thumbnails/49.jpg)
49
Atomicity?
p1
p2
p3
read() - 1
read() - 1
write(1) - ok
![Page 50: 1 © R. Guerraoui Seth Gilbert Professor: Rachid Guerraoui Assistants: M. Kapalka and A. Dragojevic Distributed Programming Laboratory](https://reader036.vdocuments.us/reader036/viewer/2022062804/56649dd05503460f94ac56ce/html5/thumbnails/50.jpg)
50
Atomicity?
p1
p2
p3
write(1) - ok
read() - 1
read() - 0
![Page 51: 1 © R. Guerraoui Seth Gilbert Professor: Rachid Guerraoui Assistants: M. Kapalka and A. Dragojevic Distributed Programming Laboratory](https://reader036.vdocuments.us/reader036/viewer/2022062804/56649dd05503460f94ac56ce/html5/thumbnails/51.jpg)
51
Atomicity?
p1
p2
p3
write(1) - ok
read() - 0
read() - 0
![Page 52: 1 © R. Guerraoui Seth Gilbert Professor: Rachid Guerraoui Assistants: M. Kapalka and A. Dragojevic Distributed Programming Laboratory](https://reader036.vdocuments.us/reader036/viewer/2022062804/56649dd05503460f94ac56ce/html5/thumbnails/52.jpg)
52
Atomicity?
p1
p2
p3
write(1) - ok
read() - 0
read() - 0
![Page 53: 1 © R. Guerraoui Seth Gilbert Professor: Rachid Guerraoui Assistants: M. Kapalka and A. Dragojevic Distributed Programming Laboratory](https://reader036.vdocuments.us/reader036/viewer/2022062804/56649dd05503460f94ac56ce/html5/thumbnails/53.jpg)
53
Atomicity?
p1
p2
p3
write(1) - ok
read() - 0
read() - 0
![Page 54: 1 © R. Guerraoui Seth Gilbert Professor: Rachid Guerraoui Assistants: M. Kapalka and A. Dragojevic Distributed Programming Laboratory](https://reader036.vdocuments.us/reader036/viewer/2022062804/56649dd05503460f94ac56ce/html5/thumbnails/54.jpg)
54
Atomicity?
p1
p2
p3
write(1) - ok
read() - 1
read() - 0
![Page 55: 1 © R. Guerraoui Seth Gilbert Professor: Rachid Guerraoui Assistants: M. Kapalka and A. Dragojevic Distributed Programming Laboratory](https://reader036.vdocuments.us/reader036/viewer/2022062804/56649dd05503460f94ac56ce/html5/thumbnails/55.jpg)
55
Atomicity?
p1
p2
p3
write(1) - ok
read() - 1
read() - 1
![Page 56: 1 © R. Guerraoui Seth Gilbert Professor: Rachid Guerraoui Assistants: M. Kapalka and A. Dragojevic Distributed Programming Laboratory](https://reader036.vdocuments.us/reader036/viewer/2022062804/56649dd05503460f94ac56ce/html5/thumbnails/56.jpg)
56
Example 2
Producer/consumer synchronization: corresponds to the queue object.
Producer processes create items; consumer processes use items.
Requirements:
– An item cannot be consumed by 2 processes.
– The first item produced is the first consumed (FIFO).
![Page 57: 1 © R. Guerraoui Seth Gilbert Professor: Rachid Guerraoui Assistants: M. Kapalka and A. Dragojevic Distributed Programming Laboratory](https://reader036.vdocuments.us/reader036/viewer/2022062804/56649dd05503460f94ac56ce/html5/thumbnails/57.jpg)
57
Queue
A queue has two operations: enqueue() and dequeue()
We assume that a queue internally maintains a list x which supports:
– append(): put an item at the end of the list;
– remove(): remove an element from the head of the list.
![Page 58: 1 © R. Guerraoui Seth Gilbert Professor: Rachid Guerraoui Assistants: M. Kapalka and A. Dragojevic Distributed Programming Laboratory](https://reader036.vdocuments.us/reader036/viewer/2022062804/56649dd05503460f94ac56ce/html5/thumbnails/58.jpg)
58
Sequential specification
dequeue() if (x = 0) then return(nil); else return(x.remove())
enqueue(v) x.append(v); return(ok)
![Page 59: 1 © R. Guerraoui Seth Gilbert Professor: Rachid Guerraoui Assistants: M. Kapalka and A. Dragojevic Distributed Programming Laboratory](https://reader036.vdocuments.us/reader036/viewer/2022062804/56649dd05503460f94ac56ce/html5/thumbnails/59.jpg)
59
Atomicity?
p1
p2
p3
enq(x) - ok
deq() - y
deq() - x
enq(y) - ok
![Page 60: 1 © R. Guerraoui Seth Gilbert Professor: Rachid Guerraoui Assistants: M. Kapalka and A. Dragojevic Distributed Programming Laboratory](https://reader036.vdocuments.us/reader036/viewer/2022062804/56649dd05503460f94ac56ce/html5/thumbnails/60.jpg)
60
Atomicity?
p1
p2
p3
enq(x) - ok
deq() - y
deq() - x
enq(y) - ok
![Page 61: 1 © R. Guerraoui Seth Gilbert Professor: Rachid Guerraoui Assistants: M. Kapalka and A. Dragojevic Distributed Programming Laboratory](https://reader036.vdocuments.us/reader036/viewer/2022062804/56649dd05503460f94ac56ce/html5/thumbnails/61.jpg)
61
Atomicity?
p1
p2
p3
enq(x) - ok
deq() - y
enq(y) - ok
![Page 62: 1 © R. Guerraoui Seth Gilbert Professor: Rachid Guerraoui Assistants: M. Kapalka and A. Dragojevic Distributed Programming Laboratory](https://reader036.vdocuments.us/reader036/viewer/2022062804/56649dd05503460f94ac56ce/html5/thumbnails/62.jpg)
62
Atomicity?
p1
p2
p3
enq(x) - ok
deq() - x
enq(y) - ok
![Page 63: 1 © R. Guerraoui Seth Gilbert Professor: Rachid Guerraoui Assistants: M. Kapalka and A. Dragojevic Distributed Programming Laboratory](https://reader036.vdocuments.us/reader036/viewer/2022062804/56649dd05503460f94ac56ce/html5/thumbnails/63.jpg)
63
Content
(1) Implementing registers
(2) The power & limitation of registers
(3) Universal objects & synchronization number
(4) The power of time & failure detection
(5) Tolerating failure prone objects
(6) Anonymous implementations
(7) Transaction memory
![Page 64: 1 © R. Guerraoui Seth Gilbert Professor: Rachid Guerraoui Assistants: M. Kapalka and A. Dragojevic Distributed Programming Laboratory](https://reader036.vdocuments.us/reader036/viewer/2022062804/56649dd05503460f94ac56ce/html5/thumbnails/64.jpg)
64
In shortThis course shows how to wait-free implement high-level atomic objects out of basic objects
Remark: unless explicitely stated otherwise: objects mean atomic objects and implementations are wait-free.