contention management and obstruction-free algorithms
DESCRIPTION
Contention Management and Obstruction-free Algorithms. Niloufar Shafiei. Agenda. Introduction Non-blocking approaches Contention management Two obstruction-free shared deque algorithms. Distributed shared memory systems. Mutual exclusion (using locks) Delay of processes - PowerPoint PPT PresentationTRANSCRIPT
![Page 1: Contention Management and Obstruction-free Algorithms](https://reader035.vdocument.in/reader035/viewer/2022062801/56814388550346895db005a3/html5/thumbnails/1.jpg)
1
Contention Management and Obstruction-free Algorithms
Niloufar Shafiei
![Page 2: Contention Management and Obstruction-free Algorithms](https://reader035.vdocument.in/reader035/viewer/2022062801/56814388550346895db005a3/html5/thumbnails/2.jpg)
2
Agenda
Introduction Non-blocking approaches Contention management Two obstruction-free shared deque
algorithms
![Page 3: Contention Management and Obstruction-free Algorithms](https://reader035.vdocument.in/reader035/viewer/2022062801/56814388550346895db005a3/html5/thumbnails/3.jpg)
3
Distributed shared memory systems
Mutual exclusion (using locks) Delay of processes Not fault-tolerant (failure of processes) Deadlock Priority inversion
Non-blocking Delay and failure of processes do not cause
performance problems
![Page 4: Contention Management and Obstruction-free Algorithms](https://reader035.vdocument.in/reader035/viewer/2022062801/56814388550346895db005a3/html5/thumbnails/4.jpg)
4
Non-blocking
Wait-free All processes complete in a finite number of steps.
Lock-free Some processes complete in a finite number of
steps.
Significant overhead Complex and subtle
![Page 5: Contention Management and Obstruction-free Algorithms](https://reader035.vdocument.in/reader035/viewer/2022062801/56814388550346895db005a3/html5/thumbnails/5.jpg)
5
Non-blocking
Obstruction-free Each process completes if it runs without
interference for sufficiently long.
Not guarantee the progress Simpler Easier to design
![Page 6: Contention Management and Obstruction-free Algorithms](https://reader035.vdocument.in/reader035/viewer/2022062801/56814388550346895db005a3/html5/thumbnails/6.jpg)
6
Contention management
Decide which process can take steps at a time
A simple method is back-off when they encounter interference.
Contention management policy: Guarantee the progress of all process
![Page 7: Contention Management and Obstruction-free Algorithms](https://reader035.vdocument.in/reader035/viewer/2022062801/56814388550346895db005a3/html5/thumbnails/7.jpg)
7
+
=Contention
ManagementObstruction-free
Algorithms
Wait-freeAlgorithms
![Page 8: Contention Management and Obstruction-free Algorithms](https://reader035.vdocument.in/reader035/viewer/2022062801/56814388550346895db005a3/html5/thumbnails/8.jpg)
8
Contention Management Policies Aggressive
Always abort
Polite Exponential back-off
KillBlocked Abort if an operation is blocked or waits for maximum waiting
time
Karma Set a priority (priority = amount of work + number of retries)
![Page 9: Contention Management and Obstruction-free Algorithms](https://reader035.vdocument.in/reader035/viewer/2022062801/56814388550346895db005a3/html5/thumbnails/9.jpg)
9
Contention Management Policies Eruption
Set a priority and increase priority of running operation
Randomized Flip a coin
Kindergarten Keep a list
Timestamp Abort earlier timestamp
QueueONBlock Set a flag of waiting operation
![Page 10: Contention Management and Obstruction-free Algorithms](https://reader035.vdocument.in/reader035/viewer/2022062801/56814388550346895db005a3/html5/thumbnails/10.jpg)
10
Obstruction-free Deque on Linear Array
0 1 … MAX+1
LN … LN RN … RN
value
counter
Invariant: array always consists of at least one LN, followed by zero or more data values, followed by at least one RN.
![Page 11: Contention Management and Obstruction-free Algorithms](https://reader035.vdocument.in/reader035/viewer/2022062801/56814388550346895db005a3/html5/thumbnails/11.jpg)
11
Rightpush(v) Change the leftmost RN to v
1. Find index of leftmost RN
LN … LN RN … RN
k
![Page 12: Contention Management and Obstruction-free Algorithms](https://reader035.vdocument.in/reader035/viewer/2022062801/56814388550346895db005a3/html5/thumbnails/12.jpg)
12
2. Check if k=MAX+1 then deque is full
3. Increase the counter of A[k-1]
LN … … … … RN
K=MAX+1
LN … … RN … RN
k
A[k-1]
![Page 13: Contention Management and Obstruction-free Algorithms](https://reader035.vdocument.in/reader035/viewer/2022062801/56814388550346895db005a3/html5/thumbnails/13.jpg)
13
4. Change A[k] to v and increase its counter value
LN … … v … RN
k
![Page 14: Contention Management and Obstruction-free Algorithms](https://reader035.vdocument.in/reader035/viewer/2022062801/56814388550346895db005a3/html5/thumbnails/14.jpg)
14
Rightpop Change the rightmost data value to RN.
1. Find index of leftmost RN
LN LN RN RN
k
![Page 15: Contention Management and Obstruction-free Algorithms](https://reader035.vdocument.in/reader035/viewer/2022062801/56814388550346895db005a3/html5/thumbnails/15.jpg)
15
2. Check if deque is empty
3. Increase the counter of A[k]
LN LN LN LN RN RN
k-1 k
LN LN RN RN
k
A[k]
![Page 16: Contention Management and Obstruction-free Algorithms](https://reader035.vdocument.in/reader035/viewer/2022062801/56814388550346895db005a3/html5/thumbnails/16.jpg)
16
4. Change A[k-1] to RN and increase its
counter value and return the popped value
LN LN RN RN RN
k
![Page 17: Contention Management and Obstruction-free Algorithms](https://reader035.vdocument.in/reader035/viewer/2022062801/56814388550346895db005a3/html5/thumbnails/17.jpg)
17
Problem: push on one end and pop from the other end
LN LN LN LN LN RN
![Page 18: Contention Management and Obstruction-free Algorithms](https://reader035.vdocument.in/reader035/viewer/2022062801/56814388550346895db005a3/html5/thumbnails/18.jpg)
18
Obstruction-free Deque on Circular Array
LN
RN
DN
RN
RN
LN
LN
LN
Invariants:1. All null values are in a contiguous sequence of locations.2. The sequence consists of zero or more RN, followed by zero
or one DN, followed by zero or more LN.3. At least two different null values are in the sequence.
![Page 19: Contention Management and Obstruction-free Algorithms](https://reader035.vdocument.in/reader035/viewer/2022062801/56814388550346895db005a3/html5/thumbnails/19.jpg)
19
Rightpush(v) Change the leftmost RN to v
1. Find index of leftmost RN
v1
RN
DN
RN
v2
LN
LN
LN
k
![Page 20: Contention Management and Obstruction-free Algorithms](https://reader035.vdocument.in/reader035/viewer/2022062801/56814388550346895db005a3/html5/thumbnails/20.jpg)
20
2. Read A[k+1] If A[k+1] = RN
v1
RN
DN
RN
v2
LN
LN
LN
k
k+1
1. Increase the counter value of A[k-1]2. Change A[k] to v
k-1
![Page 21: Contention Management and Obstruction-free Algorithms](https://reader035.vdocument.in/reader035/viewer/2022062801/56814388550346895db005a3/html5/thumbnails/21.jpg)
21
If A[k+1] = LN
v1
LN
LN
RN
v2
LN
LN
LN
k
k+1
1. Increase the counter value of A[k]2. Change A[k+1] to DN
k-1
![Page 22: Contention Management and Obstruction-free Algorithms](https://reader035.vdocument.in/reader035/viewer/2022062801/56814388550346895db005a3/html5/thumbnails/22.jpg)
22
If A[k+1] = DN and A[k+2] Null
v1
DN
v6
RN
v2
v3
v4
v5
k
k+1
Return FULL
k-1
k+2
![Page 23: Contention Management and Obstruction-free Algorithms](https://reader035.vdocument.in/reader035/viewer/2022062801/56814388550346895db005a3/html5/thumbnails/23.jpg)
23
If A[k+1] = DN and A[k+2] = LN
v1
DN
LN
RN
v2
v3
v4
v5
k
k+1
k-1
k+2
1. Increase the counter value of A[k+2]2. Change A[k+1] to RN
![Page 24: Contention Management and Obstruction-free Algorithms](https://reader035.vdocument.in/reader035/viewer/2022062801/56814388550346895db005a3/html5/thumbnails/24.jpg)
24
Conclusion Obstruction-free weakens the progress property
but it is simpler.
Contention management policies improve the progress of obstruction-free algorithms.
Obstruction-free algorithms with appropriate contention management policy can perform like wait-free algorithms in practice.