Tel Aviv University Raymond and Beverly Sackler Faculty of Exact Sciences School of Computer Science. by Guy Golan Gueta

Size: px
Start display at page:

Download "Tel Aviv University Raymond and Beverly Sackler Faculty of Exact Sciences School of Computer Science. by Guy Golan Gueta"

Transcription

1 Tel Aviv University Raymond and Beverly Sackler Faculty of Exact Sciences School of Computer Science AUTOMATIC FINE-GRAINED SYNCHRONIZATION by Guy Golan Gueta under the supervision of Prof. Mooly Sagiv and Prof. Eran Yahav and the consultation of Dr. G. Ramalingam A thesis submitted for the degree of Doctor of Philosophy Submitted to the Senate of Tel Aviv University April 2015

2 ii

3 To my loved ones, Sophie, Yasmin, Ortal and Ariel. iii

4 iv

5 Abstract Automatic Fine-Grained Synchronization Guy Golan Gueta School of Computer Science Tel Aviv University A key challenge in writing concurrent programs is synchronization: ensuring that concurrent accesses and modifications to a shared mutable state do not interfere with each other in undesirable ways. An important correctness criterion for synchronization is atomicity, i.e., the synchronization should ensure that a code section (a transaction) appears to execute atomically. Realizing an efficient and scalable synchronization that correctly ensures atomicity is considered a challenging task. In this thesis, we address the problem of achieving correct and efficient atomicity by developing and enforcing certain synchronization protocols. We present three novel synchronization approaches that utilize program-specific information using compile-time and run-time techniques. The first approach leverages the shape of shared memory in order to transform a sequential library into an atomic library (i.e., into a library in which each operation appears to execute atomically). The approach is based on domination locking, a novel fine-grained locking protocol designed specifically for concurrency control in object-oriented software with dynamic pointer updates. We present a static algorithm that automatically enforces domination locking in a sequential library which is implemented using a dynamic forest. We show that our algorithm can successfully add effective fine-grain locking to libraries where manually performing locking is challenging. The second approach transforms atomic libraries into transactional libraries, which ensure atomicity of sequences of operations. The central idea is to create a library that exploits information (foresight) provided by its clients. The foresight restricts the cases that should be considered by the library thereby permitting more efficient synchronization. This approach is based on a novel synchronization protocol which is based on a notion of dynamic right-movers. We present a static analysis to infer the foresight information required by the approach, allowing a compiler to automatically insert the foresight information into the client. This relieves the client programmer of this burden and simplifies writing client code. We show a generic implementation technique to realize the approach in a given library. We show that this approach enables enforcing atomicity of a wide selection of real-life v

6 Java composite operations. Our experiments indicate that the approach enables realizing efficient and scalable synchronization for real-life composite operations. Finally, we show an approach that enables using multiple transactional libraries. This approach is applicable to a special case of transactional libraries in which the synchronization is based on locking that exploits semantic properties of the library operations. This approach realizes a semantic-based finegrained locking which is based on the commutativity properties of the libraries operations and on the program s dynamic pointer updates. We show that this approach leads to effective synchronization. In some cases, it improves the applicability and the performance of our second approach. We formalize the above approaches and prove they guarantee atomicity and deadlock freedom. We show that our approaches provide a variety of tools to effectively deal with common cases in concurrent programs. vi

7 Acknowledgements First and foremost, I would like to express my deep gratitude and appreciation to my advisors, Mooly Sagiv and Eran Yahav. Their guidance, inspiration, knowledge, and optimism were crucial for the completion of this thesis. I would like to thank G. Ramalingam for his guidance, help, and support throughout the work on this thesis. This thesis would have been impossible without his guidance and help. I would like to thank Alex Aiken and Nathan Bronson for interesting discussions, joint work, and for the enjoyable visits at Stanford University. I would like to thank Mooly s group for many fruitful discussions and for being such a wonderful combination of research colleagues and friends: Ohad Shacham, Shachar Itzhaky, Omer Tripp, Ofri Ziv, Oren Zomer, Ghila Castelnuovo, Ariel Jarovsky, Hila Peleg, and Or Tamir. vii

8 viii

9 Contents 1 Introduction Automatic Fine-Grained Locking Transactional Libraries Composition of Transactional Libraries via Semantic Locking Fine-Grained Locking using Shape Properties Overview Preliminaries Domination Locking Enforcing DL in Forest-Based Libraries Eager Forest-Locking Enforcing EFL Example for Dynamically Changing Forest Performance Evaluation General Purpose Data Structures Specialized Implementations Transactional Libraries with Foresight Overview Serializable and Serializably-Completable Executions Serializably-Completable Execution: A Characterization Synchronization Using Foresight Realizing Foresight Based Synchronization Preliminaries Libraries Clients Foresight-Based Synchronization The Problem ix

10 3.3.2 The Client Protocol Dynamic Right Movers Serializability B-Serializable-Completability E-Completability Special Cases Automatic Foresight for Clients Annotation Language Inferring Calls to mayuse Procedures Implementation for Java Programs Implementing Libraries with Foresight The Basic Approach Using Dynamic Information Optimistic Locking Further Extensions Java Threads and Transactions Experimental Evaluation Applicability and Precision Of The Static Analysis Comparison To Hand-Crafted Implementations Evaluating The Approach On Realistic Software Java Implementation of the Transactional Maps Library Base Library Extended Library Utilizing Dynamic Information by Handcrafted Optimization API Adapter Composition of Transactional Libraries via Semantic Locking Semantic Locking Basics ADTs With Semantic Locking Automatic Atomicity Automatic Atomicity Enforcement Enforcing S2PL Lock Ordering Constraints Enforcing OS2PL on Acyclic Graphs Optimizations x

11 4.2.5 Handling Cycles via Coarse-Grained Locking Using Specialized Locking Operations Implementing ADTs with Semantic Locking Performance Evaluation Benchmarks Performance Related Work Synchronization Protocols Concurrent Data Structures Automatic Synchronization Conclusions and Future Work 109 Bibliography 111 xi

12 xii

13 Chapter 1 Introduction Concurrency is widely used in software systems because it helps reduce latency, increase throughput, and provide better utilization of multi-core machines [35, 69]. However, writing concurrent programs is considered a difficult and error-prone process, due to the need to consider all possible interleavings of code fragments which are executed in parallel. Atomicity Atomicity is a fundamental correctness property of code sections in concurrent programs. Intuitively, a code section is said to be atomic if for every (arbitrarily interleaved) program execution, there is an equivalent execution with the same overall behavior where the atomic code section is not interleaved with other parts of the program. In other words, an atomic code section can be seen as a code section which is always executed in isolation. Atomic code sections help reasoning about concurrent programs, since one can assume that each atomic code section is never interleaved with other parts of the program. Several different variants of the atomicity property have been defined and used in the literature of databases and shared memory systems, where each variant has its own semantic properties and is aimed at a specific set of scenarios and considerations (e.g., [45, 55, 75, 86]). For example, linearizability [55] is a variant of atomicity that is commonly used to describe implementations of shared libraries (and shared objects): an operation of a linearizable library can be seen as if it always takes effect instantaneously at some point between its invocation and its response. The linearizable property ignores the actual implementation details of the shared library; instead, it only considers the library behavior from the point of view of its client. The Problem In this thesis we address the problem of automatically ensuring atomicity of code sections by realizing an efficient and scalable synchronization. One of the main challenges in this problem is to guarantee atomicity in a scalable way, restricting parallelism only where necessary. The synchronization should not have a high run-time overhead which makes it worthless i.e., it should have better 1

14 2 CHAPTER 1. INTRODUCTION performance than simple alternatives (like a single global lock [89]). Solutions for enforcing atomicity, which are implemented in practice, are predominantly handcrafted and tend to lead to concurrency bugs (e.g., see [33, 58, 79]). Automatic approaches (see Section 5.3) allow a programmer to declaratively specify the atomic code sections, leaving it to a compiler and run-time to implement the necessary synchronization. However, existing automatic approaches have not been widely adopted due to various concerns [27, 34, 36, 69, 84, 89], including high run-time overhead, poor performance and limited ability to handle irreversible operations (such as I/O operations). Specialized Synchronization In this thesis we present several approaches for automatic atomicity enforcement, where each approach is designed to handle a restricted class of programs (and scenarios). The idea is to produce synchronization that enforces atomicity by exploiting the restricted properties of the programs. For each approach we describe a specialized synchronization protocol, and realize the protocol by using a combination of compile-time and run-time techniques. The synchronization protocols are designed to ensure efficient and scalable atomicity, without leading to deadlocks and without using any rollback mechanism. The presented approaches deal with two different aspects of the synchronization problem for concurrent programs. In the first approach, we deal with the code inside the libraries (i.e., the library implementation); whereas in the other two approaches, we deal with code which utilizes the libraries API. 1.1 Automatic Fine-Grained Locking In Chapter 2, we present an approach that leverages the shape of shared memory 1 to transform a sequential library into a linearizable library [55]. This approach is based on the paper Automatic Fine-Grain Locking using Shape Properties that was presented at OOPSLA 2011 [40]. A library encapsulates shared data with a set of procedures, which may be invoked by concurrently executing threads. Given the code of a library, our goal is to add correct fine-grained locking that ensures linearizability and permits a high degree of parallelism. Specifically, we are interested in locking in which each shared object has its own lock, and locks may be released before the end of the computation. The main insight of this approach is to use the shape of the pointer data structures to simplify reasoning about fine-grained locking and automatically infer efficient and correct fine-grained locking. Domination Locking We define a new fine-grained locking protocol called Domination Locking. Domination Locking is a set of conditions that guarantee atomicity and deadlock-freedom. Domination Locking is designed to handle dynamically-manipulated recursive data structures by leveraging natural 1 The shape of the heap s objects graph.

