08~Chapter_09 - Linked Lists: Locking, Lock-Free, and...

Info iconThis preview shows pages 1–15. Sign up to view the full content.

View Full Document Right Arrow Icon

Info iconThis preview has intentionally blurred sections. Sign up to view the full version.

View Full DocumentRight Arrow Icon

Info iconThis preview has intentionally blurred sections. Sign up to view the full version.

View Full DocumentRight Arrow Icon

Info iconThis preview has intentionally blurred sections. Sign up to view the full version.

View Full DocumentRight Arrow Icon

Info iconThis preview has intentionally blurred sections. Sign up to view the full version.

View Full DocumentRight Arrow Icon

Info iconThis preview has intentionally blurred sections. Sign up to view the full version.

View Full DocumentRight Arrow Icon

Info iconThis preview has intentionally blurred sections. Sign up to view the full version.

View Full DocumentRight Arrow Icon

Info iconThis preview has intentionally blurred sections. Sign up to view the full version.

View Full DocumentRight Arrow Icon
This is the end of the preview. Sign up to access the rest of the document.

Unformatted text preview: Linked Lists: Locking, Lock-Free, and Beyond Companion slides for The Art of Multiprocessor Programming by Maurice Herlihy & Nir Shavit Art of Multiprocessor Programming 2 Last Lecture: Spin-Locks CS Resets lock upon exit spin lock critical section . . . Art of Multiprocessor Programming 3 Today: Concurrent Objects Adding threads should not lower throughput Contention effects Mostly fixed by Queue locks Should increase throughput Not possible if inherently sequential Surprising things are parallelizable Art of Multiprocessor Programming 4 Coarse-Grained Synchronization Each method locks the object Avoid contention using queue locks Easy to reason about In simple cases Standard Java model Synchronized blocks and methods So, are we done? Art of Multiprocessor Programming 5 Coarse-Grained Synchronization Sequential bottleneck Threads stand in line Adding more threads Does not improve throughput Struggle to keep it from getting worse So why even use a multiprocessor? Well, some apps inherently parallel Art of Multiprocessor Programming 6 This Lecture Introduce four patterns Bag of tricks Methods that work more than once For highly-concurrent objects Goal: Concurrent access More threads, more throughput Art of Multiprocessor Programming 7 First: Fine-Grained Synchronization Instead of using a single lock .. Split object into Independently-synchronized components Methods conflict when they access The same component At the same time Art of Multiprocessor Programming 8 Second: Optimistic Synchronization Search without locking If you find it, lock and check OK: we are done Oops: start over Evaluation Usually cheaper than locking Mistakes are expensive Art of Multiprocessor Programming 9 Third: Lazy Synchronization Postpone hard work Removing components is tricky Logical removal Mark component to be deleted Physical removal Do what needs to be done Art of Multiprocessor Programming 10 Fourth: Lock-Free Synchronization Dont use locks at all Use compareAndSet() & relatives Advantages No Scheduler Assumptions/Support Disadvantages Complex Sometimes high overhead Art of Multiprocessor Programming 11 Linked List Illustrate these patterns Using a list-based Set Common application Building block for other apps Art of Multiprocessor Programming 12 Set Interface Unordered collection of items No duplicates Methods add(x) put x in set remove(x) take x out of set contains(x) tests if x in set Art of Multiprocessor Programming 13 List-Based Sets public interface Set<T> { public boolean add(T x); public boolean remove(T x); public boolean contains(T x); } Art of Multiprocessor Programming 14 List-Based Sets public interface Set<T> { public boolean add(T x); public boolean remove(T x); public boolean contains(T x); } Add item to set Art of Multiprocessor Programming...
View Full Document

Page1 / 257

08~Chapter_09 - Linked Lists: Locking, Lock-Free, and...

This preview shows document pages 1 - 15. Sign up to view the full document.

View Full Document Right Arrow Icon
Ask a homework question - tutors are online