Introduction to Concurrent Programming
|
|
- Emory Chambers
- 6 years ago
- Views:
Transcription
1 Σχολή Ηλεκτρολόγων Μηχανικών και Μηχανικών Υπολογιστών Τομέας Τεχνολογίας Πληροφορικής και Υπολογιστών Εθνικό Μετσόβιο Πολυτεχνείο Γλώσσες Προγραμματισμού ΙΙ Διδάσκοντες: Νικόλαος Παπασπύρου, Κωστής Σαγώνας Introduction to Concurrent Programming Based on the companion slides for the book The Art of Multiprocessor Programming by Maurice Herlihy & Nir Shavit, 2008
2 Άδεια Χρήσης Το παρόν εκπαιδευτικό υλικό υπόκειται σε άδειες χρήσης Creative Commons. Για εκπαιδευτικό υλικό, όπως εικόνες, που υπόκειται σε άδεια χρήσης άλλου τύπου, αυτή πρέπει να αναφέρεται ρητώς.
3 From the New York Times SAN FRANCISCO, 7 May Intel said on Friday that it was scrapping its development of two microprocessors, a move that is a shift in the company's business strategy. Introduction to Concurrent Programming 2
4 Moore s Law Transistor count still rising Clock speed flattening sharply Introduction to Concurrent Programming 3
5 Your Old Desktop: A Uniprocesor cpu memory Introduction to Concurrent Programming 4
6 Till recently in the Enterprise: The Shared Memory Multiprocessor (SMP) cache cache Bus cache Bus shared memory Introduction to Concurrent Programming 5
7 On Your New Desktop: The Multicore processor (CMP) All on the same chip cache cache cache Bus Bus shared memory Sun T2000 Niagara Introduction to Concurrent Programming 6
8 Multicores Are Here Intel's Intel ups ante with 4-core chip. New microprocessor, due this year, will be faster, use less electricity... [San Fran Chronicle] AMD will launch a dual-core version of its Opteron server processor at an event in New York on April 21. [PC World] Sun s Niagara will have eight cores, each core capable of running 4 threads in parallel, for 32 concurrently running threads.. [The Inquierer] Introduction to Concurrent Programming 7
9 Why do we care? Time no longer cures software bloat The free ride is over When you double your program s path length You can t just wait 6 months Your software must somehow exploit twice as much concurrency Introduction to Concurrent Programming 8
10 Traditional Scaling Process Speedup 1.8x 3.6x 7x User code Traditional Uniprocessor Time: Moore s law Introduction to Concurrent Programming 9
11 Multicore Scaling Process Speedup 1.8x 3.6x 7x User code Multicore Unfortunately, not so simple Introduction to Concurrent Programming 10
12 Real-World Scaling Process Speedup 1.8x 2x 2.9x User code Multicore Parallelization and Synchronization require great care Introduction to Concurrent Programming 11
13 Sequential Computation thread memory object object Introduction to Concurrent Programming 12
14 Concurrent Computation threads memory object object Introduction to Concurrent Programming 13
15 Asynchrony Sudden unpredictable delays Cache misses (short) Page faults (long) Scheduling quantum used up (really long) Introduction to Concurrent Programming 14
16 Model Summary Multiple threads Sometimes called processes Single shared memory Objects live in memory Unpredictable asynchronous delays Introduction to Concurrent Programming 15
17 Road Map We are going to focus on principles first, then practice Start with idealized models Look at simplistic problems Emphasize correctness over pragmatism Correctness may be theoretical, but incorrectness has practical impact Introduction to Concurrent Programming 16
18 Concurrency Jargon Hardware Processors, cores Software Threads, processes Sometimes OK to confuse them, sometimes not Introduction to Concurrent Programming 17
19 Parallel Primality Testing Challenge Print primes from 1 to Given Ten-processor multiprocessor One thread per processor Goal Get ten-fold speedup (or close) Introduction to Concurrent Programming 18
20 Load Balancing P 0 P 1 P 9 Split the work evenly Each thread tests range of 10 9 Introduction to Concurrent Programming 19
21 Procedure for Thread i void primeprint { int i = ThreadID.get(); // IDs in {0..9} for (j = i* , j < (i+1)*10 9 ; j++) { if (isprime(j)) print(j); } } Introduction to Concurrent Programming 20
22 Issues Higher ranges have fewer primes Yet larger numbers harder to test Thread workloads Uneven Hard to predict rejected Need dynamic load balancing Introduction to Concurrent Programming 21
23 Shared Counter each thread takes a number 17 Introduction to Concurrent Programming 22
24 Procedure for Thread i int counter = new Counter(1); void primeprint { long j = 0; while (j < ) { j = counter.getandincrement(); if (isprime(j)) print(j); } } Introduction to Concurrent Programming 23
25 Procedure for Thread i Counter counter = new Counter(1); void primeprint { long j = 0; while (j < ) { j = counter.getandincrement(); } } if (isprime(j)) print(j); Shared counter object Introduction to Concurrent Programming 24
26 Where Things Reside int counter = new Counter(1); void primeprint { long j = 0; while (j < ) { j = counter.getandincrement(); if (isprime(j)) print(j); } } code Local variables cache cache Bus cache Bus 1 shared memory shared counter Introduction to Concurrent Programming 25
27 Procedure for Thread i Counter counter = new Counter(1); void primeprint { Stop when every long j = 0; value taken while (j < ) { j = counter.getandincrement(); if (isprime(j)) print(j); } } Introduction to Concurrent Programming 26
28 Procedure for Thread i Counter counter = new Counter(1); void primeprint { long j = 0; while (j < ) { j = counter.getandincrement(); if (isprime(j)) print(j); } } Increment & return each new value Introduction to Concurrent Programming 27
29 Counter Implementation public class Counter { private long value; } public long getandincrement() { return value++; } OK for single thread, not for concurrent threads Introduction to Concurrent Programming 28
30 What It Means public class Counter { private long value; } public long getandincrement() { return value++; temp = value; } value = value + 1; return temp; Introduction to Concurrent Programming 29
31 Not so good Value read 1 write 2 read 2 write 3 read 1 write 2 time Introduction to Concurrent Programming 30
32 Is this problem inherent? read write write read If we could only glue reads and writes Introduction to Concurrent Programming 31
33 Challenge public class Counter { private long value; } public long getandincrement() { temp = value; value = temp + 1; return temp; } Make these steps atomic (indivisible) Introduction to Concurrent Programming 32
34 Hardware Solution public class Counter { private long value; public long getandincrement() { temp = value; value = temp + 1; return temp; } } ReadModifyWrite() instruction Introduction to Concurrent Programming 33
35 An Aside: Java public class Counter { private long value; } public long getandincrement() { synchronized { temp = value; value = temp + 1; } return temp; } Synchronized block Introduction to Concurrent Programming 34
36 An Aside: Java public class Counter { private long value; } public long getandincrement() { synchronized { temp = value; value = temp + 1; } return temp; } Mutual Exclusion Introduction to Concurrent Programming 35
37 Mutual Exclusion or Alice & Bob share a pond A B Introduction to Concurrent Programming 36
38 Alice has a pet A B Introduction to Concurrent Programming 37
39 Bob has a pet A B Introduction to Concurrent Programming 38
40 The Problem A B The pets don t get along Introduction to Concurrent Programming 39
41 Formalizing the Problem Two types of formal properties in asynchronous computation: Safety Properties Nothing bad happens ever Liveness Properties Something good happens eventually Introduction to Concurrent Programming 40
42 Formalizing our Problem Mutual Exclusion Both pets never in pond simultaneously This is a safety property No Deadlock if only one wants in, it gets in if both want in, one gets in. This is a liveness property Introduction to Concurrent Programming 41
43 Simple Protocol Idea Just look at the pond Gotcha Trees obscure the view Introduction to Concurrent Programming 42
44 Interpretation Threads can t see what other threads are doing Explicit communication required for coordination Introduction to Concurrent Programming 43
45 Mobile Phone Protocol Idea Bob sends SMS to Alice (or vice-versa) Gotcha Bob takes shower Alice recharges battery Bob out shopping for pet food Introduction to Concurrent Programming 44
46 Interpretation Message-passing doesn t work Recipient might not be Listening There at all Communication must be Persistent (like writing) Not transient (like speaking) Introduction to Concurrent Programming 45
47 Can Protocol cola cola Introduction to Concurrent Programming 46
48 Bob conveys a bit A B cola Introduction to Concurrent Programming 47
49 Bob conveys a bit A B cola Introduction to Concurrent Programming 48
50 Can Protocol Idea Cans on Alice s windowsill Strings lead to Bob s house Bob pulls strings, knocks over cans Gotcha Cans cannot be reused Bob runs out of cans Introduction to Concurrent Programming 49
51 Interpretation Cannot solve mutual exclusion with interrupts Sender sets fixed bit in receiver s space Receiver resets bit when ready Requires unbounded number of interrupt bits Introduction to Concurrent Programming 50
52 Flag Protocol A B Introduction to Concurrent Programming 51
53 Alice s Protocol (sort of) A B Introduction to Concurrent Programming 52
54 Bob s Protocol (sort of) A B Introduction to Concurrent Programming 53
55 Alice s Protocol Raise flag Wait until Bob s flag is down Unleash pet Lower flag when pet returns Introduction to Concurrent Programming 54
56 Bob s Protocol Raise flag Wait until Alice s flag is down Unleash pet Lower flag when pet returns danger! Introduction to Concurrent Programming 55
57 Bob s Protocol (2 nd try) Bob defers Raise flag to Alice While Alice s flag is up Lower flag Wait for Alice s flag to go down Raise flag Unleash pet Lower flag when pet returns Introduction to Concurrent Programming 56
58 The Flag Principle Raise the flag Look at other s flag Flag Principle: If each raises and looks, then Last to look must see both flags up Introduction to Concurrent Programming 57
59 Proof of Mutual Exclusion Assume both pets in pond Derive a contradiction By reasoning backwards Consider the last time Alice and Bob each looked before letting the pets in Without loss of generality assume Alice was the last to look Introduction to Concurrent Programming 58
60 Proof Bob last raised flag Alice last raised her flag Alice s last look Bob s last looked time QED Alice must have Introduction seen to Concurrent Bob s Programming flag. A contradiction 59
61 Proof of No Deadlock If only one pet wants in, it gets in. Deadlock requires both continually trying to get in. If Bob sees Alice s flag, he gives her priority (a gentleman ) QED Introduction to Concurrent Programming 60
62 Remarks Protocol is unfair Bob s pet might never get in Protocol uses waiting If Bob is eaten by his pet, Alice s pet might never get in Introduction to Concurrent Programming 61
63 Moral of Story Mutual Exclusion cannot be solved by transient communication (mobile phones) interrupts (cans) It can be solved by one-bit shared variables that can be read or written Introduction to Concurrent Programming 62
64 The Arbiter Problem (an aside) Pick a point Pick a point Introduction to Concurrent Programming 63
65 The Fable Continues Alice and Bob fall in love & marry Then they fall out of love & divorce She gets the pets (who now get along fine with each other) He has to feed them Leading to a new coordination problem: Producer-Consumer Introduction to Concurrent Programming 64
66 Bob Puts Food in the Pond A Introduction to Concurrent Programming 65
67 Alice releases her pets to Feed mmm mmm B Introduction to Concurrent Programming 66
68 Producer/Consumer Alice and Bob can t meet Each has restraining order on other So he puts food in the pond And later, she releases the pets Avoid Releasing pets when there s no food Putting out food if uneaten food remains Introduction to Concurrent Programming 67
69 Producer/Consumer Need a mechanism so that Bob lets Alice know when food has been put out Alice lets Bob know when to put out more food Introduction to Concurrent Programming 68
70 Surprise Solution A B cola Introduction to Concurrent Programming 69
71 Bob puts food in Pond A B cola Introduction to Concurrent Programming 70
72 Bob knocks over Can A B cola Introduction to Concurrent Programming 71
73 Alice Releases Pets A yum yum B cola Introduction to Concurrent Programming 72
74 Alice Resets Can when Pets are Fed A B cola Introduction to Concurrent Programming 73
75 Pseudocode while (true) { while (can.isup()){}; pet.release(); Bob s code pet.recapture(); can.reset(); } while (true) { while (can.isdown()){}; pond.stockwithfood(); can.knockover(); } Alice s code Introduction to Concurrent Programming 74
76 Correctness Mutual Exclusion Pets and Bob never together in pond No Starvation safety liveness if Bob always willing to feed, and pets always famished, then pets eat infinitely often. Producer/Consumer The pets never enter pond unless there is food, and Bob never provides food if there is unconsumed food. safety Introduction to Concurrent Programming 75
77 Could Also Solve Using Flags A B Introduction to Concurrent Programming 76
78 Waiting Both solutions use waiting while(mumble){} Waiting is problematic If one participant is delayed So is everyone else But delays are common & unpredictable Introduction to Concurrent Programming 77
79 The Fable drags on Bob and Alice still have issues But they need to communicate So they agree to use billboards Introduction to Concurrent Programming 78
80 Billboards are Large B A 3 C 1 3 D 2 E 1 Letter Tiles From Scrabble box Introduction to Concurrent Programming 79
81 Write One Letter at a Time W 4 A 1 S 1 H4 A 1 B 3 C 3 D 2 E 1 Introduction to Concurrent Programming 80
82 To post a message W A S H T H E C A R whe w Introduction to Concurrent Programming 81
83 Let s send another message L S E L L L A V A 1 A M P3 3 S 1 Introduction to Concurrent Programming 82
84 Uh-Oh S 1 E 1 L 1 L 1 T 1 H 4 E 1 C A R L 1 OK Introduction to Concurrent Programming 83
85 Readers/Writers Devise a protocol so that Writer writes one letter at a time Reader reads one letter at a time Reader sees Old message or new message No mixed messages Introduction to Concurrent Programming 84
86 Readers/Writers (cont d) Easy with mutual exclusion But mutual exclusion requires waiting One waits for the other Everyone executes sequentially Remarkably We can solve R/W without mutual exclusion Introduction to Concurrent Programming 85
87 Why do we care? We want as much of the code as possible to execute concurrently (in parallel) A larger sequential part implies reduced performance Amdahl s law: this relation is not linear Introduction to Concurrent Programming 86
88 Amdahl s Law Speedup = OldExecutionTime NewExecutionTime of computation given n CPUs instead of 1 Introduction to Concurrent Programming 87
89 Amdahl s Law Sequential fraction Speedup = Number of processors 1 1 p + p n Parallel fraction Introduction to Concurrent Programming 88
90 Example Ten processors 60% concurrent, 40% sequential How close to 10-fold speedup? Speedup=2.17= Introduction to Concurrent Programming 89
91 Example Ten processors 80% concurrent, 20% sequential How close to 10-fold speedup? Speedup=3.57= Introduction to Concurrent Programming 90
92 Example Ten processors 90% concurrent, 10% sequential How close to 10-fold speedup? Speedup=5.26= Introduction to Concurrent Programming 91
93 Example Ten processors 99% concurrent, 01% sequential How close to 10-fold speedup? Speedup=9.17= Introduction to Concurrent Programming 92
94 The Moral Making good use of our multiple processors (cores) means Finding ways to effectively parallelize our code Minimize sequential parts Reduce idle time: time in which threads wait without work Introduction to Concurrent Programming 93
95 Άδεια Χρήσης Το παρόν εκπαιδευτικό υλικό υπόκειται σε άδειες χρήσης Creative Commons. Για εκπαιδευτικό υλικό, όπως εικόνες, που υπόκειται σε άδεια χρήσης άλλου τύπου, αυτή πρέπει να αναφέρεται ρητώς.
Introduction to Concurrent Programming
Introduction to Concurrent Programming Based on the companion slides for the book The Art of Multiprocessor Programming by Maurice Herlihy & Nir Shavit, 2008 From the New York Times SAN FRANCISCO, 7 May
More informationIntroduction. Companion slides for The Art of Multiprocessor Programming by Maurice Herlihy & Nir Shavit
Introduction Companion slides for The Art of Multiprocessor Programming by Maurice Herlihy & Nir Shavit Moore s Law Transistor count still rising Clock speed flattening sharply Art of Multiprocessor Programming
More informationIntroduction. Companion slides for The Art of Multiprocessor Programming by Maurice Herlihy & Nir Shavit. Art of Multiprocessor Programming
Introduction Companion slides for The Art of Multiprocessor Programming by Maurice Herlihy & Nir Shavit Art of Multiprocessor Programming Moore s Law Transistor count still rising Clock speed flattening
More informationProgramming Paradigms for Concurrency Introduction
Programming Paradigms for Concurrency Introduction Based on companion slides for The Art of Multiprocessor Programming by Maurice Herlihy & Nir Shavit Modified by Thomas Wies New York University Moore
More informationCOMP 322: Principles of Parallel Programming Lecture 11: Parallel Programming Issues (Chapter 6) Fall 2009
COMP 322: Principles of Parallel Programming Lecture 11: Parallel Programming Issues (Chapter 6) Fall 2009 Vivek Sarkar Department of Computer Science Rice University vsarkar@rice.edu COMP 322 Lecture
More informationIntroduction to Multiprocessor Synchronization
Introduction to Multiprocessor Synchronization Maurice Herlihy http://cs.brown.edu/courses/cs176/lectures.shtml Moore's Law Transistor count still rising Clock speed flattening sharply Art of Multiprocessor
More informationIntroduction. Companion slides for The Art of Multiprocessor Programming by Maurice Herlihy & Nir Shavit
Introduction Companion slides for The by Maurice Herlihy & Nir Shavit Moore s Law Transistor count still rising Clock speed flattening sharply 2 Moore s Law (in practice) 3 Nearly Extinct: the Uniprocesor
More informationIntroduction. Chapter 1
Chapter 1 Introduction Every year, processors get faster and cheaper: processor speeds double roughly every two years. This remarkable rate of improvement will probably continue for a while, but eventually,
More informationΥλοποίηση γλωσσών συναρτησιακού προγραμματισμού
Σχολή Ηλεκτρολόγων Μηχανικών και Μηχανικών Υπολογιστών Τομέας Τεχνολογίας Πληροφορικής και Υπολογιστών Εθνικό Μετσόβιο Πολυτεχνείο Γλώσσες Προγραμματισμού ΙΙ Διδάσκοντες: Νικόλαος Παπασπύρου, Κωστής Σαγώνας
More informationARM Compiler and assembly on QEMU
School of Electrical and Computer Engineering N.T.U.A. Embedded System Design Dimitrios Soudris ARM Compiler and assembly on QEMU Άδεια Χρήσης Το παρόν εκπαιδευτικό υλικό υπόκειται σε άδειες χρήσης Creative
More informationLecture 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 informationLocks Chapter 4. Overview. Introduction Spin Locks. Queue locks. Roger Wattenhofer. Test-and-Set & Test-and-Test-and-Set Backoff lock
Locks Chapter 4 Roger Wattenhofer ETH Zurich Distributed Computing www.disco.ethz.ch Overview Introduction Spin Locks Test-and-Set & Test-and-Test-and-Set Backoff lock Queue locks 4/2 1 Introduction: From
More informationIntroduction 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 informationSpin 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 informationLocking. Part 2, Chapter 11. Roger Wattenhofer. ETH Zurich Distributed Computing
Locking Part 2, Chapter 11 Roger Wattenhofer ETH Zurich Distributed Computing www.disco.ethz.ch Overview Introduction Spin Locks Test-and-Set & Test-and-Test-and-Set Backoff lock Queue locks 11/2 Introduction:
More informationSolution: 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 informationSpin 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 informationLinked 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 informationProgramming 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 informationMutual 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 informationSpin 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 informationChapter 5 Concurrency: Mutual Exclusion. and. Synchronization. Operating Systems: Internals. and. Design Principles
Operating Systems: Internals and Design Principles Chapter 5 Concurrency: Mutual Exclusion and Synchronization Seventh Edition By William Stallings Designing correct routines for controlling concurrent
More informationTHREADS & CONCURRENCY
27/04/2018 Sorry for the delay in getting slides for today 2 Another reason for the delay: Yesterday: 63 posts on the course Piazza yesterday. A7: If you received 100 for correctness (perhaps minus a late
More informationComputer Architecture
Jens Teubner Computer Architecture Summer 2016 1 Computer Architecture Jens Teubner, TU Dortmund jens.teubner@cs.tu-dortmund.de Summer 2016 Jens Teubner Computer Architecture Summer 2016 83 Part III Multi-Core
More informationAn Introduction to Parallel Programming
An Introduction to Parallel Programming Ing. Andrea Marongiu (a.marongiu@unibo.it) Includes slides from Multicore Programming Primer course at Massachusetts Institute of Technology (MIT) by Prof. SamanAmarasinghe
More informationMultiprocessors & Thread Level Parallelism
Multiprocessors & Thread Level Parallelism COE 403 Computer Architecture Prof. Muhamed Mudawar Computer Engineering Department King Fahd University of Petroleum and Minerals Presentation Outline Introduction
More informationOperating 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 informationChapter 5 Concurrency: Mutual Exclusion and Synchronization
Operating Systems: Internals and Design Principles Chapter 5 Concurrency: Mutual Exclusion and Synchronization Seventh Edition By William Stallings Designing correct routines for controlling concurrent
More informationMulti-core Architectures. Dr. Yingwu Zhu
Multi-core Architectures Dr. Yingwu Zhu What is parallel computing? Using multiple processors in parallel to solve problems more quickly than with a single processor Examples of parallel computing A cluster
More informationCMSC 330: Organization of Programming Languages. Threads Classic Concurrency Problems
: Organization of Programming Languages Threads Classic Concurrency Problems The Dining Philosophers Problem Philosophers either eat or think They must have two forks to eat Can only use forks on either
More informationConcurrent 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 informationThe Dining Philosophers Problem CMSC 330: Organization of Programming Languages
The Dining Philosophers Problem CMSC 0: Organization of Programming Languages Threads Classic Concurrency Problems Philosophers either eat or think They must have two forks to eat Can only use forks on
More informationSpin 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 informationCMSC 330: Organization of Programming Languages. The Dining Philosophers Problem
CMSC 330: Organization of Programming Languages Threads Classic Concurrency Problems The Dining Philosophers Problem Philosophers either eat or think They must have two forks to eat Can only use forks
More informationComputer and Information Sciences College / Computer Science Department CS 207 D. Computer Architecture. Lecture 9: Multiprocessors
Computer and Information Sciences College / Computer Science Department CS 207 D Computer Architecture Lecture 9: Multiprocessors Challenges of Parallel Processing First challenge is % of program inherently
More informationProgramming 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 informationConcurrent 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 informationChapter 5: Thread-Level Parallelism Part 1
Chapter 5: Thread-Level Parallelism Part 1 Introduction What is a parallel or multiprocessor system? Why parallel architecture? Performance potential Flynn classification Communication models Architectures
More informationOnline Course Evaluation. What we will do in the last week?
Online Course Evaluation Please fill in the online form The link will expire on April 30 (next Monday) So far 10 students have filled in the online form Thank you if you completed it. 1 What we will do
More informationProcess Management And Synchronization
Process Management And Synchronization In a single processor multiprogramming system the processor switches between the various jobs until to finish the execution of all jobs. These jobs will share the
More informationCS370 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 informationKernel Synchronization I. Changwoo Min
1 Kernel Synchronization I Changwoo Min 2 Summary of last lectures Tools: building, exploring, and debugging Linux kernel Core kernel infrastructure syscall, module, kernel data structures Process management
More informationDesign and Evaluation of Scalable Software
Design and Evaluation of Scalable Software Damian Dechev 1,2 1: University of Central Florida, CSE S3 Lab, http://cse.eecs.ucf.edu Orlando, FL 2: Sandia Labs, Livermore, CA Traditional Scaling Process
More informationCPSC/ECE 3220 Fall 2017 Exam Give the definition (note: not the roles) for an operating system as stated in the textbook. (2 pts.
CPSC/ECE 3220 Fall 2017 Exam 1 Name: 1. Give the definition (note: not the roles) for an operating system as stated in the textbook. (2 pts.) Referee / Illusionist / Glue. Circle only one of R, I, or G.
More informationLecture 13: Memory Consistency. + a Course-So-Far Review. Parallel Computer Architecture and Programming CMU , Spring 2013
Lecture 13: Memory Consistency + a Course-So-Far Review Parallel Computer Architecture and Programming Today: what you should know Understand the motivation for relaxed consistency models Understand the
More informationOther consistency models
Last time: Symmetric multiprocessing (SMP) Lecture 25: Synchronization primitives Computer Architecture and Systems Programming (252-0061-00) CPU 0 CPU 1 CPU 2 CPU 3 Timothy Roscoe Herbstsemester 2012
More informationSynchronization in Concurrent Programming. Amit Gupta
Synchronization in Concurrent Programming Amit Gupta Announcements Project 1 grades are out on blackboard. Detailed Grade sheets to be distributed after class. Project 2 grades should be out by next Thursday.
More informationCOL 380: Introduc1on to Parallel & Distributed Programming. Lecture 1 Course Overview + Introduc1on to Concurrency. Subodh Sharma
COL 380: Introduc1on to Parallel & Distributed Programming Lecture 1 Course Overview + Introduc1on to Concurrency Subodh Sharma Indian Ins1tute of Technology Delhi Credits Material derived from Peter Pacheco:
More informationPrinciples of Software Construction: Objects, Design, and Concurrency. The Perils of Concurrency Can't live with it. Cant live without it.
Principles of Software Construction: Objects, Design, and Concurrency The Perils of Concurrency Can't live with it. Cant live without it. Spring 2014 Charlie Garrod Christian Kästner School of Computer
More informationWhat 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 informationConcurrency Terminology
Lesson 1 Concurrency Ch 1 [BenA 06] Terminology Concurrency in Systems Problem Examples Solution Considerations 1 Concurrency Terminology Process, thread tavallinen ohjelma Ordinary program Sequential
More informationProgramming at Scale: Concurrency
Programming at Scale: Concurrency 1 Goal: Building Fast, Scalable Software How do we speed up software? 2 What is scalability? A system is scalable if it can easily adapt to increased (or reduced) demand
More informationCSE 392/CS 378: High-performance Computing - Principles and Practice
CSE 392/CS 378: High-performance Computing - Principles and Practice Parallel Computer Architectures A Conceptual Introduction for Software Developers Jim Browne browne@cs.utexas.edu Parallel Computer
More informationConcurrent Skip Lists. Companion slides for The Art of Multiprocessor Programming by Maurice Herlihy & Nir Shavit
Concurrent Skip Lists Companion slides for The by Maurice Herlihy & Nir Shavit Set Object Interface Collection of elements No duplicates Methods add() a new element remove() an element contains() if element
More informationParallel Processing: Performance Limits & Synchronization
Parallel Processing: Performance Limits & Synchronization Daniel Sanchez Computer Science & Artificial Intelligence Lab M.I.T. May 8, 2018 L22-1 Administrivia Quiz 3: Thursday 7:30-9:30pm, room 50-340
More informationOperating 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 information10/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 informationAgenda Process Concept Process Scheduling Operations on Processes Interprocess Communication 3.2
Lecture 3: Processes Agenda Process Concept Process Scheduling Operations on Processes Interprocess Communication 3.2 Process in General 3.3 Process Concept Process is an active program in execution; process
More informationThe Art of Parallel Processing
The Art of Parallel Processing Ahmad Siavashi April 2017 The Software Crisis As long as there were no machines, programming was no problem at all; when we had a few weak computers, programming became a
More informationMidterm Exam March 13, 2013 CS162 Operating Systems
University of California, Berkeley College of Engineering Computer Science Division EECS Spring 2013 Anthony D. Joseph Midterm Exam March 13, 2013 CS162 Operating Systems Your Name: SID AND 162 Login:
More informationParallel Algorithm Engineering
Parallel Algorithm Engineering Kenneth S. Bøgh PhD Fellow Based on slides by Darius Sidlauskas Outline Background Current multicore architectures UMA vs NUMA The openmp framework and numa control Examples
More informationCS 136: Advanced Architecture. Review of Caches
1 / 30 CS 136: Advanced Architecture Review of Caches 2 / 30 Why Caches? Introduction Basic goal: Size of cheapest memory... At speed of most expensive Locality makes it work Temporal locality: If you
More informationΕισαγωγή στον Προγραμματισμό Introduction to Programming
ΕΛΛΗΝΙΚΗ ΔΗΜΟΚΡΑΤΙΑ ΠΑΝΕΠΙΣΤΗΜΙΟ ΚΡΗΤΗΣ Εισαγωγή στον Προγραμματισμό Introduction to Programming Διάλεξη 9: Ροή Εισόδου/Εξόδου Γ. Παπαγιαννάκης Άδειες Χρήσης - Το παρόν εκπαιδευτικό υλικό υπόκειται στην
More informationTHREADS AND CONCURRENCY
THREADS AND CONCURRENCY Lecture 22 CS2110 Spring 2013 Graphs summary 2 Dijkstra: given a vertex v, finds shortest path from v to x for each vertex x in the graph Key idea: maintain a 5-part invariant on
More informationComputer Architecture Crash course
Computer Architecture Crash course Frédéric Haziza Department of Computer Systems Uppsala University Summer 2008 Conclusions The multicore era is already here cost of parallelism is dropping
More informationMulti-core Architectures. Dr. Yingwu Zhu
Multi-core Architectures Dr. Yingwu Zhu Outline Parallel computing? Multi-core architectures Memory hierarchy Vs. SMT Cache coherence What is parallel computing? Using multiple processors in parallel to
More informationLesson 1. Concurrency. Terminology Concurrency in Systems Problem Examples Copyright Teemu Kerola 2009
Lesson 1 Concurrency Ch1[B [BenA A06] Terminology Concurrency in Systems Problem Examples Solution Considerations 1 Concurrency Terminology Process, thread Ordinary program tavallinen ohjelma Sequential
More informationIT 540 Operating Systems ECE519 Advanced Operating Systems
IT 540 Operating Systems ECE519 Advanced Operating Systems Prof. Dr. Hasan Hüseyin BALIK (5 th Week) (Advanced) Operating Systems 5. Concurrency: Mutual Exclusion and Synchronization 5. Outline Principles
More informationLecture 10: Multi-Object Synchronization
CS 422/522 Design & Implementation of Operating Systems Lecture 10: Multi-Object Synchronization Zhong Shao Dept. of Computer Science Yale University Acknowledgement: some slides are taken from previous
More informationParallel Programming: Background Information
1 Parallel Programming: Background Information Mike Bailey mjb@cs.oregonstate.edu parallel.background.pptx Three Reasons to Study Parallel Programming 2 1. Increase performance: do more work in the same
More informationParallel Programming: Background Information
1 Parallel Programming: Background Information Mike Bailey mjb@cs.oregonstate.edu parallel.background.pptx Three Reasons to Study Parallel Programming 2 1. Increase performance: do more work in the same
More informationConcurrency: Mutual Exclusion and Synchronization
Concurrency: Mutual Exclusion and Synchronization 1 Needs of Processes Allocation of processor time Allocation and sharing resources Communication among processes Synchronization of multiple processes
More informationCSE Traditional Operating Systems deal with typical system software designed to be:
CSE 6431 Traditional Operating Systems deal with typical system software designed to be: general purpose running on single processor machines Advanced Operating Systems are designed for either a special
More informationSemaphores. Jinkyu Jeong Computer Systems Laboratory Sungkyunkwan University
Semaphores Jinkyu Jeong (jinkyu@skku.edu) Computer Systems Laboratory Sungkyunkwan University http://csl.skku.edu EEE3052: Introduction to Operating Systems, Fall 2017, Jinkyu Jeong (jinkyu@skku.edu) Synchronization
More informationIntroduction to Concurrency (Processes, Threads, Interrupts, etc.)
Introduction to Concurrency (Processes, Threads, Interrupts, etc.) CS-3013 Operating Systems Hugh C. Lauer (Slides include materials from Slides include materials from Modern Operating Systems, 3 rd ed.,
More informationCS377P Programming for Performance Multicore Performance Multithreading
CS377P Programming for Performance Multicore Performance Multithreading Sreepathi Pai UTCS October 14, 2015 Outline 1 Multiprocessor Systems 2 Programming Models for Multicore 3 Multithreading and POSIX
More informationCS 571 Operating Systems. Midterm Review. Angelos Stavrou, George Mason University
CS 571 Operating Systems Midterm Review Angelos Stavrou, George Mason University Class Midterm: Grading 2 Grading Midterm: 25% Theory Part 60% (1h 30m) Programming Part 40% (1h) Theory Part (Closed Books):
More information1. Introduction to Concurrent Programming
1. Introduction to Concurrent Programming A concurrent program contains two or more threads that execute concurrently and work together to perform some task. When a program is executed, the operating system
More informationIssues in Parallel Processing. Lecture for CPSC 5155 Edward Bosworth, Ph.D. Computer Science Department Columbus State University
Issues in Parallel Processing Lecture for CPSC 5155 Edward Bosworth, Ph.D. Computer Science Department Columbus State University Introduction Goal: connecting multiple computers to get higher performance
More informationChapter 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 informationThreads and Parallelism in Java
Threads and Parallelism in Java Java is one of the few main stream programming languages to explicitly provide for user-programmed parallelism in the form of threads. A Java programmer may organize a program
More informationAdvanced Topic: Efficient Synchronization
Advanced Topic: Efficient Synchronization Multi-Object Programs What happens when we try to synchronize across multiple objects in a large program? Each object with its own lock, condition variables Is
More informationCMSC Computer Architecture Lecture 12: Multi-Core. Prof. Yanjing Li University of Chicago
CMSC 22200 Computer Architecture Lecture 12: Multi-Core Prof. Yanjing Li University of Chicago Administrative Stuff! Lab 4 " Due: 11:49pm, Saturday " Two late days with penalty! Exam I " Grades out on
More informationLecture notes for CS Chapter 4 11/27/18
Chapter 5: Thread-Level arallelism art 1 Introduction What is a parallel or multiprocessor system? Why parallel architecture? erformance potential Flynn classification Communication models Architectures
More informationCS370 Operating Systems Midterm Review
CS370 Operating Systems Midterm Review Yashwant K Malaiya Fall 2015 Slides based on Text by Silberschatz, Galvin, Gagne 1 1 What is an Operating System? An OS is a program that acts an intermediary between
More informationSharing Objects Ch. 3
Sharing Objects Ch. 3 Visibility What is the source of the issue? Volatile Dekker s algorithm Publication and Escape Thread Confinement Immutability Techniques of safe publication Assignment 1 Visibility
More informationChapter 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 informationChapter 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 informationExploring different level of parallelism Instruction-level parallelism (ILP): how many of the operations/instructions in a computer program can be performed simultaneously 1. e = a + b 2. f = c + d 3.
More informationCache Coherence and Atomic Operations in Hardware
Cache Coherence and Atomic Operations in Hardware Previously, we introduced multi-core parallelism. Today we ll look at 2 things: 1. Cache coherence 2. Instruction support for synchronization. And some
More informationCopyright 2010, Elsevier Inc. All rights Reserved
An Introduction to Parallel Programming Peter Pacheco Chapter 1 Why Parallel Computing? 1 Roadmap Why we need ever-increasing performance. Why we re building parallel systems. Why we need to write parallel
More informationConcurrent Preliminaries
Concurrent Preliminaries Sagi Katorza Tel Aviv University 09/12/2014 1 Outline Hardware infrastructure Hardware primitives Mutual exclusion Work sharing and termination detection Concurrent data structures
More informationAgenda. 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 informationTHREADS & CONCURRENCY
4/26/16 Announcements BRING YOUR CORNELL ID TO THE PRELIM. 2 You need it to get in THREADS & CONCURRENCY Prelim 2 is next Tonight BRING YOUR CORNELL ID! A7 is due Thursday. Our Heap.java: on Piazza (A7
More informationSPIN, 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 informationWhatever can go wrong will go wrong. attributed to Edward A. Murphy. Murphy was an optimist. authors of lock-free programs LOCK FREE KERNEL
Whatever can go wrong will go wrong. attributed to Edward A. Murphy Murphy was an optimist. authors of lock-free programs LOCK FREE KERNEL 251 Literature Maurice Herlihy and Nir Shavit. The Art of Multiprocessor
More informationWeek 7. Concurrent Programming: Thread Synchronization. CS 180 Sunil Prabhakar Department of Computer Science Purdue University
Week 7 Concurrent Programming: Thread Synchronization CS 180 Sunil Prabhakar Department of Computer Science Purdue University Announcements Exam 1 tonight 6:30 pm - 7:30 pm MTHW 210 2 Outcomes Understand
More informationNow we are going to speak about the CPU, the Central Processing Unit.
Now we are going to speak about the CPU, the Central Processing Unit. The central processing unit or CPU is the component that executes the instructions of the program that is stored in the computer s
More informationCoherence and Consistency
Coherence and Consistency 30 The Meaning of Programs An ISA is a programming language To be useful, programs written in it must have meaning or semantics Any sequence of instructions must have a meaning.
More informationLecture 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