15 1.2. TRANSACTIONAL LIBRARIES 3 domination properties of paths in dynamically-changing data structures. This protocol is a strict generalization of several related fine-grained locking protocols such as dynamic tree locking and dynamic DAG locking [17, 19, 28]. Automatic Fine-Grained Locking We then present an automatic technique to enforce the conditions of Domination Locking. The technique is applicable to libraries where the shape of the shared heap is a forest. The technique allows the shape of the heap to change dynamically as long as the shape is a forest between invocations of library operations. We show that our technique adds efficient and scalable fine-grained locking in several practical data structures where it is hard to produce similar locking manually. We demonstrate the applicability of the method on balanced search-trees [16, 46], a self-adjusting heap [81] and specialized data structure implementations [18, 72]. 1.2 Transactional Libraries Linearizable libraries provide operations that appear to execute atomically. However, clients often need to perform a sequence of library operations that appears to execute atomically, referred to hereafter as an atomic composite operation. In Chapter 3, we consider the problem of extending a linearizable library to support arbitrary atomic composite operations by clients. We introduce a novel approach in which the library ensures atomicity of composite operations by exploiting information provided by its clients. We refer to such libraries as transactional libraries. Our basic methodology requires the client code to demarcate the sequence of operations for which atomicity is desired and provide declarative information to the library (foresight) about the library operations that the composite operation may invoke. It is the library s responsibility to ensure the desired atomicity, exploiting the foresight information for effective synchronization. Example The idea is demonstrated in code fragment shown in Figure 1.1. This code uses a shared Counter (a shared library) by invoking its Get and Inc operations. The code provides information (foresight) about the future possible Counter operations: at line 2 it indicates that any operation may be invoked (after line 2), at line 4 it indicates that only Inc may be invoked (after line 4), finally at line 9 it indicates that no more operations will be used (after line 9). This information is utilized by the Counter implementation in order to efficiently ensure that this code fragment will always be executed atomically. A detailed version of this example is described in Chapter 3. Our approach is based on the paper Concurrent Libraries with Foresight that was presented at PLDI 2013 [41].

16 4 CHAPTER 1. INTRODUCTION 1 */ { 3 c = Get(); 5 while (c > 0) { 6 c = c-1; 7 Inc(); 8 } 10 } Figure 1.1: Code that provides information (foresight) about future possible operations. Foresight based Synchronization We first present a formalization of this approach. We formalize the desired goals and present a sufficient correctness condition. As long as the clients and the library extension satisfy the correctness condition, all composite operations are guaranteed atomicity without deadlocks. Our sufficiency condition is broad and permits a range of implementation options and finegrained synchronization. It is based on a notion of dynamic right-movers (Section 3.3.3), which generalizes traditional notions of static right-movers and commutativity [61, 66]. Our approach decouples the implementation of the library from the client. Thus, the correctness of the client does not depend on the way the foresight information is used by library implementation. The client only needs to ensure the correctness of the foresight information. Automatic Foresight for Clients We then present a static analysis to infer the foresight information required by our approach, allowing a compiler to automatically insert the foresight information into the client code. This relieves the client programmer of this burden and simplifies writing atomic composite operations. Library Extension Realization Our approach permits the use of customized, hand-crafted, implementations of the library extension. However, we also present a generic technique for extending a linearizable library with foresight. The technique is based on a novel variant of the tree locking protocol in which the tree is designed according to semantic properties of the library s operations. We used our generic technique to implement a single general-purpose Java library for Map data structures. Our library permits composite operations to simultaneously work with multiple instances of Map data structures. (We focus on Maps, because Shacham [78] observed that Maps are heavily used for implementing composite operations in real-life concurrent programs). We use our library and the static analysis to enforce atomicity of a selection of real-life Java composite operations, including composite operations that manipulate multiple instances of Map data structures. Our experiments indicate that our approach enables realizing efficient and scalable synchronization for real-life composite operations.

17 1.3. COMPOSITION OF TRANSACTIONAL LIBRARIES VIA SEMANTIC LOCKING Composition of Transactional Libraries via Semantic Locking In Chapter 4, we present an approach for handling composite operations that use multiple transactional libraries. Our approach is described in the short paper Automatic Semantic Locking that was presented at PPOPP 2014 [42]. This approach is also used in the paper Automatic scalable atomicity via semantic locking that was presented at PPOPP 2015 [43]. Our approach can be seen as a combination of Chapter 3 and approaches for automatic lock inference (e.g., [68]). In this approach, we restrict the synchronization that can be implemented in the libraries to synchronization that resembles locking this synchronization is similar to the semantic-aware locking from the database literature. We refer to such libraries as libraries with semantic-locking. We describe a static algorithm that enforces atomicity of code sections that use multiple libraries with semantic-locking. We implement this static algorithm and show it produces efficient and scalable synchronization.

18 6 CHAPTER 1. INTRODUCTION

19 Chapter 2 Fine-Grained Locking using Shape Properties In this chapter, we consider the problem of turning a sequential library into a linearizable library [55]. Our goal is to provide a synchronization method which guarantees atomicity of the library operations in a scalable way, restricting parallelism only where necessary. We are interested in a systematic method that is applicable to a large family of libraries, rather than a method specific to a single library. Fine-Grained Locking One way to achieve scalable multi-threading is to use fine-grained locking (e.g., [19]). In fine-grained locking, one associates, e.g., each shared object with its own lock, permitting multiple operations to simultaneously operate on different parts of the shared state. Reasoning about fine-grained locking is challenging and error-prone. As a result, programmers often resort to coarsegrained locking, leading to limited scalability. The Problem We would like to automatically add fine-grained locking to a library. A library encapsulates shared data with a set of procedures, which may be invoked by concurrently executing threads. Given the code of a library, our goal is to add correct locking that ensures atomicity and permits a high degree of parallelism. Specifically, we are interested in locking in which each shared object has its own lock, and locks may be released before the end of the computation. Our main insight is that we can use the restricted shape of pointer data structures to simplify reasoning about fine-grained locking and automatically infer efficient and correct fine-grained locking. Domination Locking We define a new fine-grained locking protocol called Domination Locking. Domination Locking is a set of conditions that guarantees atomicity and deadlock-freedom. Domination Locking is designed to handle dynamically-manipulated recursive data structures by leveraging natural domination properties of dynamic data structures. 7

20 8 CHAPTER 2. FINE-GRAINED LOCKING USING SHAPE PROPERTIES root Key =10 Priority=99 Key =5 Priority=20 Key =15 Priority=72 Key =12 Priority=30 Key =18 Priority=50 Figure 2.1: An example for a Treap data structure. Automatic Fine-Grained Locking We present an automatic technique to enforce the conditions of Domination Locking. The technique is applicable to libraries where the shape of the shared memory is a forest. The technique allows the shape of the heap to change dynamically as long as the shape is a forest between invocations of library operations. In contrast to existing lock inference techniques, which are based on two-phased locking (see Section 5.3), our technique is able to release locks at early points of the computation. Finally, as we demonstrate in Section 2.4 and Section 2.5, our technique adds effective and scalable fine-grained locking in several practical data structures where it is extremely hard to manually produce similar locking. Our examples include balanced search-trees [16, 46], a self-adjusting heap [81] and specialized data structure implementations [18, 72]. Motivating Example Consider a library that implements the Treap data structure [16]. A Treap is a search tree that is simultaneously a binary search tree (on the key field) and a heap (on the priority field). An example is shown in Figure 2.1. If priorities are assigned randomly the resulting structure is equivalent to a random binary search tree, providing good asymptotic bounds for all operations. The Treap implementation consists of three procedures: insert, remove and lookup. Manually adding fine-grained locking to the Treap s code, is challenging since it requires considering many subtle details of the Treap s code. In contrast, our technique can add fine-grained locking to the Treap s code without considering its exact implementation details. (In other words, our technique does not need to understand the actual code of the Treap). For example, consider the Treap s remove operation shown in Figure 2.2. To achieve concurrent execution of its operations, we must release the lock on the root, while an operation is still in progress, once it is safe to do so. Either of the loops (starting at Lines 4 or 12) can move the current context to a subtree, after which the root (and, similarly, other nodes) should be unlocked. Several parts of this procedure implement tree rotations that change the order among the Treap s nodes, complicating

