10/28/11. DD2451 Overview. DD2451 Overview. FDD 3008 Overview. Course Material

Size: px
Start display at page:

Download "10/28/11. DD2451 Overview. DD2451 Overview. FDD 3008 Overview. Course Material"

Transcription

1 /8/ DD45 Parallel and Distributed omputing --- FDD38 Distributed lgorithms Lecture Mads Dam utumn/winter Lectures double lectures Twice a week until beg. December Focus on theory and principles ut look at some systems too lso some programming issues DD45 Overview Exercises Exercises given for each lecture Discussion at end of each lecture 3 homework sets to be handed in individually Homework rules and grading see the course page We may use peer review Deadlines apply DD45 Overview FDD 38 Overview Paper presentations hance to present research papers See presentation sessions in schedule on course web Optional, but counts towards final grade Select paper you want to present Some advice on course web Let Mads know by mail at the latest Nov! Other matters: ourse committee/kursnämnd ny volunteers? KTH social any interest? nything else? Introductory postgraduate level Some additional requirements Paper presentation obligatory Final report 8- pages Preferably: pplication to PhD project Topic selection quite free Generally: Herlihy s book at bit too informal for pg level More precision and formality expected in handins, reports, presentations nyway the material gets more advanced as we move along ourse Material Main textbook: Herlihy and Shavit Focus on shared memory model Used a lot in first lectures Later more attention to message-passing and distribution Other textbooks used later on Other material (papers, course notes) to be announced on course page Slides: Much material due to Maurice Herlihy, rown, and Roger Wattenhofer, ETH, Zurich, thanks! What Is Parallel and Distributed omputing bout? How to distribute a computing task between several processors/ threads/nodes/cores? f (x, y)? 5! When? How? Performance? Models? Failures? Security? Scale? What is possible? What is not possible? orrectness? Fault tolerance?

2 /8/ What Is Parallel and Distributed omputing bout? What Is Parallel and Distributed omputing bout? How to distribute a computing task between several processors/ threads/nodes/cores? How to distribute a computing task between several processors/ threads/nodes/cores? When? How? Performance? Models? Security? Scale? What is possible? What is not possible? orrectness? Fault tolerance? When? How? Performance? Models? Security? Scale? What is possible? What is not possible? orrectness? Fault tolerance? What Is Parallel and Distributed omputing bout? What Is Parallel and Distributed omputing bout? How to distribute a computing task between several processors/ threads/nodes/cores? How to distribute a computing task between several processors/ threads/nodes/cores? When? How? Performance? Models? Security? Scale? What is possible? What is not possible? orrectness? Fault tolerance? When? How? Performance? Models? Security? Scale? What is possible? What is not possible? orrectness? Fault tolerance? Does Scale Matter? Why Is It Important? It s all about scale! Small scale: Small numbers of nodes, fixed interconnects, shared memory, little latency, fixed architectures, rare failures, mostly static Large scale: ig numbers, system organization important, heterogenous architectures, message passing, big latency, frequent failures, more dynamic Ultimately: Read: The Free Lunch Is Over, Herb Suer

3 /8/ High performance High reliability High availability Why Is It Important? oncurrency is indispensable ut parallelizalon and distribulon is tricky! ourse Overview First small scale Mutual exclusion Linearizability, sequenlal consistency, the Java memory model onsensus, impossibility results, consensus numbers, registers This part mainly uses Herlihy s book So let s get started ourse Overview, II Then large scale Fault tolerance yzanlne fault tolerance onsistency models, weak consistency PP systems, DHT s Mostly slides and handouts Then some addilonal topics among: Leader eleclon, spanning trees, vertex colouring, and/or Spin locks, concurrent data structures Events Events a,b: : read(x = true) the event of thread reading variable x and ge\ng the result true : write(y = ) do. of wrilng to y Note: y might have been already doesn t maer Events: re instantaneous, -me(a) = Lme at which event a occurs (Not the same as atomic, not the same as a program statement) synchrony: No two events occur at the same Lme a b a -me Events, II Thread, Process Examples: Reading a variable WriLng a variable Outpu\ng a value Inpu\ng a value Receiving a signal alling a method Returning from a method Returning normally from a method Returning exceplonally from a method (etc) depending on which abstraclons we assume thread / process is a state machine aka transilon system aka transilon graph aka (lots of other things) a a c Need to dislnguish between events and event occurrences Events are not necessarily observable c b b d 3

