Lecture-9 - CS390C: Principles of Concurrency and...

Info iconThis preview shows pages 1–13. 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
This is the end of the preview. Sign up to access the rest of the document.

Unformatted text preview: CS390C: Principles of Concurrency and Parallelism Principles of Concurrency and Parallelism Lecture 8: Lock-free Data Structures 3/19/12 slides adapted from The Art of Multiprocessor Programming, Herlihy and Shavit Thursday, March 22, 12 CS390C: Principles of Concurrency and Parallelism 2 Last Lecture: Spin-Locks CS Resets lock upon exit spin lock critical section . . . Thursday, March 22, 12 CS390C: Principles of Concurrency and Parallelism 3 Today: Concurrent Objects Adding threads should not lower throughput Contention effects Mostly Fxed by Queue locks Thursday, March 22, 12 CS390C: Principles of Concurrency and Parallelism 4 Today: Concurrent Objects Adding threads should not lower throughput Contention effects Mostly Fxed by Queue locks Should increase throughput Not possible if inherently sequential Surprising things are parallelizable Thursday, March 22, 12 CS390C: Principles of Concurrency and Parallelism 5 Coarse-Grained Synchronization Each method locks the object Avoid contention using queue locks Easy to reason about In simple cases So, are we done? Thursday, March 22, 12 CS390C: Principles of Concurrency and Parallelism 6 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 Thursday, March 22, 12 CS390C: Principles of Concurrency and Parallelism 7 Fine-Grained Synchronization Instead of using a single lock Split object into Independently-synchronized components Methods conFict when they access The same component At the same time Thursday, March 22, 12 CS390C: Principles of Concurrency and Parallelism 8 Second: Optimistic Synchronization Search without locking If you Fnd it, lock and check OK: we are done Oops: start over Evaluation Usually cheaper than locking, but Mistakes are expensive Thursday, March 22, 12 CS390C: Principles of Concurrency and Parallelism 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 Thursday, March 22, 12 CS390C: Principles of Concurrency and Parallelism 10 Fourth: Lock-Free Synchronization Dont use locks at all Use compareAndSet() & relatives Advantages No Scheduler Assumptions/Support Disadvantages Complex Sometimes high overhead Thursday, March 22, 12 CS390C: Principles of Concurrency and Parallelism 11 Linked List Illustrate these patterns Using a list-based Set Common application Building block for other apps Thursday, March 22, 12 CS390C: Principles of Concurrency and Parallelism 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 Thursday, March 22, 12 CS390C: Principles of Concurrency and Parallelism...
View Full Document

This note was uploaded on 03/26/2012 for the course CS 390 taught by Professor Staff during the Spring '08 term at Purdue University-West Lafayette.

Page1 / 217

Lecture-9 - CS390C: Principles of Concurrency and...

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

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