Blocking Non-blocking Caveat:
|
|
- Dayna Goodwin
- 6 years ago
- Views:
Transcription
1 Overview of Lecture 5 1 Progress Properties 2 Blocking The Art of Multiprocessor Programming. Maurice Herlihy and Nir Shavit. Morgan Kaufmann, Deadlock-free: some thread trying to get the lock eventually succeeds. Starvation-free: every thread trying to get the lock eventually succeeds. Lock-Based Data Structures The Problem with Locking Non-blocking Lock-free: some thread calling a method eventually returns. Wait-free: every thread calling a method eventually returns. Scalability & Measuring It Wait-Free Data Structures Lock-Free Data Structures Chapter 8 Section 1.5 Chapter 10 Lock- and wait-freeness disallow blocking methods like locks. They guarantee that the system can cope with crash-failures. Picking a progress property for a given application again depends on its needs. Wait-Free FIFO Queue (1) 3 Wait-Free FIFO Queue (2) 4 TAMP Fig. 3.3 (p.48), without exceptions Single Enqueuer/Single Dequeuer TAMP Fig. 3.3 (p.48), without exceptions class WaitFreeQueue<T> volatile int head = 0, tail = 0; T[] items; public void enq(t x) while (tail - head == items.length) /* spin */ public WaitFreeQueue(int capacity) items = (T[])new Object[capacity]; Identical to Lock-Based Queue, but without locks or synchronized! items[tail % items.length] = x; tail++; Why is spinning here not fatal? public void enq(t x) public T deq() Caveat: Single Enqueuer/Single Dequeuer! public T deq() while (tail == head) /* spin */ T x = items[head % items.length]; head++; return x; Why does it work without locks?
2 SE/SD Wait-Free FIFO Queue 5 Linearizability 6 Intuitively, this algorithm is correct for the following reasons: Only the enqueuer writes to tail and items[ ], and only the dequeuer writes to head. The condition while (tail - head == capacity) stops the enqueuer from overwriting an element in the queue before the dequeuer has read it. head is volatile, and the dequeuer only increases head after it read items[head % capacity] The condition while (tail == head) stops the dequeuer from reading an element in the queue before the enqueuer has placed it in the queue. Here it is used that tail is volatile, and the enqueuer only increases tail after it wrote to items[tail % capacity]. Principle (TAMP) Each method call should appear to take effect instantaneously at some moment between its invocation and return. Real-time behavior of method calls must be preserved. Object is linearizable, if all its possible executions are linearizable. SE/SD WF FIFO is Linearizable 7 Java AtomicReference 8 public void enq(t x) while (tail - head == items.length); items[tail % items.length] = x; tail++; public T deq() while (tail == head); T x = items[head % items.length]; return x; head++; As the linearization point of the enqueuer, for any execution, we can take tail++. As the linearization point of the dequeuer, for any execution, we can take head++. Then any execution of this queue is linearizable. On the hardware level, before a read or write operation is performed, first the bus (between processors and memory) must be locked. A read-modify-write operation consists of a read followed by a write, where in the meantime the lock on the bus is maintained. The write value may be determined using the value returned by the read. In Java, some standard read-modify-write registers are: getandset(v): assign v, and return the prior value. compareandset(e,u): if the prior value is e, then replace it by u, else leave it unchanged; return a boolean to indicate whether the value was changed. (get(): returns current value)
3 Lock-Free Stack 9 Lock-Free Stack 10 Treiber s Lock-Free Stack public class LockFreeStack<T> AtomicReference<Node<T>> head = new AtomicReference<Node<T>>(); public void push(t item) public T pop() static class Node<T> final T item; Node<T> next; public Node(T item) this.item = item; Treiber s Lock-Free Stack public void push(t item) Node<T> newhead = new Node<T>(item); Node<T> oldhead; do oldhead = head.get(); newhead.next = oldhead; while (!head.compareandset(oldhead, newhead)); public T pop() Node<T> oldhead; Node<T> newhead; do oldhead = head.get(); if (oldhead == null) return null; newhead = oldhead.next; while (!head.compareandset(oldhead, newhead)); return oldhead.item; Why does it work? Linearization Points? Best-known low-load method, but scales poorly due to contention and inherent sequential bottleneck Better: Elimination Backoff Stack [TAMP Sec. 11.4, p.249] Free List: An Optimization 11 Invoking the ABA Problem 12 Suppose stack prefix is A B S Observation: Lots of Nodes created and thrown away (Allocation overhead) Solution: Reuse them, e.g., with a free list: When popped, put Node on free list On push, take Node from free list Only allocate fresh Node, when free list empty Thread 1 about to CAS head from Node A to B in pop() Thread 2 pops Nodes A and B, and puts them on free list Stack now S Thread 2 pushes A: stack now A S head has changed back to A! (That can t be good ) Thread 1 wakes up and head.cas(a,b) succeeds stack now B S, but B is already on free list! General Problem of CAS; Needs care when reusing values!
4 Overview of Lecture 5 13 Concurrent and Distributed Programming The Art of Multiprocessor Programming. Maurice Herlihy and Nir Shavit. Morgan Kaufmann, Lock-Based Data Structures Concurrent Programming The Problem with Locking HC 6 - Wednesday 21 December 2011 Scalability & Measuring It Wait-Free Data Structures Chapter 8 Section 1.5 Chapter 10 Lock-Free Data Structures CDP #6 Overview of Lecture 6 The Art of Multiprocessor Programming. Maurice Herlihy and Nir Shavit. Morgan Kaufmann, Java AtomicReference 16 On the hardware level, before a read or write operation is performed, first the bus (between processors and memory) must be locked. A read-modify-write operation consists of a read followed by a write, where in the meantime the lock on the bus is maintained. The write value may be determined using the value returned by the read. Patterns in Lock-Free Data Structures (Chapter 10) Alternatives to Lock-Based/Lock-Free Concurrency In Java, some standard read-modify-write registers are: getandset(v): assign v, and return the prior value. compareandset(e,u): if the prior value is e, then replace it by u, else leave it unchanged; return a boolean to indicate whether the value was changed. Channels (get(): returns current value)
5 Unbounded Locked Queue (1) 17 Unbounded Locked Queue (2) 18 TAMP Sec (p.229) class UnboundedQueue<T> final Lock enqlock = new ReentrantLock(); final Lock deqlock = new ReentrantLock(); final Condition notempty = deqlock.newcondition(); Node<T> head, tail; public UnboundedQueue() head = tail = new Node<T>(null); public void enq(t x) public T deq() Sentinel Linearization Points public void enq(t x) enqlock.lock(); try Node<T> e = new Node<T>(x); tail.next = e; tail = e; notempty.signal(); finally enqlock.unlock(); TAMP Fig & 10.8 (p.229), with modifications public T deq() deqlock.lock(); try while (head.next == null) notempty.await(); T result = head.next.value; head = head.next; return result; finally deqlock.unlock(); Independent locks: Enqueuer works on tail, Dequeuer works on head R/W Data Race, Solutions? Unbounded Lock-Free Queue (1) 19 Unbounded LF Queue: Example 20 TAMP Fig (p.230), with modifications class Node<T> public final T value; public AtomicReference<Node<T>> next; public Node(T value) this.value = value; next = new AtomicReference<Node<T>>(); class LockFreeQueue<T> AtomicReference<Node<T>> head, tail; Sentinel public LockFreeQueue() Node<T> n = new Node<T>(null); head = tail = new AtomicReference<Node<T>>(n); public void enq(t x) public T deq() enq() (1) append node (2) update tail deq() (1) read value head.next (2) update head
6 Unbounded Lock-Free Queue (2) 21 Unbounded Lock-Free Queue (3) 22 TAMP Fig (p.230) public void enq(t x) Node<T> node = new Node<T>(x); while (true) Node<T> last = tail.get(); Node<T> next = last.next.get(); if (last == tail.get()) if (next == null) if (last.next.compareandset(next, node)) tail.compareandset(last, node); return; else tail.compareandset(last, next); locate last node validate value of next check if really last append new node update tail help advance lagging tail Linearization Point locate last/append/tail update not atomic: other threads must help completing half-finished enq() calls TAMP Fig (p.231) public T deq() while (true) Node<T> first = head.get(); Node<T> last = tail.get(); Node<T> next = first.next.get(); if (first == head.get()) if (first == last) if (next == null) return null; tail.compareandset(last, next); else T value = next.value; if (head.compareandset(first, next)) return value; consistency check, as before check if queue not empty advance lagging tail try again if another thread snatched value As before: deq() must also help with half-finished enq() call Channels 23 Channels (1) 24 So far, concurrent programming constructs used shared memory. We now look at communications, in which processes send and receive messages to and from each other. Models for communications synchronous: exchange of a message is an atomic action asynchronous: messages are buffered through a (finite) buffer usually implemented in software adressing: (a)symmetric data flow: one way, duplex Channels were introduced by C.A.R. Hoare in CSP [1985].
7 Channels (2) 25 Channels in Promela (1) 26 Channel connects a sending and a receiving process is typed: the type of messages that are send have to be declared Alg. 6.8 (p. 119) finite queue of datatype buffer empty queue semaphore notempty (0, ) semaphore notfull (N, ) producer datatype d loop forever p1: d produce p2: wait(notfull) p3: append(d,buffer) p4: signal(notempty) consumer With channels this can be much shorter. datatype d loop forever q1: wait(notempty) q2: d take(buffer) q3: signal(notfull) q4: consume(d) Only integers can be sent over channel ch producer integer x loop forever p1: x produce p2: ch x channel of integer ch Alg. 8.1 (p. 182) consumer integer y loop forever q1: ch y q2: consume(y) ch x sending a message to ch ch x receiving a message from ch Communication between Promela processes is via channels: asynchronous (buffered) synchronous (handshake / rendez-vous) Both are defined as chan variables: chan name = [cap] of t1, t2,..., tn; name of the channel examples capacity of the channel: cap 0 cap = 0 is special case: rendez-vous chan ch = [1] of bit; chan tor = [2] of mtype, bit; chan line[2] = [1] of mtype, Msg; array of channels Promela channels are typed! type of the elements that will be transmitted over the channel Channels in Promela (2)! sending - putting a message in a channel ch! expr1, expr2,..., exprn; A send statement is executable if the channel is not full. The types of expri should correspond with the types ti of the channel declaration.? receiving - getting a message out of a channel A receive statement is executable if the channel is not empty. message passing If the channel is not empty, the message is fetched from the channel and the individual elements of the message are stored in the vari s. message testing ch? var1, var2,..., varn; If the channel is not empty and the message at front of the channel evaluates to the individual consti values, the statement is executable and the message is removed from the channel. >0 27 chan name = [cap] of t1, t2,..., tn; ch? const1, const2,..., constn; Promela supports some exotic variations: sorted send and random receive. vari and consti can be mixed, of course. Channels in Promela (3) Rendez-vous communication capacity = 0 the number of elements in the buffer is now zero A synchronous rendez-vous communication is executable, if i) a sending ch! is enabled, and ii) there is a corresponding receiving ch? in some other process that is ready to be executed, and iii) the sending expressions match the receiving constants If a rendez-vous is executable, both statements will handshake and execute the rendez-vous together in a single transition. Beware of atomic constructs: if the send operation is in an atomic sequence, its atomicity will be lost (but may be transferred to the receiver). 28 chan name = [0] of t1, t2,..., tn; If the sender is ready to send, but the receiver is not ready to receive, the sender is blocked. Similarly, if the receiver is ready to receive before the sender is ready to send, the receiver is blocked. The rendez-vous communication is the only construct in Promela where two processes perform statements at the same time (more or less).
8 Alternating Bit Protocol 29 Dining Philosophers 30 Alternating Bit Protocol: To every message, the sender adds a bit. The receiver acknowledges each message by sending the received bit back. To receiver only accepts messages with a bit that it expected to receive. If the sender is sure that the receiver has correctly received the previous message, it sends a new message and it alternates the accompanying bit. mtype MSG, ACK; chan s2r = [2] of mtype, bit; chan r2s = [2] of mtype, bit; proctype Sender(chan in, out) bit sendbit, recvbit; do :: out! MSG, sendbit -> in? ACK, recvbit; if :: recvbit == sendbit -> sendbit = 1-sendbit :: else fi od proctype Receiver(chan in, out) bit recvbit; do :: in? MSG(recvbit) -> out! ACK(recvbit); od init run Sender(r2s, s2r); run Receiver(s2r, r2s); ch! MSG, par1, ch! MSG(par1, ) ch? MSG, par1, ch? MSG(par1, ) In this simple model we assume perfect lines: no messages are lost. byte n; chan forks[4] = [0] of bool ; proctype Phil(byte id; chan left; chan right) do :: left? _; right? _; n++; printf("phil %d eating, total = %d\n", id, n); n--; right! true; left! true; od proctype Fork(chan ch) do :: ch! true; ch? _; od write-only variable: we are not interested in the actual value: only in the synchronization init atomic run Fork(forks[0]); run Fork(forks[1]); run Fork(forks[2]); run Fork(forks[3]); run Phil(0, forks[0], forks[1]); run Phil(1, forks[1], forks[2]); run Phil(2, forks[2], forks[3]); run Phil(3, forks[3], forks[0]); Lecture 6: Concurrent Programming Lecture 6: Concurrent Programming Overview of Lecture 6 31 The Art of Multiprocessor Programming. Maurice Herlihy and Nir Shavit. Morgan Kaufmann, Patterns in Lock-Free Data Structures (Chapter 10) Alternatives to Lock-Based/Lock-Free Concurrency Channels
CSE 613: Parallel Programming. Lecture 17 ( Concurrent Data Structures: Queues and Stacks )
CSE 613: Parallel Programming Lecture 17 ( Concurrent Data Structures: Queues and Stacks ) Rezaul A. Chowdhury Department of Computer Science SUNY Stony Brook Spring 2012 Desirable Properties of Concurrent
More informationConcurrent Queues, Monitors, and the ABA problem. Companion slides for The Art of Multiprocessor Programming by Maurice Herlihy & Nir Shavit
Concurrent Queues, Monitors, and the ABA problem Companion slides for The Art of Multiprocessor Programming by Maurice Herlihy & Nir Shavit Queues Often used as buffers between producers and consumers
More informationCS477 Formal Software Development Methods / 32
CS477 Formal Software Development Methods 2112 SC, UIUC egunter@illinois.edu http://courses.engr.illinois.edu/cs477 SPIN Beginners Tutorial April 13, 2018 Assertion Violation: mutextwrong1.pml bit flag;
More informationProgramming Language Seminar Concurrency 2: Lock-free algorithms
Programming Language Seminar Concurrency 2: Lock-free algorithms Peter Sestoft Friday 2013-11-01 1 Outline for today Compare-and-swap instruction Atomic test-then-set operation Implemented directly in
More informationCS477 Formal Software Development Methods / 39
CS477 Formal Software Development Methods 2112 SC, UIUC egunter@illinois.edu http://courses.engr.illinois.edu/cs477 SPIN Beginners Tutorial April 11, 2018 Hello World /* A "Hello World" Promela model for
More informationConcurrent Queues and Stacks. Companion slides for The Art of Multiprocessor Programming by Maurice Herlihy & Nir Shavit
Concurrent Queues and Stacks Companion slides for The Art of Multiprocessor Programming by Maurice Herlihy & Nir Shavit The Five-Fold Path Coarse-grained locking Fine-grained locking Optimistic synchronization
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 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 informationLecture 3 SPIN and Promela
Lecture 3 SPIN and Promela 1 What is SPIN(Simple Promela INterpreter) A tool for analyzing mels of concurrent systems Mels described in Promela Language with concurrent processes Communication via shared
More informationOverview 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 informationWhat is SPIN(Simple Promela Interpreter) Elements of Promela. Material About SPIN. Basic Variables and Types. Typical Structure of Promela Model
What is SPIN(Simple Promela Interpreter) Lecture XX SPIN and Promela A tool for analyzing mels of reactive systems Mels described in Promela Language with concurrent processes, Communication via channels,
More informationUnit 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 informationWhat is SPIN(Simple Promela Interpreter) Material About SPIN. Elements of Promela. Basic Variables and Types. Typical Structure of Promela Model
What is SPIN(Simple Promela Interpreter) Lecture 3 SPIN and Promela A tool for analyzing mels of reactive systems Mels described in Promela Language with concurrent processes, Communication via channels,
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 informationWhatever can go wrong will go wrong. attributed to Edward A. Murphy. Murphy was an optimist. authors of lock-free programs 3.
Whatever can go wrong will go wrong. attributed to Edward A. Murphy Murphy was an optimist. authors of lock-free programs 3. LOCK FREE KERNEL 309 Literature Maurice Herlihy and Nir Shavit. The Art of Multiprocessor
More informationNetwork Protocol Design and Evaluation
Network Protocol Design and Evaluation 05 - Validation, Part I Stefan Rührup Summer 2009 Overview In the last lectures: Specification of protocols and data/message formats In this chapter: Building a validation
More informationIntroduction 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 informationAdvances in Programming Languages
O T Y H Advances in Programming Languages APL5: Further language concurrency mechanisms David Aspinall (including slides by Ian Stark) School of Informatics The University of Edinburgh Tuesday 5th October
More informationDesign of Internet Protocols:
CSCI 234 Design of Internet Protocols: George Blankenship George Blankenship 1 Outline Verication and Validation History and motivation Spin Promela language Promela model George Blankenship 2 Verication
More informationHello World. Slides mostly a reproduction of Theo C. Ruys SPIN Beginners Tutorial April 23, Hello() print "Hello"
Hello World CS477 Formal Software Development Methods 11 SC, UIUC egunter@illinois.edu http://courses.engr.illinois.edu/cs477 inners April 3, 014 /* A "Hello World" Promela model for SPIN. */ active Hello()
More informationThe 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 informationSynchronization 1. Synchronization
Synchronization 1 Synchronization key concepts critical sections, mutual exclusion, test-and-set, spinlocks, blocking and blocking locks, semaphores, condition variables, deadlocks reading Three Easy Pieces:
More informationT Parallel and Distributed Systems (4 ECTS)
T 79.4301 Parallel and Distributed Systems (4 ECTS) T 79.4301 Rinnakkaiset ja hajautetut järjestelmät (4 op) Lecture 3 4th of February 2008 Keijo Heljanko Keijo.Heljanko@tkk.fi T 79.4301 Parallel and Distributed
More informationCONCURRENT LIBRARIES. Correctness Criteria, Verification
CONCURRENT LIBRARIES Correctness Criteria, Verification Verification Ingredients Specifying a Library: φ Implementing a Library: L Verifying a Library implementation: L φ The History of an Object Object
More informationCS 318 Principles of Operating Systems
CS 318 Principles of Operating Systems Fall 2017 Midterm Review Ryan Huang 10/12/17 CS 318 Midterm Review 2 Midterm October 17 th Tuesday 9:00-10:20 am at classroom Covers material before virtual memory
More informationCS510 Operating System Foundations. Jonathan Walpole
CS510 Operating System Foundations Jonathan Walpole Monitors 2 Programming Complexity There are many ways to introduce bugs using locks and semaphores - forget to lock somewhere in the program - forget
More informationCopyright 2008 CS655 System Modeling and Analysis. Korea Advanced Institute of Science and Technology
The Spin Model Checker : Part I Copyright 2008 CS655 System Korea Advanced Institute of Science and Technology System Spec. In Promela Req. Spec. In LTL Overview of the Spin Architecture Spin Model pan.c
More informationDesign and Analysis of Distributed Interacting Systems
Design and Analysis of Distributed Interacting Systems Lecture 5 Linear Temporal Logic (cont.) Prof. Dr. Joel Greenyer May 2, 2013 (Last Time:) LTL Semantics (Informally) LTL Formulae are interpreted on
More informationConcurrent 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 informationConcurrency. On multiprocessors, several threads can execute simultaneously, one on each processor.
Synchronization 1 Concurrency On multiprocessors, several threads can execute simultaneously, one on each processor. On uniprocessors, only one thread executes at a time. However, because of preemption
More informationCSE 153 Design of Operating Systems
CSE 153 Design of Operating Systems Winter 2018 Lecture 10: Monitors Monitors A monitor is a programming language construct that controls access to shared data Synchronization code added by compiler, enforced
More information4/6/2011. Model Checking. Encoding test specifications. Model Checking. Encoding test specifications. Model Checking CS 4271
Mel Checking LTL Property System Mel Mel Checking CS 4271 Mel Checking OR Abhik Roychoudhury http://www.comp.nus.edu.sg/~abhik Yes No, with Counter-example trace 2 Recap: Mel Checking for mel-based testing
More informationSemaphores. To avoid busy waiting: when a process has to wait, it will be put in a blocked queue of processes waiting for the same event
Semaphores Synchronization tool (provided by the OS) that do not require busy waiting A semaphore S is an integer variable that, apart from initialization, can only be accessed through 2 atomic and mutually
More informationSemaphores. Semaphores. Semaphore s operations. Semaphores: observations
Semaphores Synchronization tool (provided by the OS) that do not require busy waiting A semaphore S is an integer variable that, apart from initialization, can only be accessed through 2 atomic and mutually
More informationOperating Systems CMPSC 473. Synchronization February 26, Lecture 12 Instructor: Trent Jaeger
Operating Systems CMPSC 473 Synchronization February 26, 2008 - Lecture 12 Instructor: Trent Jaeger Last class: Synchronization Problems and Primitives Today: Synchonization Solutions Midterm (Both Sections)
More informationSynchronization 1. Synchronization
Synchronization 1 Synchronization key concepts critical sections, mutual exclusion, test-and-set, spinlocks, blocking and blocking locks, semaphores, condition variables, deadlocks reading Three Easy Pieces:
More informationPROCESS SYNCHRONIZATION
PROCESS SYNCHRONIZATION Process Synchronization Background The Critical-Section Problem Peterson s Solution Synchronization Hardware Semaphores Classic Problems of Synchronization Monitors Synchronization
More informationPromela and SPIN. Mads Dam Dept. Microelectronics and Information Technology Royal Institute of Technology, KTH. Promela and SPIN
Promela and SPIN Mads Dam Dept. Microelectronics and Information Technology Royal Institute of Technology, KTH Promela and SPIN Promela (Protocol Meta Language): Language for modelling discrete, event-driven
More informationThe Five-Fold Path. Queues & Stacks. Bounded vs Unbounded. Blocking vs Non-Blocking. Concurrent Queues and Stacks. Another Fundamental Problem
Concurrent Queues and Stacks The Five-Fold Path Coarse-grained locking Fine-grained locking Optimistic synchronization Lazy synchronization Lock-free synchronization 2 Another Fundamental Problem Queues
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 informationTemporal Logic of Actions (TLA) (a brief introduction) Shmuel Katz Computer Science Department The Technion
Temporal Logic of Actions (TLA) (a brief introduction) Shmuel Katz Computer Science Department The Technion CS236368 Formal Specifications Lecture-- TLA 1 Basic Idea Combine transitions with temporal logic
More informationComputer Aided Verification 2015 The SPIN model checker
Computer Aided Verification 2015 The SPIN model checker Grigory Fedyukovich Universita della Svizzera Italiana March 11, 2015 Material borrowed from Roberto Bruttomesso Outline 1 Introduction 2 PROcess
More informationAtomic Variables & Nonblocking Synchronization
Atomic Variables & Nonblocking Synchronization CMSC 433 Fall 2014 Michael Hicks (with some slides due to Rance Cleaveland) A Locking Counter public final class Counter { private long value = 0; public
More informationThere are 8 total numbered pages, 6 Questions. You have 60 minutes. Budget your time carefully!
UNIVERSITY OF TORONTO FACULTY OF APPLIED SCIENCE AND ENGINEERING MIDTERM EXAMINATION, March, 2017 Third Year Materials ECE344H1 - Operating Systems Calculator Type: 2 Exam Type: A Examiner D. Yuan Please
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 informationG52CON: Concepts of Concurrency Lecture 15: Message Passing. Gabriela Ochoa School of Computer Science & IT
G52CON: Concepts of Concurrency Lecture 15: Message Passing Gabriela Ochoa School of Computer Science & IT gxo@cs.nott.ac.uk Content Introduction and transition Recapitulation on hardware architectures
More informationA Tutorial on Model Checker SPIN
A Tutorial on Model Checker SPIN Instructor: Hao Zheng Department of Computer Science and Engineering University of South Florida Tampa, FL 33620 Email: haozheng@usf.edu Phone: (813)974-4757 Fax: (813)974-5456
More informationCS510 Concurrent Systems. Jonathan Walpole
CS510 Concurrent Systems Jonathan Walpole Simple, Fast, and Practical Non-Blocking and Blocking Concurrent Queue Algorithms utline Background Non-Blocking Queue Algorithm Two Lock Concurrent Queue Algorithm
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 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 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 informationSequen&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 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 informationUniversality of Consensus. Companion slides for The Art of Multiprocessor Programming by Maurice Herlihy & Nir Shavit
Universality of Consensus Companion slides for The by Maurice Herlihy & Nir Shavit Turing Computability 1 0 1 1 0 1 0 A mathematical model of computation Computable = Computable on a T-Machine 2 Shared-Memory
More informationInterprocess Communication By: Kaushik Vaghani
Interprocess Communication By: Kaushik Vaghani Background Race Condition: A situation where several processes access and manipulate the same data concurrently and the outcome of execution depends on the
More informationOutline of lecture. i219 Software Design Methodology 10. Multithreaded programming. Kazuhiro Ogata (JAIST)
i219 Software Design Methodology 10. Multithreaded programming Kazuhiro Ogata (JAIST) Outline of lecture 2 Thread Race condition Synchronization Deadlock Bounded buffer problem Thread (1) 3 Units of execution.
More informationNon-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 informationFine-grained synchronization & lock-free programming
Lecture 17: Fine-grained synchronization & lock-free programming Parallel Computer Architecture and Programming CMU 15-418/15-618, Spring 2016 Tunes Minnie the Moocher Robbie Williams (Swings Both Ways)
More informationNon-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 informationReminder from last time
Concurrent systems Lecture 3: CCR, monitors, and concurrency in practice DrRobert N. M. Watson 1 Reminder from last time Implementing mutual exclusion: hardware support for atomicity and inter-processor
More informationA Non-Blocking Concurrent Queue Algorithm
A Non-Blocking Concurrent Queue Algorithm Bruno Didot bruno.didot@epfl.ch June 2012 Abstract This report presents a new non-blocking concurrent FIFO queue backed by an unrolled linked list. Enqueue and
More informationMultithreaded Programming Part II. CSE 219 Stony Brook University, Department of Computer Science
Multithreaded Programming Part II CSE 219 Stony Brook University, Thread Scheduling In a Java application, main is a thread on its own Once multiple threads are made Runnable the thread scheduler of the
More informationConcurrency. On multiprocessors, several threads can execute simultaneously, one on each processor.
Synchronization 1 Concurrency On multiprocessors, several threads can execute simultaneously, one on each processor. On uniprocessors, only one thread executes at a time. However, because of preemption
More informationPractical Concurrent and Parallel Programming 10
Practical Concurrent and Parallel Programming 10 Peter Sestoft IT University of Copenhagen Friday 2016-11-11* IT University of Copenhagen 1 Plan for today Compare and swap (CAS) low-level atomicity Examples:
More informationQuasi-Linearizability Relaxed Consistency For Improved Concurrency
TEL-AVIV UNIVERSITY RAYMOND AND BEVERLY SACKLER FACULTY OF EXACT SCIENCES SCHOOL OF COMPUTER SCIENCE Quasi-Linearizability Relaxed Consistency For Improved Concurrency Dissertation submitted in partial
More informationMutual 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 informationThe Wait-Free Hierarchy
Jennifer L. Welch References 1 M. Herlihy, Wait-Free Synchronization, ACM TOPLAS, 13(1):124-149 (1991) M. Fischer, N. Lynch, and M. Paterson, Impossibility of Distributed Consensus with One Faulty Process,
More informationModelling Without a Modelling Language
Modelling Without a Modelling Language Antti Valmari & Vesa Lappalainen University of Jyväskylä 1 Introduction 2 Quick Comparison to Promela 3 Demand-Driven Token Ring 4 Simple Transition Classes 5 Faster
More informationMultitasking / Multithreading system Supports multiple tasks
Tasks and Intertask Communication Introduction Multitasking / Multithreading system Supports multiple tasks As we ve noted Important job in multitasking system Exchanging data between tasks Synchronizing
More informationClassic Problems of Synchronization
Classic Problems of Synchronization Bounded-Buffer Problem s-s Problem Dining Philosophers Problem Monitors 2/21/12 CSE325 - Synchronization 1 s-s Problem s s 2/21/12 CSE325 - Synchronization 2 Problem
More informationOwnership of a queue for practical lock-free scheduling
Ownership of a queue for practical lock-free scheduling Lincoln Quirk May 4, 2008 Abstract We consider the problem of scheduling tasks in a multiprocessor. Tasks cannot always be scheduled independently
More informationReview of last lecture. Goals of this lecture. DPHPC Overview. Lock-based queue. Lock-based queue
Review of last lecture Design of Parallel and High-Performance Computing Fall 2013 Lecture: Linearizability Instructor: Torsten Hoefler & Markus Püschel TA: Timo Schneider Cache-coherence is not enough!
More informationSpin: Overview of PROMELA
Spin: Overview of PROMELA Patrick Trentin patrick.trentin@unitn.it http://disi.unitn.it/trentin Formal Methods Lab Class, March 10, 2017 These slides are derived from those by Stefano Tonetta, Alberto
More informationFast and Lock-Free Concurrent Priority Queues for Multi-Thread Systems
Fast and Lock-Free Concurrent Priority Queues for Multi-Thread Systems Håkan Sundell Philippas Tsigas Outline Synchronization Methods Priority Queues Concurrent Priority Queues Lock-Free Algorithm: Problems
More informationConcurrency: Mutual Exclusion and
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 information10/27/11. Is The Queue Correct? Concurrent Computaton. Objects. A Concurrent FIFO Queue head. A Concurrent FIFO Queue head
DD2451 Parallel and Distributed Computing --- FDD3008 Distributed Algorithms Lecture 2 Concurrent Objects memory Concurrent Computaton Mads Dam Autumn/Winter 2011 object object Art of Mul/processor 2 Objects
More informationModern High-Performance Locking
Modern High-Performance Locking Nir Shavit Slides based in part on The Art of Multiprocessor Programming by Maurice Herlihy & Nir Shavit Locks (Mutual Exclusion) public interface Lock { public void lock();
More informationSynchronization Principles II
CSC 256/456: Operating Systems Synchronization Principles II John Criswell University of Rochester 1 Synchronization Issues Race conditions and the need for synchronization Critical Section Problem Mutual
More informationG52CON: 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 informationMulti-Threaded System int x, y, r; int *p, *q, *z; int **a; EEC 421/521: Software Engineering. Thread Interleaving SPIN. Model Checking using SPIN
EEC 421/521: Software Engineering Model Checking using SPIN 4/29/08 EEC 421/521: Software Engineering 1 Multi-Threaded System int x, y, r; int *p, *q, *z; int **a; thread_1(void) /* initialize p, q, and
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 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 informationSWEN-220 Mathematical Models of Software. Concurrency in SPIN Interleaving
SWEN-220 Mathematical Models of Software Concurrency in SPIN Interleaving 1 Topics Interleaving Process Interference Race Conditions Atomicity 2 Concurrency Concurrency can come in many flavors Concurrent
More informationConcurrency. 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 informationContribution:javaMultithreading Multithreading Prof. Dr. Ralf Lämmel Universität Koblenz-Landau Software Languages Team
http://101companies.org/wiki/ Contribution:javaMultithreading Multithreading Prof. Dr. Ralf Lämmel Universität Koblenz-Landau Software Languages Team Non-101samples available here: https://github.com/101companies/101repo/tree/master/technologies/java_platform/samples/javathreadssamples
More informationSoftware Engineering using Formal Methods
Software Engineering using Formal Methods Introduction to Promela Wolfgang Ahrendt 03 September 2015 SEFM: Promela /GU 150903 1 / 36 Towards Model Checking System Model Promela Program byte n = 0; active
More informationCSE 120 Principles of Operating Systems Spring 2016
CSE 120 Principles of Operating Systems Spring 2016 Condition Variables and Monitors Monitors A monitor is a programming language construct that controls access to shared data Synchronization code added
More informationThe Spin Model Checker : Part I. Moonzoo Kim KAIST
The Spin Model Checker : Part I Moonzoo Kim KAIST Hierarchy of SW Coverage Criteria Complete Value Coverage CVC (SW) Model checking Complete Path Coverage CPC Concolic testing All-DU-Paths Coverage ADUP
More informationSummary Semaphores. Passing the Baton any await statement. Synchronisation code not linked to the data
Lecture 4 Monitors Summary Semaphores Good news Simple, efficient, expressive Passing the Baton any await statement Bad news Low level, unstructured omit a V: deadlock omit a P: failure of mutex Synchronisation
More informationThreads. Concurrency. What it is. Lecture Notes Week 2. Figure 1: Multi-Threading. Figure 2: Multi-Threading
Threads Figure 1: Multi-Threading Figure 2: Multi-Threading Concurrency What it is 1. Two or more threads of control access a shared resource. Scheduler operation must be taken into account fetch-decode-execute-check
More informationLecture 3: Intro to Concurrent Processing using Semaphores
Lecture 3: Intro to Concurrent Processing using Semaphores Semaphores; The Prucer-Consumer problem; The Dining Philosophers problem; The Readers-Writers Problem: Readers Preference Passing the Baton Ballhausen
More informationLecture 6. Introduction to Message Passing
Lecture 6 Introduction to Message Passing Message Passing Introduction to message passing JR s message passing model Operations Asynchronous message passing Synchronous message passing 2 Shared Variables?
More informationDD2451 Parallel and Distributed Computing --- FDD3008 Distributed Algorithms
DD2451 Parallel and Distributed Computing --- FDD3008 Distributed Algorithms Lecture 2 Concurrent Objects Mads Dam Autumn/Winter 2011 Concurrent Computaton memory object object Art of Mul*processor 2 Objects
More informationChapter 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 informationFormal Specification and Verification
Formal Specification and Verification Introduction to Promela Bernhard Beckert Based on a lecture by Wolfgang Ahrendt and Reiner Hähnle at Chalmers University, Göteborg Formal Specification and Verification:
More informationCHAPTER 6: PROCESS SYNCHRONIZATION
CHAPTER 6: PROCESS SYNCHRONIZATION The slides do not contain all the information and cannot be treated as a study material for Operating System. Please refer the text book for exams. TOPICS Background
More informationOperating Systems. Lecture 4 - Concurrency and Synchronization. Master of Computer Science PUF - Hồ Chí Minh 2016/2017
Operating Systems Lecture 4 - Concurrency and Synchronization Adrien Krähenbühl Master of Computer Science PUF - Hồ Chí Minh 2016/2017 Mutual exclusion Hardware solutions Semaphores IPC: Message passing
More informationProcess 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 informationDr. Rafiq Zakaria Campus. Maulana Azad College of Arts, Science & Commerce, Aurangabad. Department of Computer Science. Academic Year
Dr. Rafiq Zakaria Campus Maulana Azad College of Arts, Science & Commerce, Aurangabad Department of Computer Science Academic Year 2015-16 MCQs on Operating System Sem.-II 1.What is operating system? a)
More informationLecture 10: Avoiding Locks
Lecture 10: Avoiding Locks CSC 469H1F Fall 2006 Angela Demke Brown (with thanks to Paul McKenney) Locking: A necessary evil? Locks are an easy to understand solution to critical section problem Protect
More information