4 /8/ States Traces Model dependent Threads: Object states assignments of values to fields Thread states do. to local variables Program counters (Maybe more, caches, load state, network state, etc) Network state Wire state uffer states onfiguralon state IP numbers Lots and lots and lots thread produces a trace = sequence of events tr = a a a n a a a n Precedence, happens- before (Lamport): a - > b : Same as -me(a) < -me(b) Processor state: Registers Memory aches, pipelines onfiguralon The precedence relalon is a total order Irreflexive: not(a - > a) nlsymmetric: If a - > b then not(b - > a) TransiLve: If a - > b and b - > c then a - > c Total: For all a b, either a - > b or b - > a (a,b) Intervals = the interval between a and b = the set of Lme point from -me(a) to -me(b) (endpoints included) (a,b) - > (c,d) = (a,b) precedes (c,d) = b - > c = (a,b) ends before (c,d) starts (a,b), (c,d) concurrent, if not (a,b) - > (c,d) a b c d a c b d rilcal SecLons public class ounter { private long value; public long getndincrement() { temp = value; value = temp + ; return temp; Say: ssign globally unique sequence numbers What if two threads call getndincrement in parallel? rilcal SecLons, II Locks public interface Lock { Tread : read(value=) write(temp=) read(temp=) write(value=) public void lock(); public void unlock(); Tread : read(value=) public class ounter { private long value; write(value=) Lock.lock(): Entering crilcal seclon Lock.unlock(): ExiLng public long getndincrement() { temp = value; value = temp + ; return temp; 4

5 /8/ Using Locks public class ounter { private long value; private Lock lock; public long getndincrement() { lock.lock(); try { int temp = value; value = value + ; finally { lock.unlock(); return temp; ProperLes Mutual exclusion: S i : The i:th interval during which thread is in its crilcal seclon For any,, i, j, S i - > S j or S j - > S i bsence of deadlock: If some thread calls lock() and never returns (i.e. it has acquired the lock) then other threads acquire and release the lock infinitely onen No starvalon: Each call to lock() eventually returns Threads, First empt class LockOne implements Lock { private boolean[] flag = new boolean[]; while (flag[otherthread]) { Threads, First empt Lemma: Mutual exclusion holds Proof: Suppose flag[thisthread] = false S S Notes: LockOne deadlocks flag array should be declared volalle, why? class LockOne implements Lock { private boolean[] flag = new boolean[]; while (flag[otherthread]) { flag[thisthread] = false Threads, First empt Threads, First empt S S write (flag[] = true) read (flag[] = false) S write (flag[] = true) read (flag[] = false) S write (flag[] = true) (Otherwise would have len c.s. already) class LockOne implements Lock { private boolean[] flag = new boolean[]; while (flag[otherthread]) { flag[thisthread] = false class LockOne implements Lock { private boolean[] flag = new boolean[]; while (flag[otherthread]) { flag[thisthread] = false 5

6 /8/ Threads, First empt Threads, First empt S write (flag[] = true) S read (flag[] = false) read (flag[] = false) (by the code) write (flag[] = true) S write (flag[] = true) S read (flag[] = false) read (flag[] = false) (but flag[] was never wrien to! QED) write (flag[] = true) class LockOne implements Lock { private boolean[] flag = new boolean[]; while (flag[otherthread]) { flag[thisthread] = false class LockOne implements Lock { private boolean[] flag = new boolean[]; while (flag[otherthread]) { flag[thisthread] = false Threads, Second empt LockTwo, Mutual Exclusion public class LockTwo implements Lock { private int victim; while (victim == thisthread) {; write (viclm = ) read (viclm = ) S (by the code) S Notes: victim = : defers to LockTwo also deadlocks public class LockTwo implements Lock { private int victim; while (victim == thisthread) {; LockTwo, Mutual Exclusion LockTwo, Mutual Exclusion S S write (viclm = ) read (viclm = ) write (viclm = ) (since viclm must be wrien) S write (viclm = ) S read (viclm = ) write (viclm = ) read (viclm = ) (must be placed somewhere ) public class LockTwo implements Lock { private int victim; while (victim == thisthread) {; public class LockTwo implements Lock { private int victim; while (victim == thisthread) {; 6

7 /8/ LockTwo, Mutual Exclusion S write (viclm = ) S read (viclm = ) write (viclm = ) read (viclm = ) (but impossible) Peterson s lgorithm while (flag[otherthread] && victim == thisthread) {; flag[thisthread] = false; public class LockTwo implements Lock { private int victim; while (victim == thisthread) {; Notes: Flag your interest and step back if other thread also wants a go Peterson s lgorithm, Mutual Exclusion Peterson s lgorithm, Mutual Exclusion S S write (flag[] = true) S write (flag[] = true) S write (viclm = ) read (viclm) write (viclm = ) read (viclm) read (flag[]) write b (flag[] = true) read (flag[]) Don t yet know which value write (viclm = ) (Else goes first) while (flag[otherthread] && victim == thisthread) {; flag[thisthread] = false; while (flag[otherthread] && victim == thisthread) {; flag[thisthread] = false; Peterson s lgorithm, Mutual Exclusion Peterson s lgorithm, Mutual Exclusion S S write (flag[] = true) S write (flag[] = true) S write (viclm = ) read (viclm=) (since was last to assign to viclm) write (viclm = ) read (viclm=) write b (flag[] = true) read (flag[]) write b (flag[] = true) read (flag[]=false) (since entered S) write (viclm = ) write (viclm = ) while (flag[otherthread] && victim == thisthread) {; flag[thisthread] = false; while (flag[otherthread] && victim == thisthread) {; flag[thisthread] = false; 7

8 /8/ Peterson s lgorithm, Mutual Exclusion Peterson s lgorithm, No StarvaLon S write (flag[] = true) write (viclm = ) read (viclm=) write b (flag[] = true) read (flag[]=false) (Impossible, qed) write (viclm = ) S Suppose thread spins from Lme t onwards Then viclm = and flag[] = true infinitely onen (i.o.) Since flag[] = true i.o.: Either enters and exits S i.o. ut then viclm = almost always ( almost always = always, from some Lme t onwards) Else spins in the lock() loop ut then viclm = almost always, a contradiclon while (flag[otherthread] && victim == thisthread) {; flag[thisthread] = false; while (flag[otherthread] && victim == thisthread) {; flag[thisthread] = false; Lamport s akery lgorithm Lamport s akery lgorithm Used to declare interest, as earlier class akery implements Lock { boolean[] flag; Smallest non- zero label Label[] label; gets to go public akery (int n) { flag = new boolean[n]; label = new Label[n]; for (int i = ; i < n; i++) { flag[i] = false; label[i] = ; I want the cs class akery implements Lock { flag[i] = true; label[i] = max(label[],,label[n-])+; while (exists k flag[k] && (label[i],i) > (label[k],k)) {; Pick a new Lcket, later than any already in use Doorway Wait unll the new Lcket is minimal Uses lexicographic order to break symmetry Lamport s akery lgorithm class akery implements Lock { flag[i] = false; The akery lgorithm, orrectness Lemma: The akery algorithm is deadlock free Proof: Eventually a wailng thread will hold the least (label, thread) pair. QED Lemma: The akery algorithm is first- come- first- served Proof: First through the doorway gets the smallest Lcket. QED Lemma: The akery algorithm salsfies mutual exclusion Proof: heck the textbook. 8

9 /8/ Timestamps akery algorithm: Timestamp: (label, thread) pair Timestamp domain unbounded for correctness Two operalons needed: scan: Sample the label array label: Produce a new label, strict upper bound of scanned labels Possible to do this using only bounded data? ounded Timestamps Possible to build bounded Lmestamp system which Is wait- free i.e. no locks For mullple threads (cf. Dolev- Shavit- SIM- 97) Here only sequenlal solulon Not wait- free So useless for the akery algorithm SLll of interest Two Thread ounded Precedence Graph Three Thread ounded Precedence Graph? : has precedence over : has precedence over ut is not transilve! Eh? Want as well? What if wants precedence? Note that precedence here is not transilve! Three Thread ounded Precedence Graph Three Thread ounded Precedence Graph Edge from all vertex in cycle to any vertex in cycle etc moves 9

10 /8/ Three Thread ounded Precedence Graph n Thread ounded Precedence Graph moves nd so on n thread graph size is 3 n- (!) So Is the akery lgorithm the Way to Go? The akery lgorithm is Succinct, Elegant, and Fair. Q: So why isn t it praclcal? : Well, you have to read n dislnct variables Shared Memory Shared read/write memory localons are called registers (for historical reasons) ome in different flavors MulL- Reader- Single- Writer (flag[]) MulL- Reader- MulL- Writer (victim[]) Less intereslng for now: SRMW and SRSW rt of Multiprocessor 57 rt of Multiprocessor 58 n MRSW Registers re Needed Theorem: t least n MRSW (mull- reader/single- writer) registers are needed to solve deadlock- free mutual exclusion. n registers like flag[] This is a lower bound result generally tough Proof Technique ssume that an algorithm for a lock object with < n MRSW registers exists The lock objects salsfies mutual exclusion, no deadlock, no starvalon Derive a contradiclon I.e., show a bad execulon that violates properles must exist The lock object must work correctly for all client programs So choose one with n threads which infinitely onen tries to enter and leave the crilcal seclon To be starvalon free whenever all threads in idle state - outside c.s. and outside the lock - each thread must be able to enter c.s. ON ITS OWN

11 /8/ Proof: n MRSW Registers re Needed Each thread must write to some register before entering c.s. Run and from idle state unll about to write to their registers can visit the cs Nothing has been wrien yet or can write and proceed to enter cs as well They have no way of telling whether or not is in cs Upper ound akery algorithm uses n MRSW registers So the bound is (prey) Lght ut what if we use MRMW registers? Like victim[]? write write S S S ad News Theorem t least n MRMW mull- reader/mull- writer registers are needed to solve deadlock- free mutual exclusion. Theorem (First - Threads) Theorem: Deadlock- free mutual exclusion for threads requires at least mull- reader mull- writer registers Proof: assume one register suffices and derive a contradiclon (So mullple writers don t help) rt of Multiprocessor 63 rt of Multiprocessor 64 Two Thread ExecuLon Threads run, reading and wrilng R Deadlock free so at least one gets in S write(r) R S overing State for One Register lways Exists In any protocol has to write to the register before entering S, so stop it just before write(r) over of register R: thread is about to write to R and R s value allows other threads to enter S overing state: ll shared registers are covered rt of Multiprocessor 65 rt of Multiprocessor 66

12 /8/ Proof: ssume over of Proof: ssume over of S write(r) runs, possibly writes to the register, enters S S write(r) S Runs, first obliteralng any trace of, then also enters the crilcal seclon rt of Multiprocessor 67 rt of Multiprocessor 68 Theorem Proof: ssume over of Deadlock- free mutual exclusion for 3 threads requires at least 3 mull- reader mull- writer registers has run from idle state unll about to write to R has run from idle state unll about to write to R is free to enter S Write(R ) Write(R ) We show later that such a state can be reached Only registers rt of Multiprocessor 69 7 Run Solo Obliterate Traces of Write(R ) Write(R ) Write(R ) Write(R ) S Writes to one or both registers, enters S S Other threads obliterate evidence that entered S rt of Multiprocessor 7 rt of Multiprocessor 7

13 /8/ Mutual Exclusion Fails overing State an e Reached S Write(R ) S Write(R ) S looks empty*, so another thread can get in Proved: a contradiclon starlng from a covering state for registers laim: a covering state for registers is reachable from any state where S is empty Problem: Registers may have mullple writers So threads may interfere So how can we be sure that two threads may each cover a register at the same Lme? (*) Looks empty: There is no informalon in any shared register that is not idle rt of Multiprocessor 74 overing State for Two overing State for Two Write(R ) If we run through S 3 Lmes, must return twice to cover some register, say R In each case: is outside S and has not wrien to any shared register since leaving idle state 75 Write(R ) Write(R ) Write(R ) Start with covering register R for the st Lme Run unll about to write to R This must be possible Else let write R only do that, let enter S, let write R This state looks the same to as one where did nothing 76 overing State for Two overing State for Two Write(R ) Write(R ) Write(R ) Write(R ) We were here: Start with covering register R for the st Lme Run unll about to write to uncovered R re we done? NO! could have written to R So S no longer looks empty This could prevent from entering S! rt of Multiprocessor 77 rt of Multiprocessor 78 3

14 /8/ overing State for Two InducLvely We an Show Write(R ) Write(R ) Run obliterating traces of in R Run again until it is about to write to R Remember wrote R then (maybe) R then R again fter each write enters S, exits S, enters idle state So after writing to R, leaves S so S looks empty to Now we are done Write(R ) There is a covering state Where k threads not in S cover k distinct registers Proof follows when k = n - rt of Multiprocessor Write(R ) 8 Write(R ) Summary of Lecture In the 96 s many incorrect solutions to starvation-free mutual exclusion using RW-registers were published Today we know how to solve FIFO n thread mutual exclusion using n RW-Registers This is optimal within factor ut n registers for n thread mutual exclusion is not a scalable solution Solution: Hardware supported atomic registers oming up: Which registers, what can they do? rt of Multiprocessor 8 4

DD2451 Parallel and Distributed Computing --- FDD3008 Distributed Algorithms

DD2451 Parallel and Distributed Computing --- FDD3008 Distributed Algorithms DD2451 Parallel and Distributed Computing --- FDD3008 Distributed Algorithms Lecture 1 Mads Dam Autumn/Winter 2011 DD2451 Overview Lectures 12 double lectures Twice a week until beg. December Focus on

More information

Lecture 7: Mutual Exclusion 2/16/12. slides adapted from The Art of Multiprocessor Programming, Herlihy and Shavit

Lecture 7: Mutual Exclusion 2/16/12. slides adapted from The Art of Multiprocessor Programming, Herlihy and Shavit Principles of Concurrency and Parallelism Lecture 7: Mutual Exclusion 2/16/12 slides adapted from The Art of Multiprocessor Programming, Herlihy and Shavit Time Absolute, true and mathematical time, of

More information

Peterson s Algorithm

Peterson s Algorithm Peterson s Algorithm public void lock() { flag[i] = true; victim = i; while (flag[j] && victim == i) {}; } public void unlock() { flag[i] = false; } 24/03/10 Art of Multiprocessor Programming 1 Mutual

More information

Programming Paradigms for Concurrency Lecture 2 - Mutual Exclusion

Programming Paradigms for Concurrency Lecture 2 - Mutual Exclusion Programming Paradigms for Concurrency Lecture 2 - Mutual Exclusion Based on companion slides for The Art of Multiprocessor Programming by Maurice Herlihy & Nir Shavit Modified by Thomas Wies New York University

More information

Mutual Exclusion. Companion slides for The Art of Multiprocessor Programming by Maurice Herlihy & Nir Shavit

Mutual Exclusion. Companion slides for The Art of Multiprocessor Programming by Maurice Herlihy & Nir Shavit Mutual Exclusion Companion slides for The by Maurice Herlihy & Nir Shavit Mutual Exclusion Today we will try to formalize our understanding of mutual exclusion We will also use the opportunity to show

More information

What We'll Cover Today

What We'll Cover Today Mutual Exclusion Acknowledgement: Slides adopted from the companion slides for the book "The Art of Mul>processor Programming" by Maurice Herlihy and Nir Shavit What We'll Cover Today Chapter 2 of: Digital

More information

Mutual Exclusion. 1 Formal problem definitions. Time notion CSE /17/2015. Outline of this lecture:

Mutual Exclusion. 1 Formal problem definitions. Time notion CSE /17/2015. Outline of this lecture: CSE 539 03/17/2015 Mutual Exclusion Lecture 15 Scribe: Son Dinh Outline of this lecture: 1. Formal problem definitions 2. Solution for 2 threads 3. Solution for n threads 4. Inherent costs of mutual exclusion

More information

Mutual Exclusion. Companion slides for The Art of Multiprocessor Programming by Maurice Herlihy & Nir Shavit

Mutual Exclusion. Companion slides for The Art of Multiprocessor Programming by Maurice Herlihy & Nir Shavit Mutual Exclusion Companion slides for The by Maurice Herlihy & Nir Shavit Mutual Exclusion In his 1965 paper E. W. Dijkstra wrote: "Given in this paper is a solution to a problem which, to the knowledge

More information

Mutual Exclusion: Classical Algorithms for Locks

Mutual Exclusion: Classical Algorithms for Locks Mutual Exclusion: Classical Algorithms for Locks John Mellor-Crummey Department of Computer Science Rice University johnmc@cs.rice.edu COMP 422 Lecture 18 21 March 2006 Motivation Ensure that a block of

More information

Solution: a lock (a/k/a mutex) public: virtual void unlock() =0;

Solution: a lock (a/k/a mutex) public: virtual void unlock() =0; 1 Solution: a lock (a/k/a mutex) class BasicLock { public: virtual void lock() =0; virtual void unlock() =0; ; 2 Using a lock class Counter { public: int get_and_inc() { lock_.lock(); int old = count_;

More information

DD2451 Parallel and Distributed Computing --- FDD3008 Distributed Algorithms

DD2451 Parallel and Distributed Computing --- FDD3008 Distributed Algorithms DD2451 Parallel and Distributed Computing --- FDD3008 Distributed Algorithms Lecture 3 Atomic Registers Mads Dam Autumn/Winter 2011 This Lecture Registers: Shared memory loca6ons that can be read and wri'en

More information

Programming Paradigms for Concurrency Lecture 3 Concurrent Objects

Programming Paradigms for Concurrency Lecture 3 Concurrent Objects Programming Paradigms for Concurrency Lecture 3 Concurrent Objects Based on companion slides for The Art of Multiprocessor Programming by Maurice Herlihy & Nir Shavit Modified by Thomas Wies New York University

More information

Lecture. DM510 - Operating Systems, Weekly Notes, Week 11/12, 2018

Lecture. DM510 - Operating Systems, Weekly Notes, Week 11/12, 2018 Lecture In the lecture on March 13 we will mainly discuss Chapter 6 (Process Scheduling). Examples will be be shown for the simulation of the Dining Philosopher problem, a solution with monitors will also

More information

Concurrent Objects. Companion slides for The Art of Multiprocessor Programming by Maurice Herlihy & Nir Shavit

Concurrent Objects. Companion slides for The Art of Multiprocessor Programming by Maurice Herlihy & Nir Shavit Concurrent Objects Companion slides for The by Maurice Herlihy & Nir Shavit Concurrent Computation memory object object 2 Objectivism What is a concurrent object? How do we describe one? How do we implement

More information

Models of concurrency & synchronization algorithms

Models of concurrency & synchronization algorithms Models of concurrency & synchronization algorithms Lecture 3 of TDA383/DIT390 (Concurrent Programming) Carlo A. Furia Chalmers University of Technology University of Gothenburg SP3 2016/2017 Today s menu

More information

Chapter 6: Process [& Thread] Synchronization. CSCI [4 6] 730 Operating Systems. Why does cooperation require synchronization?

Chapter 6: Process [& Thread] Synchronization. CSCI [4 6] 730 Operating Systems. Why does cooperation require synchronization? Chapter 6: Process [& Thread] Synchronization CSCI [4 6] 730 Operating Systems Synchronization Part 1 : The Basics Why is synchronization needed? Synchronization Language/Definitions:» What are race conditions?»

More information

SPIN, PETERSON AND BAKERY LOCKS

SPIN, PETERSON AND BAKERY LOCKS Concurrent Programs reasoning about their execution proving correctness start by considering execution sequences CS4021/4521 2018 jones@scss.tcd.ie School of Computer Science and Statistics, Trinity College

More information

Concurrent Computing

Concurrent Computing Concurrent Computing Introduction SE205, P1, 2017 Administrivia Language: (fr)anglais? Lectures: Fridays (15.09-03.11), 13:30-16:45, Amphi Grenat Web page: https://se205.wp.imt.fr/ Exam: 03.11, 15:15-16:45

More information

Important Lessons. A Distributed Algorithm (2) Today's Lecture - Replication

Important Lessons. A Distributed Algorithm (2) Today's Lecture - Replication Important Lessons Lamport & vector clocks both give a logical timestamps Total ordering vs. causal ordering Other issues in coordinating node activities Exclusive access to resources/data Choosing a single

More information

! Why is synchronization needed? ! Synchronization Language/Definitions: ! How are locks implemented? Maria Hybinette, UGA

! Why is synchronization needed? ! Synchronization Language/Definitions: ! How are locks implemented? Maria Hybinette, UGA Chapter 6: Process [& Thread] Synchronization CSCI [4 6] 730 Operating Systems Synchronization Part 1 : The Basics! Why is synchronization needed?! Synchronization Language/Definitions:» What are race

More information

Concurrent Objects and Linearizability

Concurrent Objects and Linearizability Chapter 3 Concurrent Objects and Linearizability 3.1 Specifying Objects An object in languages such as Java and C++ is a container for data. Each object provides a set of methods that are the only way

More information

Unit 6: Indeterminate Computation

Unit 6: Indeterminate Computation Unit 6: Indeterminate Computation Martha A. Kim October 6, 2013 Introduction Until now, we have considered parallelizations of sequential programs. The parallelizations were deemed safe if the parallel

More information

Overview of Lecture 4. Memory Models, Atomicity & Performance. Ben-Ari Concurrency Model. Dekker s Algorithm 4

Overview of Lecture 4. Memory Models, Atomicity & Performance. Ben-Ari Concurrency Model. Dekker s Algorithm 4 Concurrent and Distributed Programming http://fmt.cs.utwente.nl/courses/cdp/ Overview of Lecture 4 2 Memory Models, tomicity & Performance HC 4 - Tuesday, 6 December 2011 http://fmt.cs.utwente.nl/~marieke/

More information

Lecture Topics. Announcements. Today: Concurrency: Mutual Exclusion (Stallings, chapter , 5.7)

Lecture Topics. Announcements. Today: Concurrency: Mutual Exclusion (Stallings, chapter , 5.7) Lecture Topics Today: Concurrency: Mutual Exclusion (Stallings, chapter 5.1-5.4, 5.7) Next: Concurrency: Deadlock and Starvation (Stallings, chapter 6.1, 6.6-6.8) 1 Announcements Self-Study Exercise #5

More information

Introduction to Concurrency and Multicore Programming. Slides adapted from Art of Multicore Programming by Herlihy and Shavit

Introduction to Concurrency and Multicore Programming. Slides adapted from Art of Multicore Programming by Herlihy and Shavit Introduction to Concurrency and Multicore Programming Slides adapted from Art of Multicore Programming by Herlihy and Shavit Overview Introduction Mutual Exclusion Linearizability Concurrent Data Structure

More information

CSE332: Data Abstractions Lecture 22: Shared-Memory Concurrency and Mutual Exclusion. Tyler Robison Summer 2010

CSE332: Data Abstractions Lecture 22: Shared-Memory Concurrency and Mutual Exclusion. Tyler Robison Summer 2010 CSE332: Data Abstractions Lecture 22: Shared-Memory Concurrency and Mutual Exclusion Tyler Robison Summer 2010 1 Toward sharing resources (memory) So far we ve looked at parallel algorithms using fork-join

More information

Topics in Reliable Distributed Systems

Topics in Reliable Distributed Systems Topics in Reliable Distributed Systems 049017 1 T R A N S A C T I O N S Y S T E M S What is A Database? Organized collection of data typically persistent organization models: relational, object-based,

More information

CSCI [4 6] 730 Operating Systems. Example Execution. Process [& Thread] Synchronization. Why does cooperation require synchronization?

CSCI [4 6] 730 Operating Systems. Example Execution. Process [& Thread] Synchronization. Why does cooperation require synchronization? Process [& Thread] Synchronization CSCI [4 6] 730 Operating Systems Synchronization Part 1 : The Basics Why is synchronization needed? Synchronization Language/Definitions: What are race conditions? What

More information

DD2451 Parallel and Distributed Computing --- FDD3008 Distributed Algorithms

DD2451 Parallel and Distributed Computing --- FDD3008 Distributed Algorithms DD2451 Parallel and Distributed Computing --- FDD3008 Distributed Algorithms Lecture 4 Consensus, I Mads Dam Autumn/Winter 2011 Slides: Much material due to M. Herlihy and R Wa8enhofer Last Lecture Shared

More information

Synchronization API of Pthread Mutex: lock, unlock, try_lock CondVar: wait, signal, signal_broadcast. Synchronization

Synchronization API of Pthread Mutex: lock, unlock, try_lock CondVar: wait, signal, signal_broadcast. Synchronization CS341: Operating System Lect20 : 16 th Sept 2014 Dr. A. Sahu Dept of Comp. Sc. & Engg. Indian Institute of Technology Guwahati Synchronization API of Pthread Mutex: lock, unlock, try_lock CondVar: wait,

More information

Computing with Infinitely Many Processes under assumptions on concurrency and participation -M.Merritt&G.Taubenfeld. Dean Christakos & Deva Seetharam

Computing with Infinitely Many Processes under assumptions on concurrency and participation -M.Merritt&G.Taubenfeld. Dean Christakos & Deva Seetharam Computing with Infinitely Many Processes under assumptions on concurrency and participation -M.Merritt&G.Taubenfeld Dean Christakos & Deva Seetharam November 25, 2003 Abstract This paper explores four

More information

A Simple Example. The Synchronous Language Esterel. A First Try: An FSM. The Esterel Version. The Esterel Version. The Esterel Version

A Simple Example. The Synchronous Language Esterel. A First Try: An FSM. The Esterel Version. The Esterel Version. The Esterel Version The Synchronous Language Prof. Stephen. Edwards Simple Example The specification: The output O should occur when inputs and have both arrived. The R input should restart this behavior. First Try: n FSM

More information

Agenda. Lecture. Next discussion papers. Bottom-up motivation Shared memory primitives Shared memory synchronization Barriers and locks

Agenda. Lecture. Next discussion papers. Bottom-up motivation Shared memory primitives Shared memory synchronization Barriers and locks Agenda Lecture Bottom-up motivation Shared memory primitives Shared memory synchronization Barriers and locks Next discussion papers Selecting Locking Primitives for Parallel Programming Selecting Locking

More information

1 The comparison of QC, SC and LIN

1 The comparison of QC, SC and LIN Com S 611 Spring Semester 2009 Algorithms for Multiprocessor Synchronization Lecture 5: Tuesday, 3rd February 2009 Instructor: Soma Chaudhuri Scribe: Jianrong Dong 1 The comparison of QC, SC and LIN Pi

More information

Synchronization. CS 475, Spring 2018 Concurrent & Distributed Systems

Synchronization. CS 475, Spring 2018 Concurrent & Distributed Systems Synchronization CS 475, Spring 2018 Concurrent & Distributed Systems Review: Threads: Memory View code heap data files code heap data files stack stack stack stack m1 m1 a1 b1 m2 m2 a2 b2 m3 m3 a3 m4 m4

More information

CSE 486/586 Distributed Systems

CSE 486/586 Distributed Systems CSE 486/586 Distributed Systems Mutual Exclusion Steve Ko Computer Sciences and Engineering University at Buffalo CSE 486/586 Recap: Consensus On a synchronous system There s an algorithm that works. On

More information

CSE 153 Design of Operating Systems

CSE 153 Design of Operating Systems CSE 153 Design of Operating Systems Winter 19 Lecture 7/8: Synchronization (1) Administrivia How is Lab going? Be prepared with questions for this weeks Lab My impression from TAs is that you are on track

More information

Spin Locks and Contention. Companion slides for The Art of Multiprocessor Programming by Maurice Herlihy & Nir Shavit

Spin Locks and Contention. Companion slides for The Art of Multiprocessor Programming by Maurice Herlihy & Nir Shavit Spin Locks and Contention Companion slides for The Art of Multiprocessor Programming by Maurice Herlihy & Nir Shavit Focus so far: Correctness and Progress Models Accurate (we never lied to you) But idealized

More information

Synchronization Principles

Synchronization Principles Synchronization Principles Gordon College Stephen Brinton The Problem with Concurrency Concurrent access to shared data may result in data inconsistency Maintaining data consistency requires mechanisms

More information

Introduction to OS Synchronization MOS 2.3

Introduction to OS Synchronization MOS 2.3 Introduction to OS Synchronization MOS 2.3 Mahmoud El-Gayyar elgayyar@ci.suez.edu.eg Mahmoud El-Gayyar / Introduction to OS 1 Challenge How can we help processes synchronize with each other? E.g., how

More information

The Relative Power of Synchronization Methods

The Relative Power of Synchronization Methods Chapter 5 The Relative Power of Synchronization Methods So far, we have been addressing questions of the form: Given objects X and Y, is there a wait-free implementation of X from one or more instances

More information

10/17/ Gribble, Lazowska, Levy, Zahorjan 2. 10/17/ Gribble, Lazowska, Levy, Zahorjan 4

10/17/ Gribble, Lazowska, Levy, Zahorjan 2. 10/17/ Gribble, Lazowska, Levy, Zahorjan 4 Temporal relations CSE 451: Operating Systems Autumn 2010 Module 7 Synchronization Instructions executed by a single thread are totally ordered A < B < C < Absent synchronization, instructions executed

More information

Pre- and post- CS protocols. CS 361 Concurrent programming Drexel University Fall 2004 Lecture 7. Other requirements for a mutual exclusion algorithm

Pre- and post- CS protocols. CS 361 Concurrent programming Drexel University Fall 2004 Lecture 7. Other requirements for a mutual exclusion algorithm CS 361 Concurrent programming Drexel University Fall 2004 Lecture 7 Bruce Char and Vera Zaychik. All rights reserved by the author. Permission is given to students enrolled in CS361 Fall 2004 to reproduce

More information

CSE 451: Operating Systems Winter Lecture 7 Synchronization. Steve Gribble. Synchronization. Threads cooperate in multithreaded programs

CSE 451: Operating Systems Winter Lecture 7 Synchronization. Steve Gribble. Synchronization. Threads cooperate in multithreaded programs CSE 451: Operating Systems Winter 2005 Lecture 7 Synchronization Steve Gribble Synchronization Threads cooperate in multithreaded programs to share resources, access shared data structures e.g., threads

More information

G52CON: Concepts of Concurrency

G52CON: Concepts of Concurrency G52CON: Concepts of Concurrency Lecture 11: Semaphores I" Brian Logan School of Computer Science bsl@cs.nott.ac.uk Outline of this lecture" problems with Peterson s algorithm semaphores implementing semaphores

More information

CS 153 Design of Operating Systems Winter 2016

CS 153 Design of Operating Systems Winter 2016 CS 153 Design of Operating Systems Winter 2016 Lecture 7: Synchronization Administrivia Homework 1 Due today by the end of day Hopefully you have started on project 1 by now? Kernel-level threads (preemptable

More information

Chapter 6: Synchronization. Chapter 6: Synchronization. 6.1 Background. Part Three - Process Coordination. Consumer. Producer. 6.

Chapter 6: Synchronization. Chapter 6: Synchronization. 6.1 Background. Part Three - Process Coordination. Consumer. Producer. 6. Part Three - Process Coordination Chapter 6: Synchronization 6.1 Background Concurrent access to shared data may result in data inconsistency Maintaining data consistency requires mechanisms to ensure

More information

10/17/2011. Cooperating Processes. Synchronization 1. Example: Producer Consumer (3) Example

10/17/2011. Cooperating Processes. Synchronization 1. Example: Producer Consumer (3) Example Cooperating Processes Synchronization 1 Chapter 6.1 4 processes share something (devices such as terminal, keyboard, mouse, etc., or data structures) and can affect each other non deterministic Not exactly

More information

Consistency. CS 475, Spring 2018 Concurrent & Distributed Systems

Consistency. CS 475, Spring 2018 Concurrent & Distributed Systems Consistency CS 475, Spring 2018 Concurrent & Distributed Systems Review: 2PC, Timeouts when Coordinator crashes What if the bank doesn t hear back from coordinator? If bank voted no, it s OK to abort If

More information

Module 6: Process Synchronization. Operating System Concepts with Java 8 th Edition

Module 6: Process Synchronization. Operating System Concepts with Java 8 th Edition Module 6: Process Synchronization 6.1 Silberschatz, Galvin and Gagne 2009 Module 6: Process Synchronization Background The Critical-Section Problem Peterson s Solution Synchronization Hardware Semaphores

More information

Chapter 6: Process Synchronization

Chapter 6: Process Synchronization Chapter 6: Process Synchronization Chapter 6: Synchronization 6.1 Background 6.2 The Critical-Section Problem 6.3 Peterson s Solution 6.4 Synchronization Hardware 6.5 Mutex Locks 6.6 Semaphores 6.7 Classic

More information

Chapter 6: Process Synchronization. Module 6: Process Synchronization

Chapter 6: Process Synchronization. Module 6: Process Synchronization Chapter 6: Process Synchronization Module 6: Process Synchronization Background The Critical-Section Problem Peterson s Solution Synchronization Hardware Semaphores Classic Problems of Synchronization

More information

Spin Locks and Contention. Companion slides for Chapter 7 The Art of Multiprocessor Programming by Maurice Herlihy & Nir Shavit

Spin Locks and Contention. Companion slides for Chapter 7 The Art of Multiprocessor Programming by Maurice Herlihy & Nir Shavit Spin Locks and Contention Companion slides for Chapter 7 The Art of Multiprocessor Programming by Maurice Herlihy & Nir Shavit Focus so far: Correctness and Progress Models Accurate (we never lied to you)

More information

RACE CONDITIONS AND SYNCHRONIZATION

RACE CONDITIONS AND SYNCHRONIZATION RACE CONDITIONS AND SYNCHRONIZATION Lecture 21 CS2110 Fall 2010 Reminder 2 A race condition arises if two threads try and share some data One updates it and the other reads it, or both update the data

More information

Shared Objects. Shared Objects

Shared Objects. Shared Objects Shared Objects Shared Objects Invoked operations have a non-zero duration Invocations can overlap Useful for: modeling distributed shared memory Objects can be combined together to implement higher level

More information

Dr. D. M. Akbar Hussain DE5 Department of Electronic Systems

Dr. D. M. Akbar Hussain DE5 Department of Electronic Systems Concurrency 1 Concurrency Execution of multiple processes. Multi-programming: Management of multiple processes within a uni- processor system, every system has this support, whether big, small or complex.

More information

CS370 Operating Systems

CS370 Operating Systems CS370 Operating Systems Colorado State University Yashwant K Malaiya Fall 2017 Lecture 11 Slides based on Text by Silberschatz, Galvin, Gagne Various sources 1 1 FAQ Multilevel Feedback Queue: Q0, Q1,

More information

Implementing Mutual Exclusion. Sarah Diesburg Operating Systems CS 3430

Implementing Mutual Exclusion. Sarah Diesburg Operating Systems CS 3430 Implementing Mutual Exclusion Sarah Diesburg Operating Systems CS 3430 From the Previous Lecture The too much milk example shows that writing concurrent programs directly with load and store instructions

More information

Operating Systems. Synchronization

Operating Systems. Synchronization Operating Systems Fall 2014 Synchronization Myungjin Lee myungjin.lee@ed.ac.uk 1 Temporal relations Instructions executed by a single thread are totally ordered A < B < C < Absent synchronization, instructions

More information

Lecture Topics. Announcements. Today: Concurrency (Stallings, chapter , 5.7) Next: Exam #1. Self-Study Exercise #5. Project #3 (due 9/28)

Lecture Topics. Announcements. Today: Concurrency (Stallings, chapter , 5.7) Next: Exam #1. Self-Study Exercise #5. Project #3 (due 9/28) Lecture Topics Today: Concurrency (Stallings, chapter 5.1-5.4, 5.7) Next: Exam #1 1 Announcements Self-Study Exercise #5 Project #3 (due 9/28) Project #4 (due 10/12) 2 Exam #1 Tuesday, 10/3 during lecture

More information

Chapter 5: Process Synchronization. Operating System Concepts Essentials 2 nd Edition

Chapter 5: Process Synchronization. Operating System Concepts Essentials 2 nd Edition Chapter 5: Process Synchronization Silberschatz, Galvin and Gagne 2013 Chapter 5: Process Synchronization Background The Critical-Section Problem Peterson s Solution Synchronization Hardware Mutex Locks

More information

Operating Systems CMPSC 473. Synchronization February 21, Lecture 11 Instructor: Trent Jaeger

Operating Systems CMPSC 473. Synchronization February 21, Lecture 11 Instructor: Trent Jaeger Operating Systems CMPSC 473 Synchronization February 21, 2008 - Lecture 11 Instructor: Trent Jaeger Last class: CPU Scheduling Today: A little more scheduling Start synchronization Little s Law Evaluating

More information

Spin Locks and Contention

Spin Locks and Contention Spin Locks and Contention Companion slides for The Art of Multiprocessor Programming by Maurice Herlihy & Nir Shavit Modified for Software1 students by Lior Wolf and Mati Shomrat Kinds of Architectures

More information

Process Synchronization

Process Synchronization Process Synchronization Concurrent access to shared data may result in data inconsistency Multiple threads in a single process Maintaining data consistency requires mechanisms to ensure the orderly execution

More information

Atomicity and Virtualization. Atomicity. Critical section. Edsger s perspective. Virtualizing a resource requires managing concurrent accesses

Atomicity and Virtualization. Atomicity. Critical section. Edsger s perspective. Virtualizing a resource requires managing concurrent accesses Atomicity and Virtualization Atomicity Virtualizing a resource requires managing concurrent accesses data structures must transition between consistent states atomic actions transform state indivisibly

More information

Chapter 6: Synchronization. Operating System Concepts 8 th Edition,

Chapter 6: Synchronization. Operating System Concepts 8 th Edition, Chapter 6: Synchronization, Silberschatz, Galvin and Gagne 2009 Outline Background The Critical-Section Problem Peterson s Solution Synchronization Hardware Semaphores Classic Problems of Synchronization

More information

Spin Locks and Contention. Companion slides for The Art of Multiprocessor Programming by Maurice Herlihy & Nir Shavit

Spin Locks and Contention. Companion slides for The Art of Multiprocessor Programming by Maurice Herlihy & Nir Shavit Spin Locks and Contention Companion slides for The Art of Multiprocessor Programming by Maurice Herlihy & Nir Shavit Real world concurrency Understanding hardware architecture What is contention How to

More information

Process Synchronization. Mehdi Kargahi School of ECE University of Tehran Spring 2008

Process Synchronization. Mehdi Kargahi School of ECE University of Tehran Spring 2008 Process Synchronization Mehdi Kargahi School of ECE University of Tehran Spring 2008 Producer-Consumer (Bounded Buffer) Producer Consumer Race Condition Producer Consumer Critical Sections Structure of

More information

Synchronization I. Jin-Soo Kim Computer Systems Laboratory Sungkyunkwan University

Synchronization I. Jin-Soo Kim Computer Systems Laboratory Sungkyunkwan University Synchronization I Jin-Soo Kim (jinsookim@skku.edu) Computer Systems Laboratory Sungkyunkwan University http://csl.skku.edu Today s Topics Synchronization problem Locks 2 Synchronization Threads cooperate

More information

CSL373: Lecture 5 Deadlocks (no process runnable) + Scheduling (> 1 process runnable)

CSL373: Lecture 5 Deadlocks (no process runnable) + Scheduling (> 1 process runnable) CSL373: Lecture 5 Deadlocks (no process runnable) + Scheduling (> 1 process runnable) Past & Present Have looked at two constraints: Mutual exclusion constraint between two events is a requirement that

More information

Synchronization for Concurrent Tasks

Synchronization for Concurrent Tasks Synchronization for Concurrent Tasks Minsoo Ryu Department of Computer Science and Engineering 2 1 Race Condition and Critical Section Page X 2 Algorithmic Approaches Page X 3 Hardware Support Page X 4

More information

Operating Systems. Designed and Presented by Dr. Ayman Elshenawy Elsefy

Operating Systems. Designed and Presented by Dr. Ayman Elshenawy Elsefy Operating Systems Designed and Presented by Dr. Ayman Elshenawy Elsefy Dept. of Systems & Computer Eng.. AL-AZHAR University Website : eaymanelshenawy.wordpress.com Email : eaymanelshenawy@yahoo.com Reference

More information

Concurrency. Chapter 5

Concurrency. Chapter 5 Concurrency 1 Chapter 5 2 Concurrency Is a fundamental concept in operating system design Processes execute interleaved in time on a single processor Creates the illusion of simultaneous execution Benefits

More information

Dept. of CSE, York Univ. 1

Dept. of CSE, York Univ. 1 EECS 3221.3 Operating System Fundamentals No.5 Process Synchronization(1) Prof. Hui Jiang Dept of Electrical Engineering and Computer Science, York University Background: cooperating processes with shared

More information

CS370 Operating Systems

CS370 Operating Systems CS370 Operating Systems Colorado State University Yashwant K Malaiya Spring 1018 L11 Synchronization Slides based on Text by Silberschatz, Galvin, Gagne Various sources 1 1 FAQ Multilevel feedback queue:

More information

CSE 451: Operating Systems Winter Lecture 7 Synchronization. Hank Levy 412 Sieg Hall

CSE 451: Operating Systems Winter Lecture 7 Synchronization. Hank Levy 412 Sieg Hall CSE 451: Operating Systems Winter 2003 Lecture 7 Synchronization Hank Levy Levy@cs.washington.edu 412 Sieg Hall Synchronization Threads cooperate in multithreaded programs to share resources, access shared

More information

Sequen&al Consistency and Linearizability

Sequen&al Consistency and Linearizability Sequen&al Consistency and Linearizability (Or, Reasoning About Concurrent Objects) Acknowledgement: Slides par&ally adopted from the companion slides for the book "The Art of Mul&processor Programming"

More information

CS 31: Introduction to Computer Systems : Threads & Synchronization April 16-18, 2019

CS 31: Introduction to Computer Systems : Threads & Synchronization April 16-18, 2019 CS 31: Introduction to Computer Systems 22-23: Threads & Synchronization April 16-18, 2019 Making Programs Run Faster We all like how fast computers are In the old days (1980 s - 2005): Algorithm too slow?

More information

CS5460: Operating Systems

CS5460: Operating Systems CS5460: Operating Systems Lecture 9: Implementing Synchronization (Chapter 6) Multiprocessor Memory Models Uniprocessor memory is simple Every load from a location retrieves the last value stored to that

More information

Chapter 6: Process Synchronization

Chapter 6: Process Synchronization Chapter 6: Process Synchronization Objectives Introduce Concept of Critical-Section Problem Hardware and Software Solutions of Critical-Section Problem Concept of Atomic Transaction Operating Systems CS

More information

Review of last lecture. Peer Quiz. DPHPC Overview. Goals of this lecture. Lock-based queue

Review of last lecture. Peer Quiz. DPHPC Overview. Goals of this lecture. Lock-based queue Review of last lecture Design of Parallel and High-Performance Computing Fall 2016 Lecture: Linearizability Motivational video: https://www.youtube.com/watch?v=qx2driqxnbs Instructor: Torsten Hoefler &

More information

CSE 120. Fall Lecture 6: Semaphores. Keith Marzullo

CSE 120. Fall Lecture 6: Semaphores. Keith Marzullo CSE 120 Principles of Operating Systems Fall 2007 Lecture 6: Semaphores Keith Marzullo Announcements Homework #2 out Homework #1 almost graded... Discussion session on Wednesday will entertain questions

More information

Synchronization I. Jo, Heeseung

Synchronization I. Jo, Heeseung Synchronization I Jo, Heeseung Today's Topics Synchronization problem Locks 2 Synchronization Threads cooperate in multithreaded programs To share resources, access shared data structures Also, to coordinate

More information

CS 4349 Lecture October 18th, 2017

CS 4349 Lecture October 18th, 2017 CS 4349 Lecture October 18th, 2017 Main topics for #lecture include #minimum_spanning_trees. Prelude Homework 6 due today. Homework 7 due Wednesday, October 25th. Homework 7 has one normal homework problem.

More information

Concurrent programming: From theory to practice. Concurrent Algorithms 2015 Vasileios Trigonakis

Concurrent programming: From theory to practice. Concurrent Algorithms 2015 Vasileios Trigonakis oncurrent programming: From theory to practice oncurrent Algorithms 2015 Vasileios Trigonakis From theory to practice Theoretical (design) Practical (design) Practical (implementation) 2 From theory to

More information

Thread Synchronization: Foundations. Properties. Safety properties. Edsger s perspective. Nothing bad happens

Thread Synchronization: Foundations. Properties. Safety properties. Edsger s perspective. Nothing bad happens Edsger s perspective Testing can only prove the presence of bugs Thread Synchronization: Foundations Properties Property: a predicate that is evaluated over a run of the program (a trace) every message

More information

Process Synchronization

Process Synchronization CSC 4103 - Operating Systems Spring 2007 Lecture - VI Process Synchronization Tevfik Koşar Louisiana State University February 6 th, 2007 1 Roadmap Process Synchronization The Critical-Section Problem

More information

A Sophomoric Introduction to Shared-Memory Parallelism and Concurrency Lecture 4 Shared-Memory Concurrency & Mutual Exclusion

A Sophomoric Introduction to Shared-Memory Parallelism and Concurrency Lecture 4 Shared-Memory Concurrency & Mutual Exclusion A Sophomoric Introduction to Shared-Memory Parallelism and Concurrency Lecture 4 Shared-Memory Concurrency & Mutual Exclusion Dan Grossman Last Updated: August 2010 For more information, see http://www.cs.washington.edu/homes/djg/teachingmaterials/

More information

Lesson 6: Process Synchronization

Lesson 6: Process Synchronization Lesson 6: Process Synchronization Chapter 5: Process Synchronization Background The Critical-Section Problem Peterson s Solution Synchronization Hardware Mutex Locks Semaphores Classic Problems of Synchronization

More information

The Art of Multiprocessor Programming Copyright 2007 Elsevier Inc. All rights reserved. October 3, 2007 DRAFT COPY

The Art of Multiprocessor Programming Copyright 2007 Elsevier Inc. All rights reserved. October 3, 2007 DRAFT COPY The Art of Multiprocessor Programming Copyright 2007 Elsevier Inc. All rights reserved Maurice Herlihy October 3, 2007 Nir Shavit 2 Contents 1 Introduction 13 1.1 Shared Objects and Synchronization..............

More information

Chapter 5: Process Synchronization. Operating System Concepts 9 th Edition

Chapter 5: Process Synchronization. Operating System Concepts 9 th Edition Chapter 5: Process Synchronization Silberschatz, Galvin and Gagne 2013 Chapter 5: Process Synchronization Background The Critical-Section Problem Peterson s Solution Synchronization Hardware Mutex Locks

More information

Linked Lists: Locking, Lock-Free, and Beyond. Companion slides for The Art of Multiprocessor Programming by Maurice Herlihy & Nir Shavit

Linked Lists: Locking, Lock-Free, and Beyond. Companion slides for The Art of Multiprocessor Programming by Maurice Herlihy & Nir Shavit Linked Lists: Locking, Lock-Free, and Beyond Companion slides for The Art of Multiprocessor Programming by Maurice Herlihy & Nir Shavit Concurrent Objects Adding threads should not lower throughput Contention

More information

Non-blocking Array-based Algorithms for Stacks and Queues!

Non-blocking Array-based Algorithms for Stacks and Queues! Non-blocking Array-based Algorithms for Stacks and Queues! Niloufar Shafiei! Department of Computer Science and Engineering York University ICDCN 09 Outline! Introduction! Stack algorithm! Queue algorithm!

More information

Chapter 6: Process Synchronization. Operating System Concepts 8 th Edition,

Chapter 6: Process Synchronization. Operating System Concepts 8 th Edition, Chapter 6: Process Synchronization, Silberschatz, Galvin and Gagne 2009 Module 6: Process Synchronization Background The Critical-Section Problem Peterson s Solution Synchronization Hardware Semaphores

More information

EECE.4810/EECE.5730: Operating Systems Spring 2017 Homework 2 Solution

EECE.4810/EECE.5730: Operating Systems Spring 2017 Homework 2 Solution 1. (15 points) A system with two dual-core processors has four processors available for scheduling. A CPU-intensive application (e.g., a program that spends most of its time on computation, not I/O or

More information

Midterm on next week Tuesday May 4. CS 361 Concurrent programming Drexel University Fall 2004 Lecture 9

Midterm on next week Tuesday May 4. CS 361 Concurrent programming Drexel University Fall 2004 Lecture 9 CS 361 Concurrent programming Drexel University Fall 2004 Lecture 9 Bruce Char and Vera Zaychik. All rights reserved by the author. Permission is given to students enrolled in CS361 Fall 2004 to reproduce

More information

Recall from Chapter 1 that a data race is a failure to correctly implement critical sections for non-atomic shared variable accesses.

Recall from Chapter 1 that a data race is a failure to correctly implement critical sections for non-atomic shared variable accesses. 3.10 Tracing, Testing, and Replay for Semaphores and Locks Outline: A technique for detecting violations of mutual exclusion. Tracing and replaying executions during debugging. Deadlock detection Reachability

More information

Non-blocking Array-based Algorithms for Stacks and Queues. Niloufar Shafiei

Non-blocking Array-based Algorithms for Stacks and Queues. Niloufar Shafiei Non-blocking Array-based Algorithms for Stacks and Queues Niloufar Shafiei Outline Introduction Concurrent stacks and queues Contributions New algorithms New algorithms using bounded counter values Correctness

More information

3. Concurrency Control for Transactions Part One

3. Concurrency Control for Transactions Part One 3. Concurrency Control for Transactions Part One CSEP 545 Transaction Processing Philip A. Bernstein Copyright 2012 Philip A. Bernstein 1/11/2012 1 Outline 1. A Simple System Model 2. Serializability Theory

More information

Chapter 7: Process Synchronization. Background. Illustration

Chapter 7: Process Synchronization. Background. Illustration Chapter 7: Process Synchronization Background The Critical-Section Problem Synchronization Hardware Semaphores Classical Problems of Synchronization Critical Regions Monitors Synchronization in Solaris

More information