21 2.1. OVERVIEW 9 any correctness reasoning that depends on the order among nodes. Figure 2.3 shows an example of manual fine-grained locking of the Treap remove operation. Manually adding fine-grained locking to the code took an expert several hours and was an extremely error-prone process. In several cases, the expert locking released a lock too early, resulting in an incorrect concurrent algorithm (e.g., the release operation in Line 28). Our technique is able to automatically produce fine-grained concurrency in the Treap s code, by relying on its tree shape. This is in contrast to existing alternatives, such as manually enforcing handover-hand locking, that require a deep understanding of code details. Note that the dynamic tree locking protocol [17] is sufficient to ensure atomicity and deadlockfreedom of the Treap s example. In fact, the locking shown in Figure 2.3 satisfies the conditions of the dynamic tree locking protocol. But in contrast to the domination locking protocol which can be automatically enforced in the Treap s code, none of the existing synchronization techniques (see Section 5.3) can automatically enforce dynamic tree locking protocol for the Treap (even though the Treap is a single tree). 2.1 Overview In this section, we present an informal brief description of our approach. Domination Locking We define a new locking protocol, called Domination Locking (abbreviated DL). DL is a set of conditions that are designed to guarantee atomicity and deadlock freedom for operations of a well-encapsulated library. DL differentiates between a library s exposed and hidden objects: exposed objects (e.g., the Treap s root) act as the intermediary between the library and its clients, with pointers to such objects being passed back and forth between the library and its clients, while the clients are completely unaware of hidden objects (e.g., the Treap s intermediate nodes). The protocol exploits the fact that all operations must begin with one or more exposed objects and traverse the heap-graph to reach hidden objects. The protocol requires the exposed objects passed as parameters to an operation to be locked in a fashion similar to two-phase-locking. However, hidden objects are handled differently. A thread is allowed to acquire a lock on a hidden object if the locks it holds dominate the hidden object. (A set S of objects is said to dominate an object u if all paths (in the heap-graph) from an exposed object to u contains some object in S.) In particular, hidden objects can be locked even after other locks have been released, thus enabling early release of other locked objects (hidden as well as exposed). This simple protocol generalizes several fine-grained locking protocols defined for dynamically changing graphs [17, 19, 28] and is applicable in more cases (i.e., the conditions of DL are weaker). We use the DL s conditions as the basis for our automatic technique.

