Linked Lists: Locking, Lock-Free, and Beyond …
Last Lecture: Spin-Locks
Today: Concurrent Objects
Today: Concurrent Objects
Coarse-Grained Synchronization
Coarse-Grained Synchronization
Coarse-Grained Synchronization
Coarse-Grained Synchronization
Coarse-Grained Synchronization
Coarse-Grained Synchronization
This Lecture
This Lecture
First:Fine-Grained Synchronization
Second:Optimistic Synchronization
Second:Optimistic Synchronization
Second:Optimistic Synchronization
Third:Lazy Synchronization
Fourth:Lock-Free Synchronization
Fourth:Lock-Free Synchronization
Fourth:Lock-Free Synchronization
Linked List
Set Interface
Set Interface
Set Interface
List-Based Sets
List-Based Sets
List-Based Sets
List-Based Sets
List Node
List Node
List Node
List Node
The List-Based Set
Reasoning about Concurrent Objects
Reasoning about Concurrent Objects
Specifically …
Specifically …
Interference
Interference
Interference
Interference
Abstract Data Types
Abstract Data Types
Rep Invariant
Blame Game
Blame Game
Blame Game
Rep Invariant (partly)
Abstraction Map
Sequential List Based Set
Sequential List Based Set
Coarse-Grained Locking
Coarse-Grained Locking
Coarse-Grained Locking
Coarse-Grained Locking
Coarse-Grained Locking
Fine-grained Locking
Fine-grained Locking
Hand-over-Hand locking
Hand-over-Hand locking
Hand-over-Hand locking
Hand-over-Hand locking
Hand-over-Hand locking
Removing a Node
Removing a Node
Removing a Node
Removing a Node
Removing a Node
Removing a Node
Concurrent Removes
Concurrent Removes
Concurrent Removes
Concurrent Removes
Concurrent Removes
Concurrent Removes
Concurrent Removes
Concurrent Removes
Concurrent Removes
Concurrent Removes
Uh, Oh
Uh, Oh
Problem
Insight
Hand-Over-Hand Again
Hand-Over-Hand Again
Hand-Over-Hand Again
Hand-Over-Hand Again
Hand-Over-Hand Again
Hand-Over-Hand Again
Removing a Node
Removing a Node
Removing a Node
Removing a Node
Removing a Node
Removing a Node
Removing a Node
Removing a Node
Removing a Node
Removing a Node
Removing a Node
Removing a Node
Removing a Node
Removing a Node
Removing a Node
Removing a Node
Remove method
Remove method
Remove method
Remove method
Remove method
Remove method
Remove method
Remove method
Remove method
Remove: searching
Remove: searching
Remove: searching
Remove: searching
Remove: searching
Remove: searching
Remove: searching
Remove: searching
Remove: searching
Remove: searching
Remove: searching
Why remove() is linearizable
Why remove() is linearizable
Why remove() is linearizable
Why remove() is linearizable
Why remove() is linearizable
Why remove() is linearizable
Adding Nodes
Same Abstraction Map
Rep Invariant
Drawbacks
Optimistic Synchronization
Optimistic: Traverse without Locking
Optimistic: Lock and Load
Optimistic: Lock and Load
What could go wrong?
What could go wrong?
What could go wrong?
What could go wrong?
What could go wrong?
What could go wrong?
What could go wrong?
Validate – Part 1
What Else Could Go Wrong?
What Else Coould Go Wrong?
What Else Coould Go Wrong?
What Else Could Go Wrong?
What Else Could Go Wrong?
Validate Part 2(while holding locks)
Optimistic: Linearization Point
Same Abstraction Map
Invariants
Correctness
Unsuccessful Remove
Validate (1)
Validate (2)
OK Computer
Correctness
Validation
Validation
Validation
Validation
Validation
Validation
Validation
Validation
Remove: searching
Remove: searching
Remove: searching
Remove: searching
Remove: searching
Remove: searching
Remove: searching
On Exit from Loop
Remove Method
Remove Method
Remove Method
Remove Method
Remove Method
Remove Method
Optimistic List
So Far, So Good
Evaluation
Lazy List
Lazy List
Lazy Removal
Lazy Removal
Lazy Removal
Lazy Removal
Lazy Removal
Lazy List
Validation
Business as Usual
Business as Usual
Business as Usual
Business as Usual
Business as Usual
Business as Usual
Business as Usual
Business as Usual
Business as Usual
New Abstraction Map
Invariant
Validation
List Validate Method
List Validate Method
List Validate Method
Remove
Remove
Remove
Remove
Remove
Contains
Contains
Contains
Contains
Contains
Summary: Wait-free Contains
Lazy List
Evaluation
Traffic Jam
Reminder: Lock-Free Data Structures
Lock-free Lists
Lock-free Lists
Problem…
The Solution: Combine Bit and Pointer
Solution
Marking a Node
Extracting Reference & Mark
Extracting Reference & Mark
Extracting Mark Only
Changing State
Changing State
Changing State
Changing State
Changing State
Changing State
Removing a Node
Removing a Node
Removing a Node
Removing a Node
Traversing the List
Lock-Free Traversal(only Add and Remove)
The Window Class
The Window Class
Using the Find Method
Using the Find Method
Using the Find Method
The Find Method
The Find Method
Remove
Remove
Remove
Remove
Remove
Remove
Remove
Add
Add
Add
Add
Wait-free Contains
Wait-free Contains
Lock-free Find
Lock-free Find
Lock-free Find
Lock-free Find
Lock-free Find
Lock-free Find
Lock-free Find
Lock-free Find
Lock-free Find
Lock-free Find
Lock-free Find
Lock-free Find
Performance
High Contains Ratio
Low Contains Ratio
As Contains Ratio Increases
Summary
“To Lock or Not to Lock”