Lecture-8 - Principles of Concurrency and Parallelism...

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

View Full Document Right Arrow Icon
CS390C: Principles of Concurrency and Parallelism Principles of Concurrency and Parallelism Lecture 8: Locks 2/28/12 slides adapted from The Art of Multiprocessor Programming, Herlihy and Shavit Tuesday, February 28, 12
Background image of page 1

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

View Full DocumentRight Arrow Icon
CS390C: Principles of Concurrency and Parallelism 2 New Focus: Performance Models More complicated (not the same as complex!) Still focus on principles (not soon obsolete) Protocols Elegant (in their fashion) Important (why else would we pay attention) And realistic (your mileage may vary) Tuesday, February 28, 12
Background image of page 2
CS390C: Principles of Concurrency and Parallelism 3 Kinds of Architectures SISD (Uniprocessor) Single instruction stream Single data stream SIMD (Vector) Single instruction Multiple data MIMD (Multiprocessors) Multiple instruction Multiple data. Tuesday, February 28, 12
Background image of page 3

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

View Full DocumentRight Arrow Icon
CS390C: Principles of Concurrency and Parallelism 4 MIMD Architectures • Memory Contention • Communication Contention • Communication Latency Shared Bus memory Distributed Tuesday, February 28, 12
Background image of page 4
CS390C: Principles of Concurrency and Parallelism 5 Revisit Mutual Exclusion Think of performance, not just correctness and progress Begin to understand how performance depends on our software properly utilizing the multiprocessor machine’s hardware And get to know a collection of locking algorithms… (1) Tuesday, February 28, 12
Background image of page 5

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

View Full DocumentRight Arrow Icon
CS390C: Principles of Concurrency and Parallelism 6 Lock Contention Keep trying “spin” or “busy-wait” Good if delays are short Give up the processor Good if delays are long Always good on uniprocessor (1) Tuesday, February 28, 12
Background image of page 6
CS390C: Principles of Concurrency and Parallelism 7 Basic Spin-Lock CS Resets lock upon exit spin lock critical section . . . Tuesday, February 28, 12
Background image of page 7

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

View Full DocumentRight Arrow Icon
CS390C: Principles of Concurrency and Parallelism 8 Basic Spin-Lock CS Resets lock upon exit spin lock critical section . . . …lock introduces sequential bottleneck …and introduces contention no parallelism Tuesday, February 28, 12
Background image of page 8
CS390C: Principles of Concurrency and Parallelism 8 Basic Spin-Lock CS Resets lock upon exit spin lock critical section . . . …lock introduces sequential bottleneck …and introduces contention no parallelism Tuesday, February 28, 12
Background image of page 9

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

View Full DocumentRight Arrow Icon
CS390C: Principles of Concurrency and Parallelism 9 Test-and-Set Boolean value Test-and-set (TAS) Swap true with current value Return value tells if prior value was true or false Can reset just by writing false TAS aka “getAndSet” Tuesday, February 28, 12
Background image of page 10
CS390C: Principles of Concurrency and Parallelism 10 Test-and-Set public class AtomicBoolean { boolean value; public synchronized boolean getAndSet(boolean newValue) { boolean prior = value; value = newValue; return prior; } } (5) Tuesday, February 28, 12
Background image of page 11

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

View Full DocumentRight Arrow Icon
CS390C: Principles of Concurrency and Parallelism 11 Test-and-Set AtomicBoolean lock = new AtomicBoolean(false) boolean prior = lock.getAndSet(true) (5) Swapping in true is called “test-and-set” or TAS Tuesday, February 28, 12
Background image of page 12
CS390C: Principles of Concurrency and Parallelism 12 Test-and-Set Locks Locking
Background image of page 13

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

View Full DocumentRight Arrow Icon
Image of page 14
This is the end of the preview. Sign up to access the rest of the 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 / 100

Lecture-8 - Principles of Concurrency and Parallelism...

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

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