22 10 CHAPTER 2. FINE-GRAINED LOCKING USING SHAPE PROPERTIES 1 boolean remove(node par, int key) { 2 Node n = null; 3 n = par.right; // right child has root 4 while (n!= null && key!= n.key) { 5 par = n; 6 n = (key < n.key)? n.left : n.right; 7 } 8 if (n == null) 9 return false; // search failed, no change 10 Node nl = n.left; 11 Node nr = n.right; 12 while (true) { // n is the node to be removed 13 Node bestchild = (nl == null 14 (nr!= null && nr.prio > nl.prio))? nr : nl; 15 if (n == par.left) 16 par.left = bestchild; 17 else 18 par.right = bestchild; 19 if (bestchild == null) 20 break; // n was a leaf 21 if (bestchild == nl) { 22 n.left = nl.right; // rotate nl to n s spot 23 nl.right = n; 24 nl = n.left; 25 } else { 26 n.right = nr.left; // rotate nr to n s spot 27 nr.left = n; 28 nr = n.right; 29 } 30 par = bestchild; 31 } 32 return true; 33 } Figure 2.2: Removing an element from a treap by locating it and then rotating it into a leaf position. (Our technique can add fine-grained locking to this code without understanding its details.)

23 2.1. OVERVIEW 11 1 boolean remove(node par, int key) { 2 Node n = null; 3 acquire(par); 4 n = par.right; 5 if(n!= null) acquire(n); 6 while (n!= null && key!= n.key) { 7 release(par); 8 par = n; 9 n = (key < n.key)? n.left : n.right; 10 if(n!= null) acquire(n); 11 } 12 if (n == null){ release(par); return false; } 13 Node nl = n.left; if(nl!= null) acquire(nl); 14 Node nr = n.right; if(nr!= null) acquire(nr); 15 while (true) { 16 Node bestchild = (nl == null 17 (nr!= null && nr.prio > nl.prio))? nr : nl; 18 if (n == par.left) 19 par.left = bestchild; 20 else 21 par.right = bestchild; 22 release(par); 23 if (bestchild == null) 24 break; 25 if (bestchild == nl) { 26 n.left = nl.right; 27 nl.right = n; 28 // release(nl); // an erroneous release statment 29 nl = n.left; 30 if(nl!= null) acquire(nl); 31 } else { 32 n.right = nr.left; 33 nr.left = n; 34 nr = n.right; 35 if(nr!= null) acquire(nr); 36 } 37 par = bestchild; 38 } 39 return true; 40 } Figure 2.3: Treap s remove code with manual fine-grained locking.

24 12 CHAPTER 2. FINE-GRAINED LOCKING USING SHAPE PROPERTIES Key =10 Priority=99 par n Key =5 Priority=20 nl Key =15 Priority=72 nr bestchild Key =12 Priority=30 Key =18 Priority=50 Figure 2.4: Execution of the Treap s remove (Figure 2.2) in which the tree shape is violated. The node pointed by nr and bestchild has two predecessors. Automatic Locking of Forest-Based Libraries Our technique is able to automatically enforce DL, in a way that releases locks at early points of the computation. Specifically, the technique is applicable to libraries whose heap-graphs form a forest at the end of any complete sequential execution (of any sequence of operations). Note that existing shape analyses, for sequential programs, can be used to automatically verify if a library satisfies this precondition (e.g., [76, 88] ). In particular, we avoid the need for explicitly reasoning on concurrent executions. For example, the Treap is a tree at the end of any of its operations, when executed sequentially. Note that, during some of its operation (insert and remove) its tree shape is violated by a node with multiple predecessors (caused by the tree rotations). An example for tree violation (caused by the rotations in remove) is shown in Figure 2.4. Our technique uses the following locking scheme: a procedure invocation maintains a lock on the set of objects directly pointed to by its local variables (called the immediate scope). When an object goes out of the immediate scope of the invocation (i.e., when the last variable pointing to that object is assigned some other value), the object is unlocked if it has (at most) one predecessor in the heap graph (i.e., if it does not violate the forest shape). If a locked object has multiple predecessors when it goes out of the immediate scope of the invocation, then it is unlocked eventually when the object has at most one predecessor. The forest-condition guarantees that every lock is eventually released. To realize this scheme, we use a pair of reference counts to track incoming references from the heap and local variables of the current procedure. All the updates to the reference count can be done easily by instrumenting every assignment statement, allowing a relatively simple compile-time transformation. While we defer the details of the transformation to Section 2.4, Figure 2.5 shows the transformed implementation of remove (from Figure 2.2). ASNL and ASNF are macros that perform assignment to a local variable and a field, respectively, update reference counts, and conditionally acquire or release locks according to the above locking scheme.

25 2.1. OVERVIEW 13 1 boolean remove(node par, int key) { 2 Node n = null; 3 Take(par); 4 ASNL(n, par.right); 5 while (n!= null && key!= n.key) { 6 ASNL(par, n); 7 ASNL(n, (key < n.key)? n.left : n.right); 8 } 9 if (n == null) { 10 ASNL(par, null); 11 ASNL(n, null); 12 return false; 13 } 14 Node nl = null; ASNL(nL, n.left); 15 Node nr = null; ASNL(nR, n.right); 16 while (true) { 17 Node bestch = null; ASNL(bestCh, (nl == null 18 (nr!= null && nr.prio > nl.prio))? nr : nl); 19 if (n == par.left) 20 ASNF(par.left, bestch); 21 else 22 ASNF(par.right, bestch); 23 if (bestch == null) { 24 ASNL(bestCh, null); 25 break; 26 } 27 if (bestch == nl) { 28 ASNF(n.left, nl.right); 29 ASNF(nL.right, n); 30 ASNL(nL, n.left); 31 } else { 32 ASNF(n.right, nr.left); 33 ASNF(nR.left, n); 34 ASNL(nR, n.right); 35 } 36 ASNL(par, bestch); 37 ASNL(bestCh, null); 38 } 39 ASNL(par, null); ASNL(n, null); ASNL(nL, null); 40 ASNL(nR, null); 41 return true; 42 } Figure 2.5: Augmenting remove with macros to dynamically enforce domination locking.

26 14 CHAPTER 2. FINE-GRAINED LOCKING USING SHAPE PROPERTIES Main Contributions The main contributions of this chapter can be summarized as follows: We introduce a new locking protocol entitled Domination Locking. We show that domination locking can be enforced and verified by considering only sequential executions [17]: if domination locking is satisfied by all sequential executions, then atomicity and deadlock freedom are guaranteed in all executions, including non-sequential ones. We present an automatic technique to generate fine-grained locking by enforcing the domination locking protocol for libraries where the heap graph is guaranteed to be a forest in between operations. Our technique can handle any temporary violation of the forest shape constraint, including temporary cycles. We present a performance evaluation of our technique on several examples, including balanced search-trees [16, 46], a self-adjusting heap [81] and specialized data structure implementations [18, 72]. The evaluation shows that our automatic locking provides good scalability and performance comparable to hand crafted locking (for the examples where hand crafted locking solutions were available). We discuss extensions and additional applications of our suggestions. 2.2 Preliminaries Our goal is to augment a library with concurrency control that guarantees strict conflict-serializability [75] and linearizability [55]. In this section we formally define what a library is and the notion of strict conflict-serializability for libraries. Syntax and Informal Semantics A library defines a set of types and a set of procedures that may be invoked by clients of the library, potentially concurrently. A type consists of a set of fields of type boolean, integer, or pointer to a user-defined type. The types are private to the library: an object of a type T defined by a library M can be allocated or dereferenced only by procedures of library M. However, pointers to objects of type T can be passed back and forth between the clients of library M and the procedures of library M. Dually, types defined by clients are private to the client. Pointers to clientdefined types may be passed back and forth between the clients and the library, but the library cannot dereference such pointers (or allocate objects of such type). Procedures have parameters and local variables, which are private to the invocation of the procedures. (Thus, these are thread-local variables.) There are no static or global variables shared by different invocations of procedures. (However, our results can be generalized to support them.)

27 2.2. PRELIMINARIES 15 stms = skip x = e(y1,...,yk) assume(b) x = new R() x = y.f x.f = y acquire(x) release(x) return(x) Figure 2.6: Primitive instructions, b stands for a local boolean variable, e(y1,...,yk) stands for an expression over local variables. We assume that body of a procedure is represented by a control-flow graph. We refer to the vertices of a control-flow graph as program points. The edges of a control-flow graph are annotated with primitive instructions, shown in Figure 2.6. Conditionals are encoded by annotating control-flow edges with assume statements. Without loss of generality, we assume that a heap object can be dereferenced only in a load ( x = y.f ) or store ( x.f = y ) instruction. Operations to acquire or release a lock refer to a thread-local variable (that points to the heap object to be locked or unlocked). The other primitive instructions reference only thread-local variables. We present a semantics for a library independent of any specific client. We define a notion of execution that covers all possible executions of the library that can arise with any possible client, but restricting attention to the part of the program state owned by the library. (In effect, our semantics models what is usually referred to as a most-general-client of the library.) For simplicity, we assume that each procedure invocation is executed by a different thread, which allows us to identify procedure invocations using a thread-id. We refer to each invocation of a procedure as a transaction. We model a procedure invocation as a creation of a new thread with an appropriate thread-local state. We describe the behavior of a library by the relation. A transition σ σ represents the fact that a state σ can be transformed into a state σ by executing a single instruction. Transactions share a heap consisting of an (unbounded) set of heap objects. Any object allocated during the execution of a library procedure is said to be a library (owned) object. In fact, our semantics models only library owned objects. Any library object that is returned by a library procedure is said to be an exposed object. Other library objects are hidden objects. Note that an exposed object remains exposed forever. A key idea encoded in the semantics is that at any point during execution a new procedure invocation may occur. The only assumption made is that any library object passed as a procedure argument is exposed; i.e., the object was returned by some earlier procedure invocation. Each heap allocated object serves as a lock for itself. Locks are exclusive (i.e., a lock can be held by at most one transaction at a time). The execution of a transaction trying to acquire a lock (by an acquire

28 16 CHAPTER 2. FINE-GRAINED LOCKING USING SHAPE PROPERTIES v V al = Loc Z {true, false, null} ρ E = V V al h H = Loc F V al l L = Loc s S = K E 2 L σ Σ = H (Loc {true, false}) (T S) Figure 2.7: Semantic domains Instruction Transition Side Condition skip x = e(y 1,..., y k ) assume(b) x = newr() x = y.f x.f = y acquire(x) release(x) return(x) return(x) σ t,e h, r, ϱ[t k, ρ, L ] σ t,e h, r, ϱ[t k, ρ[x [[e]](ρ(y 1 ),..., ρ(y k ))], L ] σ t,e h, r, ϱ[t k, ρ, L ] σ t,e h[a o], r, ϱ[t k, ρ[x a], L ] σ t,e h, r, ϱ[t k, ρ[x h(ρ(y))(f)], L ] σ t,e h[ρ(x) (h(ρ(x))[f ρ(y)])], r, ϱ[t k, ρ, L ] ρ(b) = true a dom(h) ι(r)() = o ρ(y) dom(h) ρ(x) dom(h) σ t,e h, r, ϱ[t k, ρ, L {ρ(x)} ] ρ(x) L k, ρ, L range(ϱ) : ρ(x) L σ t,e h, r, ϱ[t k, ρ, L \ {ρ(x)} ] σ t,e h, r[ρ(x) true], ϱ[t k, ρ, L ] σ t,e h, r, ϱ[t k, ρ, L ] ρ(x) L ρ(x) dom(h) ρ(x) dom(h) Table 2.1: The semantics of primitive instructions. For brevity, we use the shorthands: σ = h, r, ϱ and ϱ(t) = k, ρ, L, and omit (k, k ) = e CFG t from all side conditions. statement) which is held by another transaction is blocked until a time when the lock is available (i.e., is not held by any transaction). Locks are reentrant; an acquire statement has no impact when it refers to a lock that is already held by the current transaction. A transaction cannot release a lock that it does not hold. Whenever a new object is allocated, its boolean fields are initialized to false, its integer fields are initialized to 0, and pointer fields are initialized to null. Local variables are initialized in the same manner. Semantics Figure 2.7 defines the semantic domains of a state of a library, and meta-variables ranging over them. Let t T be the domain of transaction identifiers. A state σ = h, r, ϱ Σ of a library is a triple: h assigns values to fields of dynamically allocated objects. A value v Val can be either a location, an integer, a boolean value,or null. r maps exposed objects to true, and hidden objects to false. Finally, ϱ associates a transaction t with its transaction local state ϱ(t). A transaction-local state s = k, ρ, L S is: k is the value of the transaction s program counter, ρ records the values of its local

29 2.2. PRELIMINARIES 17 variables, and L is the transaction s lock set which records the locks that the transaction holds. The behavior of a library is described by the relations and. The relation is a subset of Σ (T (K K)) Σ, and is defined in Table A transition σ t,e σ represents the fact that σ can be transformed into σ via transaction t executing the instruction annotating control-flow edge e. Invocation of a new transaction is modeled by the relation Σ T Σ; we say that h, r, ϱ t σ if σ = h, r, ϱ[t s] where t dom(ϱ) and s is any valid initial local state: i.e., s = entry, ρ, {}, where entry is the entry vertex, and ρ maps local variables and parameters to appropriate initial values (based on their type). In particular, ρ must map any pointer parameter of a type defined by the library to an exposed object (i.e., an object u in h such that r(u) = true). We write σ σ, if there exists t such that σ t σ or there exists t, e such that σ t,e σ. Running Transactions Each control-flow graph of a procedure has two distinguished control points: an entry site from which the transaction starts, and an exit site in which the transaction ends (if a CFG edge is annotated with a return statement, then this edge points to the exit site of the procedure). We say that a transaction t is running in a state σ, if t is not in its entry site or exit site. An idle state, is a state in which no transaction is running. Executions The initial state σ I has an empty heap and no transactions. A sequence of states π = σ 0,..., σ k is an execution if the following hold: (i) σ 0 is the initial state, (ii) for 0 i < k, σ i σ i+1. An execution π = σ 0,..., σ k is a complete execution, if σ k is idle. An execution π = σ 0,..., σ k is a sequential execution, if for each 0 i k at most one transaction in σ i is running. An execution is non-interleaved if transitions of different transactions are not interleaved (i.e., for every pair of transactions t i t j either all the transitions executed by t i come before any transition executed by t j, or vice versa). Note that, a sequential execution is a special case of a non-interleaved execution. In a sequential execution a new transaction starts executing only after all previous transactions have completed execution. In a non-interleaved execution, a new transaction can start executing before a previous transaction completes execution, but the execution is not permitted to include transitions by the previous transaction once the new transaction starts executing. We say that a sequential execution is completable if it is a prefix of a complete sequential execution. Schedules The schedule of an execution π = σ 0,..., σ k is a sequence t 0, e 0,..., t k 1, e k 1 such t i,e i t that for 0 i < k: σ i σ i+1, or σ i i σi+1 and e i = e init (where e init is disjoint with all edges in the CFG). We say that a sequence ξ = t 0, e 0,..., t k 1, e k 1 is a feasible schedule, if ξ 1 For simplicity of presentation, we use an idempotent variant of acquire (i.e., acquire has no impact when the lock has already owned by the current transaction). We note that this variant is permitted by the Lock interface from the java.util.concurrent.locks package, and can easily be implemented in languages such as Java and C++.

30 18 CHAPTER 2. FINE-GRAINED LOCKING USING SHAPE PROPERTIES is a schedule of an execution. The schedule of a transaction t in an execution is the (possibly noncontiguous) subsequence of the execution s schedule consisting only of t s transitions. Notice that each feasible schedule uniquely defines a single execution because: (i) we assume that there exists a single intial state; and (ii) each instruction defined intable 2.1 is a partial function (in our semantics nondeterminism is modeled by permitting CFG nodes with several outgoing edges). Graph-Representation The heap (shared memory) of a state identifies an edge-labelled multidigraph (a directed graph in which multiple edges are allowed between the same pair of vertices), which we call the heap graph. Each heap-allocated object is represented by a vertex in the graph. A pointer field f in an object u that points to an object v is represented by an edge (u, v) labelled f. (Note that the heap graph represents only objects owned by the library. Objects owned by the client are not represented in the heap graph.). We define the allocation id of an object in an execution to be the pair (t, i) if the object was allocated by the i-th transition executed by a transaction t. An object o 1 in an execution π 1 corresponds to an object o 2 in an execution π 2 iff their allocation ids are the same. We compare states and objects belonging to different executions modulo this correspondence relation. Strict Conflict-Serializability and Linearizability conflict if: Given an execution, we say that two transitions (i) they are executed by two different transactions, (ii) they access some common object (i.e., read or write fields of the same object). Executions π and π are said to be conflict-equivalent if they consist of the same set of transactions, and the schedule of every transaction t is the same in both executions, and the executions agree on the order between conflicting transitions (i.e., the ith transition of a transaction t precedes and conflicts with the jth transition of a transaction t in π, iff the former precedes and conflicts with the latter in π ). Conflict-equivalent executions produce the same state [86]. An execution is conflict-serializable if it is conflict-equivalent with a non-interleaved execution. We say that an execution π is strict conflict-serializable if it is conflict-equivalent to a non-interleaved execution π where a transaction t 1 completes execution before a transaction t 2 in π if t 1 completes execution before a transaction t 2 in π. Assume that all sequential executions of a library satisfy a given specification Φ. In this case, a strict conflict-serializable execution is also linearizable [56] with respect to specification Φ. 2 Thus, correctness in sequential executions combined with strict conflict-serializability is sufficient to ensure linearizability. 2 Strict conflict-serializability guarantees the atomicity and the run-time order required by the linearizability property. Moreover, note that according to the linearizability property (as defined in [56]) the execution may contain transactions that will never be able to complete.

31 2.3. DOMINATION LOCKING 19 The above definitions can also be used for feasible schedules because (as explained earlier) a feasible schedule uniquely defines a single execution. 2.3 Domination Locking In this section we present the Domination Locking Protocol (abbreviated DL). We show that if every sequential execution of a library satisfies DL and is completable, then every concurrent execution of the library is strict conflict-serializable and is a prefix of a complete-execution (i.e., atomicity and deadlockfreedom are guaranteed). The locking protocol is parameterized by a total order on all heap objects, which remains fixed over the whole execution. Definition 2.1 Let be a total order of heap objects. We say that an execution satisfies the Domination Locking protocol, with respect to, if it satisfies the following conditions: 1. A transaction t can access a field of an object u, only if u is currently locked by t. 2. A transaction t can acquire an exposed object u, only if t has never acquired an exposed object v such that u v. 3. A transaction t can acquire an exposed object, only if t has never released a lock. 4. A transaction t can acquire a hidden object u, only if every path between an exposed object to u includes an object which is locked by t. Intuitively, the protocol works as follows. Requirement (1) prevents race conditions where two transactions try to update an object neither has locked. Conditions (2) and (3) deal with exposed objects. Very little can be assumed about an object that has been exposed; references to it may reside anywhere and be used at any time by other transactions that know nothing about the invariants t is maintaining. Thus, as is standard, requirements (2) and (3) ensure all transactions acquire locks on exposed objects in a consistent order, preventing deadlocks. The situation with hidden objects is different, and we know more: other threads can only gain access to t s hidden objects through some chain of references starting at an exposed object, and so it suffices for t to guard each such potential access path with a lock. Another way of understanding the protocol is that previous proposals (e.g., [28, 59, 63, 80]) treat all objects as exposed, whereas domination locking also takes advantage of the information hiding of abstract data types to impose a different, and weaker, requirement on encapsulated data. In particular, no explicit order is imposed on the acquisition or release of locks on hidden objects, provided condition (4) is maintained.

Concurrent Libraries with Foresight

Concurrent Libraries with Foresight Concurrent Libraries with Foresight Guy Golan-Gueta Tel Aviv University ggolan@tau.ac.il G. Ramalingam Microsoft Research grama@microsoft.com Mooly Sagiv Tel Aviv University msagiv@tau.ac.il Eran Yahav

More information

Static Lock Capabilities for Deadlock-Freedom

Static Lock Capabilities for Deadlock-Freedom Static Lock Capabilities for Deadlock-Freedom Colin S. Gordon csgordon@cs.washington.edu University of Washington TLDI, January 28, 2012 Joint work with Michael D. Ernst and Dan Grossman Colin S. Gordon

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

Logical Concurrency Control From Sequential Proofs

Logical Concurrency Control From Sequential Proofs Logical Concurrency Control From Sequential Proofs Jyotirmoy Deshmukh jyotirmoy@cerc.utexas.edu G. Ramalingam grama@microsoft.com Venkatesh Prasad Ranganath rvprasad@microsoft.com Kapil Vaswani kapilv@microsoft.com

More information

Joint Entity Resolution

Joint Entity Resolution Joint Entity Resolution Steven Euijong Whang, Hector Garcia-Molina Computer Science Department, Stanford University 353 Serra Mall, Stanford, CA 94305, USA {swhang, hector}@cs.stanford.edu No Institute

More information

Experience with Model Checking Linearizability

Experience with Model Checking Linearizability Experience with Model Checking Linearizability Martin Vechev, Eran Yahav, and Greta Yorsh IBM T.J. Watson Research Center Non-blocking concurrent algorithms offer significant performance advantages, but

More information

Improving the Practicality of Transactional Memory

Improving the Practicality of Transactional Memory Improving the Practicality of Transactional Memory Woongki Baek Electrical Engineering Stanford University Programming Multiprocessors Multiprocessor systems are now everywhere From embedded to datacenter

More information

Composing Concurrency Control

Composing Concurrency Control Composing Concurrency Control Ofri Ziv Tel Aviv University, Israel ofriziv@tau.ac.il Alex Aiken Stanford University, USA aiken@cs.stanford.edu Guy Golan-Gueta Tel Aviv University, Israel ggolan@tau.ac.il

More information

Reasoning About Lock Placements

Reasoning About Lock Placements Reasoning About Lock Placements Peter Hawkins, Alex Aiken, Kathleen Fisher, Martin Rinard, and Mooly Sagiv Stanford University, AT&T Labs Research, MIT, Tel Aviv University Abstract. A lock placement describes,

More information

Interprocess Communication By: Kaushik Vaghani

Interprocess 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 information

Handout 9: Imperative Programs and State

Handout 9: Imperative Programs and State 06-02552 Princ. of Progr. Languages (and Extended ) The University of Birmingham Spring Semester 2016-17 School of Computer Science c Uday Reddy2016-17 Handout 9: Imperative Programs and State Imperative

More information

Chapter 13 : Concurrency Control

Chapter 13 : Concurrency Control Chapter 13 : Concurrency Control Chapter 13: Concurrency Control Lock-Based Protocols Timestamp-Based Protocols Validation-Based Protocols Multiple Granularity Multiversion Schemes Insert and Delete Operations

More information

Graph-based protocols are an alternative to two-phase locking Impose a partial ordering on the set D = {d 1, d 2,..., d h } of all data items.

Graph-based protocols are an alternative to two-phase locking Impose a partial ordering on the set D = {d 1, d 2,..., d h } of all data items. Graph-based protocols are an alternative to two-phase locking Impose a partial ordering on the set D = {d 1, d 2,..., d h } of all data items. If d i d j then any transaction accessing both d i and d j

More information

! A lock is a mechanism to control concurrent access to a data item! Data items can be locked in two modes :

! A lock is a mechanism to control concurrent access to a data item! Data items can be locked in two modes : Lock-Based Protocols Concurrency Control! A lock is a mechanism to control concurrent access to a data item! Data items can be locked in two modes : 1 exclusive (X) mode Data item can be both read as well

More information

Concurrent & Distributed Systems Supervision Exercises

Concurrent & Distributed Systems Supervision Exercises Concurrent & Distributed Systems Supervision Exercises Stephen Kell Stephen.Kell@cl.cam.ac.uk November 9, 2009 These exercises are intended to cover all the main points of understanding in the lecture

More information

Lock-free Serializable Transactions

Lock-free Serializable Transactions Lock-free Serializable Transactions Jeff Napper jmn@cs.utexas.edu Lorenzo Alvisi lorenzo@cs.utexas.edu Laboratory for Advanced Systems Research Department of Computer Science The University of Texas at

More information

Thread Safety. Review. Today o Confinement o Threadsafe datatypes Required reading. Concurrency Wrapper Collections

Thread Safety. Review. Today o Confinement o Threadsafe datatypes Required reading. Concurrency Wrapper Collections Thread Safety Today o Confinement o Threadsafe datatypes Required reading Concurrency Wrapper Collections Optional reading The material in this lecture and the next lecture is inspired by an excellent

More information

Lecture 21 Concurrency Control Part 1

Lecture 21 Concurrency Control Part 1 CMSC 461, Database Management Systems Spring 2018 Lecture 21 Concurrency Control Part 1 These slides are based on Database System Concepts 6 th edition book (whereas some quotes and figures are used from

More information

LOGICAL CONCURRENCY CONTROL FROM SEQUENTIAL PROOFS. address:

LOGICAL CONCURRENCY CONTROL FROM SEQUENTIAL PROOFS.  address: Logical Methods in Computer Science Vol. 7 (3:10) 2011, pp. 1 29 www.lmcs-online.org Submitted Jun.26, 2010 Published Sep. 2, 2011 LOGICAL CONCURRENCY CONTROL FROM SEQUENTIAL PROOFS JYOTIRMOY DESHMUKH

More information

A Sophomoric Introduction to Shared-Memory Parallelism and Concurrency Lecture 5 Programming with Locks and Critical Sections

A Sophomoric Introduction to Shared-Memory Parallelism and Concurrency Lecture 5 Programming with Locks and Critical Sections A Sophomoric Introduction to Shared-Memory Parallelism and Concurrency Lecture 5 Programming with Locks and Critical Sections Dan Grossman Last Updated: May 2012 For more information, see http://www.cs.washington.edu/homes/djg/teachingmaterials/

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

DISTRIBUTED COMPUTER SYSTEMS

DISTRIBUTED COMPUTER SYSTEMS DISTRIBUTED COMPUTER SYSTEMS CONSISTENCY AND REPLICATION CONSISTENCY MODELS Dr. Jack Lange Computer Science Department University of Pittsburgh Fall 2015 Consistency Models Background Replication Motivation

More information

M301: Software Systems & their Development. Unit 4: Inheritance, Composition and Polymorphism

M301: Software Systems & their Development. Unit 4: Inheritance, Composition and Polymorphism Block 1: Introduction to Java Unit 4: Inheritance, Composition and Polymorphism Aims of the unit: Study and use the Java mechanisms that support reuse, in particular, inheritance and composition; Analyze

More information

Safety SPL/2010 SPL/20 1

Safety SPL/2010 SPL/20 1 Safety 1 system designing for concurrent execution environments system: collection of objects and their interactions system properties: Safety - nothing bad ever happens Liveness - anything ever happens

More information

Hybrid Static-Dynamic Analysis for Statically Bounded Region Serializability

Hybrid Static-Dynamic Analysis for Statically Bounded Region Serializability Hybrid Static-Dynamic Analysis for Statically Bounded Region Serializability Aritra Sengupta, Swarnendu Biswas, Minjia Zhang, Michael D. Bond and Milind Kulkarni ASPLOS 2015, ISTANBUL, TURKEY Programming

More information

mywbut.com Concurrency Control

mywbut.com Concurrency Control C H A P T E R 1 6 Concurrency Control This chapter describes how to control concurrent execution in a database, in order to ensure the isolation properties of transactions. A variety of protocols are described

More information

arxiv: v1 [cs.dc] 4 Mar 2016

arxiv: v1 [cs.dc] 4 Mar 2016 In the Search of Optimal Concurrency Vincent Gramoli 3 Petr Kuznetsov 1 Srivatsan Ravi 2 1 Télécom ParisTech 2 Purdue University 3 University of Sydney arxiv:1603.01384v1 [cs.dc] 4 Mar 2016 Abstract Implementing

More information

A Short Summary of Javali

A Short Summary of Javali A Short Summary of Javali October 15, 2015 1 Introduction Javali is a simple language based on ideas found in languages like C++ or Java. Its purpose is to serve as the source language for a simple compiler

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

1 Publishable Summary

1 Publishable Summary 1 Publishable Summary 1.1 VELOX Motivation and Goals The current trend in designing processors with multiple cores, where cores operate in parallel and each of them supports multiple threads, makes the

More information

Intermediate Code Generation

Intermediate Code Generation Intermediate Code Generation In the analysis-synthesis model of a compiler, the front end analyzes a source program and creates an intermediate representation, from which the back end generates target

More information

Obstruction degree: measuring concurrency in shared memory systems

Obstruction degree: measuring concurrency in shared memory systems Obstruction degree: measuring concurrency in shared memory systems Rachid Guerraoui and Mihai Letia EPFL {rachid.guerraoui,mihai.letia}@epfl.ch Abstract This paper presents the notion of obstruction degree,

More information

Process Management And Synchronization

Process 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 information

Computation Abstractions. Processes vs. Threads. So, What Is a Thread? CMSC 433 Programming Language Technologies and Paradigms Spring 2007

Computation Abstractions. Processes vs. Threads. So, What Is a Thread? CMSC 433 Programming Language Technologies and Paradigms Spring 2007 CMSC 433 Programming Language Technologies and Paradigms Spring 2007 Threads and Synchronization May 8, 2007 Computation Abstractions t1 t1 t4 t2 t1 t2 t5 t3 p1 p2 p3 p4 CPU 1 CPU 2 A computer Processes

More information

The Automatic Design of Batch Processing Systems

The Automatic Design of Batch Processing Systems The Automatic Design of Batch Processing Systems by Barry Dwyer, M.A., D.A.E., Grad.Dip. A thesis submitted for the degree of Doctor of Philosophy in the Department of Computer Science University of Adelaide

More information

Semantic Analysis. CSE 307 Principles of Programming Languages Stony Brook University

Semantic Analysis. CSE 307 Principles of Programming Languages Stony Brook University Semantic Analysis CSE 307 Principles of Programming Languages Stony Brook University http://www.cs.stonybrook.edu/~cse307 1 Role of Semantic Analysis Syntax vs. Semantics: syntax concerns the form of a

More information

CSE332: Data Abstractions Lecture 23: Programming with Locks and Critical Sections. Tyler Robison Summer 2010

CSE332: Data Abstractions Lecture 23: Programming with Locks and Critical Sections. Tyler Robison Summer 2010 CSE332: Data Abstractions Lecture 23: Programming with Locks and Critical Sections Tyler Robison Summer 2010 1 Concurrency: where are we Done: The semantics of locks Locks in Java Using locks for mutual

More information

Linearizability of Persistent Memory Objects

Linearizability of Persistent Memory Objects Linearizability of Persistent Memory Objects Michael L. Scott Joint work with Joseph Izraelevitz & Hammurabi Mendes www.cs.rochester.edu/research/synchronization/ Workshop on the Theory of Transactional

More information

NON-BLOCKING DATA STRUCTURES AND TRANSACTIONAL MEMORY. Tim Harris, 31 October 2012

NON-BLOCKING DATA STRUCTURES AND TRANSACTIONAL MEMORY. Tim Harris, 31 October 2012 NON-BLOCKING DATA STRUCTURES AND TRANSACTIONAL MEMORY Tim Harris, 31 October 2012 Lecture 6 Linearizability Lock-free progress properties Queues Reducing contention Explicit memory management Linearizability

More information

Milind Kulkarni Research Statement

Milind Kulkarni Research Statement Milind Kulkarni Research Statement With the increasing ubiquity of multicore processors, interest in parallel programming is again on the upswing. Over the past three decades, languages and compilers researchers

More information

The Encoding Complexity of Network Coding

The Encoding Complexity of Network Coding The Encoding Complexity of Network Coding Michael Langberg Alexander Sprintson Jehoshua Bruck California Institute of Technology Email: mikel,spalex,bruck @caltech.edu Abstract In the multicast network

More information

G Programming Languages - Fall 2012

G Programming Languages - Fall 2012 G22.2110-003 Programming Languages - Fall 2012 Lecture 2 Thomas Wies New York University Review Last week Programming Languages Overview Syntax and Semantics Grammars and Regular Expressions High-level

More information

UNIT:2. Process Management

UNIT:2. Process Management 1 UNIT:2 Process Management SYLLABUS 2.1 Process and Process management i. Process model overview ii. Programmers view of process iii. Process states 2.2 Process and Processor Scheduling i Scheduling Criteria

More information

Formal Specification and Verification

Formal 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 information

Object Ownership in Program Verification

Object Ownership in Program Verification Object Ownership in Program Verification Werner Dietl 1 and Peter Müller 2 1 University of Washington wmdietl@cs.washington.edu 2 ETH Zurich peter.mueller@inf.ethz.ch Abstract. Dealing with aliasing is

More information

1 Introduction. 3 Syntax

1 Introduction. 3 Syntax CS 6110 S18 Lecture 19 Typed λ-calculus 1 Introduction Type checking is a lightweight technique for proving simple properties of programs. Unlike theorem-proving techniques based on axiomatic semantics,

More information

Hierarchical Pointer Analysis for Distributed Programs

Hierarchical Pointer Analysis for Distributed Programs Hierarchical Pointer Analysis for Distributed Programs Amir Kamil Computer Science Division, University of California, Berkeley kamil@cs.berkeley.edu April 14, 2006 1 Introduction Many distributed, parallel

More information

2 nd Semester 2009/2010

2 nd Semester 2009/2010 Chapter 16: Concurrency Control Departamento de Engenharia Informática Instituto Superior Técnico 2 nd Semester 2009/2010 Slides baseados nos slides oficiais do livro Database System Concepts c Silberschatz,

More information

6.033: Fault Tolerance: Isolation Lecture 17 Katrina LaCurts,

6.033: Fault Tolerance: Isolation Lecture 17 Katrina LaCurts, 6.033: Fault Tolerance: Isolation Lecture 17 Katrina LaCurts, lacurts@mit.edu 0. Introduction - Last time: Atomicity via logging. We're good with atomicity now. - Today: Isolation - The problem: We have

More information

Summary: Open Questions:

Summary: Open Questions: Summary: The paper proposes an new parallelization technique, which provides dynamic runtime parallelization of loops from binary single-thread programs with minimal architectural change. The realization

More information

Cover Page. The handle holds various files of this Leiden University dissertation

Cover Page. The handle   holds various files of this Leiden University dissertation Cover Page The handle http://hdl.handle.net/1887/22891 holds various files of this Leiden University dissertation Author: Gouw, Stijn de Title: Combining monitoring with run-time assertion checking Issue

More information

Chapter 15 : Concurrency Control

Chapter 15 : Concurrency Control Chapter 15 : Concurrency Control What is concurrency? Multiple 'pieces of code' accessing the same data at the same time Key issue in multi-processor systems (i.e. most computers today) Key issue for parallel

More information

The Pointer Assertion Logic Engine

The Pointer Assertion Logic Engine The Pointer Assertion Logic Engine [PLDI 01] Anders Mφller Michael I. Schwartzbach Presented by K. Vikram Cornell University Introduction Pointer manipulation is hard Find bugs, optimize code General Approach

More information

Induction and Semantics in Dafny

Induction and Semantics in Dafny 15-414 Lecture 11 1 Instructor: Matt Fredrikson Induction and Semantics in Dafny TA: Ryan Wagner Encoding the syntax of Imp Recall the abstract syntax of Imp: a AExp ::= n Z x Var a 1 + a 2 b BExp ::=

More information

TRANSACTION PROCESSING CONCEPTS

TRANSACTION PROCESSING CONCEPTS 1 Transaction CHAPTER 9 TRANSACTION PROCESSING CONCEPTS A Transaction refers to a logical unit of work in DBMS, which comprises a set of DML statements that are to be executed atomically (indivisibly).

More information

Optimizing Closures in O(0) time

Optimizing Closures in O(0) time Optimizing Closures in O(0 time Andrew W. Keep Cisco Systems, Inc. Indiana Univeristy akeep@cisco.com Alex Hearn Indiana University adhearn@cs.indiana.edu R. Kent Dybvig Cisco Systems, Inc. Indiana University

More information

Linked Lists: The Role of Locking. Erez Petrank Technion

Linked Lists: The Role of Locking. Erez Petrank Technion Linked Lists: The Role of Locking Erez Petrank Technion Why Data Structures? Concurrent Data Structures are building blocks Used as libraries Construction principles apply broadly This Lecture Designing

More information

Formal Syntax and Semantics of Programming Languages

Formal Syntax and Semantics of Programming Languages Formal Syntax and Semantics of Programming Languages Mooly Sagiv Reference: Semantics with Applications Chapter 2 H. Nielson and F. Nielson http://www.daimi.au.dk/~bra8130/wiley_book/wiley.html The While

More information

CS 2112 Lecture 20 Synchronization 5 April 2012 Lecturer: Andrew Myers

CS 2112 Lecture 20 Synchronization 5 April 2012 Lecturer: Andrew Myers CS 2112 Lecture 20 Synchronization 5 April 2012 Lecturer: Andrew Myers 1 Critical sections and atomicity We have been seeing that sharing mutable objects between different threads is tricky We need some

More information

Incompatibility Dimensions and Integration of Atomic Commit Protocols

Incompatibility Dimensions and Integration of Atomic Commit Protocols The International Arab Journal of Information Technology, Vol. 5, No. 4, October 2008 381 Incompatibility Dimensions and Integration of Atomic Commit Protocols Yousef Al-Houmaily Department of Computer

More information

Lecture 1 Contracts : Principles of Imperative Computation (Fall 2018) Frank Pfenning

Lecture 1 Contracts : Principles of Imperative Computation (Fall 2018) Frank Pfenning Lecture 1 Contracts 15-122: Principles of Imperative Computation (Fall 2018) Frank Pfenning In these notes we review contracts, which we use to collectively denote function contracts, loop invariants,

More information

Advanced Databases. Lecture 9- Concurrency Control (continued) Masood Niazi Torshiz Islamic Azad University- Mashhad Branch

Advanced Databases. Lecture 9- Concurrency Control (continued) Masood Niazi Torshiz Islamic Azad University- Mashhad Branch Advanced Databases Lecture 9- Concurrency Control (continued) Masood Niazi Torshiz Islamic Azad University- Mashhad Branch www.mniazi.ir Multiple Granularity Allow data items to be of various sizes and

More information

Runtime assertion checking of multithreaded Java programs

Runtime assertion checking of multithreaded Java programs Master Thesis Runtime assertion checking of multithreaded Java programs An extension of the STROBE framework Author: Jorne Kandziora Supervisors: dr. M. Huisman dr. C.M. Bockisch M. Zaharieva-Stojanovski,

More information

15 418/618 Project Final Report Concurrent Lock free BST

15 418/618 Project Final Report Concurrent Lock free BST 15 418/618 Project Final Report Concurrent Lock free BST Names: Swapnil Pimpale, Romit Kudtarkar AndrewID: spimpale, rkudtark 1.0 SUMMARY We implemented two concurrent binary search trees (BSTs): a fine

More information

Chapter 12 : Concurrency Control

Chapter 12 : Concurrency Control Chapter 12 : Concurrency Control Chapter 12: Concurrency Control Lock-Based Protocols Timestamp-Based Protocols Validation-Based Protocols Multiple Granularity Multiversion Schemes Insert and Delete Operations

More information

Part 3: Beyond Reduction

Part 3: Beyond Reduction Lightweight Analyses For Reliable Concurrency Part 3: Beyond Reduction Stephen Freund Williams College joint work with Cormac Flanagan (UCSC), Shaz Qadeer (MSR) Busy Acquire Busy Acquire void busy_acquire()

More information

Qualifying Exam in Programming Languages and Compilers

Qualifying Exam in Programming Languages and Compilers Qualifying Exam in Programming Languages and Compilers University of Wisconsin Fall 1991 Instructions This exam contains nine questions, divided into two parts. All students taking the exam should answer

More information

Software Engineering using Formal Methods

Software 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 information

Transactional Interference-less Balanced Tree

Transactional Interference-less Balanced Tree Transactional Interference-less Balanced Tree Technical Report Ahmed Hassan, Roberto Palmieri, and Binoy Ravindran Virginia Tech, Blacksburg, VA, USA. Abstract. In this paper, we present TxCF-Tree, a balanced

More information

UNIT-IV TRANSACTION PROCESSING CONCEPTS

UNIT-IV TRANSACTION PROCESSING CONCEPTS 1 Transaction UNIT-IV TRANSACTION PROCESSING CONCEPTS A Transaction refers to a logical unit of work in DBMS, which comprises a set of DML statements that are to be executed atomically (indivisibly). Commit

More information

TVLA: A SYSTEM FOR GENERATING ABSTRACT INTERPRETERS*

TVLA: A SYSTEM FOR GENERATING ABSTRACT INTERPRETERS* TVLA: A SYSTEM FOR GENERATING ABSTRACT INTERPRETERS* Tal Lev-Ami, Roman Manevich, and Mooly Sagiv Tel Aviv University {tla@trivnet.com, {rumster,msagiv}@post.tau.ac.il} Abstract TVLA (Three-Valued-Logic

More information

PRINCIPLES OF COMPILER DESIGN UNIT I INTRODUCTION TO COMPILERS

PRINCIPLES OF COMPILER DESIGN UNIT I INTRODUCTION TO COMPILERS Objective PRINCIPLES OF COMPILER DESIGN UNIT I INTRODUCTION TO COMPILERS Explain what is meant by compiler. Explain how the compiler works. Describe various analysis of the source program. Describe the

More information

Lecture 1 Contracts. 1 A Mysterious Program : Principles of Imperative Computation (Spring 2018) Frank Pfenning

Lecture 1 Contracts. 1 A Mysterious Program : Principles of Imperative Computation (Spring 2018) Frank Pfenning Lecture 1 Contracts 15-122: Principles of Imperative Computation (Spring 2018) Frank Pfenning In these notes we review contracts, which we use to collectively denote function contracts, loop invariants,

More information

Software Engineering using Formal Methods

Software Engineering using Formal Methods Software Engineering using Formal Methods Introduction to Promela Wolfgang Ahrendt & Richard Bubel & Reiner Hähnle & Wojciech Mostowski 31 August 2011 SEFM: Promela /GU 110831 1 / 35 Towards Model Checking

More information

Lecture 21: Transactional Memory. Topics: consistency model recap, introduction to transactional memory

Lecture 21: Transactional Memory. Topics: consistency model recap, introduction to transactional memory Lecture 21: Transactional Memory Topics: consistency model recap, introduction to transactional memory 1 Example Programs Initially, A = B = 0 P1 P2 A = 1 B = 1 if (B == 0) if (A == 0) critical section

More information

Type Checking and Type Equality

Type Checking and Type Equality Type Checking and Type Equality Type systems are the biggest point of variation across programming languages. Even languages that look similar are often greatly different when it comes to their type systems.

More information

On the Complexity of Partially-Flow-Sensitive Alias Analysis

On the Complexity of Partially-Flow-Sensitive Alias Analysis On the Complexity of Partially-Flow-Sensitive Alias Analysis 13 N. RINETZKY Tel Aviv University G. RAMALINGAM Microsoft Research India M. SAGIV Tel Aviv University and E. YAHAV IBM T. J. Watson Research

More information

Automatic Scalable Atomicity via Semantic Locking

Automatic Scalable Atomicity via Semantic Locking Automatic Scalable Atomicity via Semantic Locking Guy Golan-Gueta Yahoo Labs, Israel ggolan@yahoo-inc.com G. Ramalingam Microsoft Research, India grama@microsoft.com Mooly Sagiv Tel Aviv University, Israel

More information

Reminder from last time

Reminder from last time Concurrent systems Lecture 5: Concurrency without shared data, composite operations and transactions, and serialisability DrRobert N. M. Watson 1 Reminder from last time Liveness properties Deadlock (requirements;

More information

Scaling Optimistic Concurrency Control by Approximately Partitioning the Certifier and Log

Scaling Optimistic Concurrency Control by Approximately Partitioning the Certifier and Log Scaling Optimistic Concurrency Control by Approximately Partitioning the Certifier and Log Philip A. Bernstein Microsoft Research Redmond, WA, USA phil.bernstein@microsoft.com Sudipto Das Microsoft Research

More information

Executive Summary. It is important for a Java Programmer to understand the power and limitations of concurrent programming in Java using threads.

Executive Summary. It is important for a Java Programmer to understand the power and limitations of concurrent programming in Java using threads. Executive Summary. It is important for a Java Programmer to understand the power and limitations of concurrent programming in Java using threads. Poor co-ordination that exists in threads on JVM is bottleneck

More information

State Machine Diagrams

State Machine Diagrams State Machine Diagrams Introduction A state machine diagram, models the dynamic aspects of the system by showing the flow of control from state to state for a particular class. 2 Introduction Whereas an

More information

Synchronization SPL/2010 SPL/20 1

Synchronization SPL/2010 SPL/20 1 Synchronization 1 Overview synchronization mechanisms in modern RTEs concurrency issues places where synchronization is needed structural ways (design patterns) for exclusive access 2 Overview synchronization

More information

Parallel linked lists

Parallel linked lists Parallel linked lists Lecture 10 of TDA384/DIT391 (Principles of Conent Programming) Carlo A. Furia Chalmers University of Technology University of Gothenburg SP3 2017/2018 Today s menu The burden of locking

More information

Thirty one Problems in the Semantics of UML 1.3 Dynamics

Thirty one Problems in the Semantics of UML 1.3 Dynamics Thirty one Problems in the Semantics of UML 1.3 Dynamics G. Reggio R.J. Wieringa September 14, 1999 1 Introduction In this discussion paper we list a number of problems we found with the current dynamic

More information

Written Presentation: JoCaml, a Language for Concurrent Distributed and Mobile Programming

Written Presentation: JoCaml, a Language for Concurrent Distributed and Mobile Programming Written Presentation: JoCaml, a Language for Concurrent Distributed and Mobile Programming Nicolas Bettenburg 1 Universitaet des Saarlandes, D-66041 Saarbruecken, nicbet@studcs.uni-sb.de Abstract. As traditional

More information

Lecture 22 Concurrency Control Part 2

Lecture 22 Concurrency Control Part 2 CMSC 461, Database Management Systems Spring 2018 Lecture 22 Concurrency Control Part 2 These slides are based on Database System Concepts 6 th edition book (whereas some quotes and figures are used from

More information

Reasoning About Lock Placements

Reasoning About Lock Placements Reasoning About Lock Placements Peter Hawkins, Alex Aiken, Kathleen Fisher, Martin Rinard, and Mooly Sagiv Stanford University, Tufts University, MIT, Tel Aviv University Abstract. A lock placement describes,

More information

Programming Languages Third Edition. Chapter 7 Basic Semantics

Programming Languages Third Edition. Chapter 7 Basic Semantics Programming Languages Third Edition Chapter 7 Basic Semantics Objectives Understand attributes, binding, and semantic functions Understand declarations, blocks, and scope Learn how to construct a symbol

More information

Linearizable Iterators

Linearizable Iterators Linearizable Iterators Supervised by Maurice Herlihy Abstract Petrank et. al. [5] provide a construction of lock-free, linearizable iterators for lock-free linked lists. We consider the problem of extending

More information

12 Abstract Data Types

12 Abstract Data Types 12 Abstract Data Types 12.1 Foundations of Computer Science Cengage Learning Objectives After studying this chapter, the student should be able to: Define the concept of an abstract data type (ADT). Define

More information

Goal of Concurrency Control. Concurrency Control. Example. Solution 1. Solution 2. Solution 3

Goal of Concurrency Control. Concurrency Control. Example. Solution 1. Solution 2. Solution 3 Goal of Concurrency Control Concurrency Control Transactions should be executed so that it is as though they executed in some serial order Also called Isolation or Serializability Weaker variants also

More information

CS4215 Programming Language Implementation. Martin Henz

CS4215 Programming Language Implementation. Martin Henz CS4215 Programming Language Implementation Martin Henz Thursday 15 March, 2012 2 Chapter 11 impl: A Simple Imperative Language 11.1 Introduction So far, we considered only languages, in which an identifier

More information

Applications of Formal Verification

Applications of Formal Verification Applications of Formal Verification Model Checking: Introduction to PROMELA Prof. Dr. Bernhard Beckert Dr. Vladimir Klebanov SS 2010 KIT INSTITUT FÜR THEORETISCHE INFORMATIK KIT University of the State

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

A Causality-Based Runtime Check for (Rollback) Atomicity

A Causality-Based Runtime Check for (Rollback) Atomicity A Causality-Based Runtime Check for (Rollback) Atomicity Serdar Tasiran Koc University Istanbul, Turkey Tayfun Elmas Koc University Istanbul, Turkey RV 2007 March 13, 2007 Outline This paper: Define rollback

More information

High-Level Small-Step Operational Semantics for Software Transactions

High-Level Small-Step Operational Semantics for Software Transactions High-Level Small-Step Operational Semantics for Software Transactions Katherine F. Moore Dan Grossman The University of Washington Motivating Our Approach Operational Semantics Model key programming-language

More information

Linearizability of Persistent Memory Objects

Linearizability of Persistent Memory Objects Linearizability of Persistent Memory Objects Michael L. Scott Joint work with Joseph Izraelevitz & Hammurabi Mendes www.cs.rochester.edu/research/synchronization/ Compiler-Driven Performance Workshop,

More information

Chapter 4 Defining Classes I

Chapter 4 Defining Classes I Chapter 4 Defining Classes I This chapter introduces the idea that students can create their own classes and therefore their own objects. Introduced is the idea of methods and instance variables as the

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