Copyright by David Wilson Kitchin 2013
Total Page:16
File Type:pdf, Size:1020Kb
Copyright by David Wilson Kitchin 2013 The Dissertation Committee for David Wilson Kitchin certifies that this is the approved version of the following dissertation: Orchestration and Atomicity Committee: Jayadev Misra, Supervisor William Cook, Supervisor Don Batory Keshav Pingali Dan Grossman Orchestration and Atomicity by David Wilson Kitchin, B.S.C.S. Dissertation Presented to the Faculty of the Graduate School of The University of Texas at Austin in Partial Fulfillment of the Requirements for the Degree of Doctor of Philosophy The University of Texas at Austin August 2013 This dissertation is dedicated to my mother and father, whose boundless love and support have made all of this possible. Acknowledgments First, I must express my gratitude to my best friend, Kristine Butler, without whose unwavering support I could never have completed this journey. I am also deeply grateful to my good friends Chris Lundberg and Mercedes Vaughn, who have given me a place to call home for the past three years, and whose wonderful companionship I have continually enjoyed. I am thankful every day for my loving, quirky, and brilliant family. I am grateful for my excellent advisor and mentor, Jay Misra, so much so that I am not sure how to put it into words. We have worked together for eight years, and our collaborations have always been productive and enjoyable. He has always treated me with respect, even when I have ignored his guidance or strained his patience. Jay is a great scholar, and I look forward to opportunities to work with him again in the future. My gratitude extends to all of the members of the Orc Research Group, past and present, who have each in their own way made the group a lively and interesting hub of great ideas and vigorous discussion. My current co-conspirators, John Thywissen and Arthur Peters, are at the top of that list. I would like to thank the other four members of my dissertation commit- tee | William Cook, Don Batory, Keshav Pingali, and Dan Grossman | for their patience throughout my long and difficult writing process. I would like to thank all of the organizers, lecturers, and participants who v attended the Summer School on Language-Based Techniques for Concurrent and Distributed Software at the University of Oregon, in 2006. That confluence of great ideas and talented minds gave me the initial spark that led, over the course of seven years, to the development of Ora. I am indebted to Frank Pfenning, who managed to teach me enough about programming language theory in a single semester to last me through a decade of exploration and research, with more still to come. I am also indebted to Steven Rudich, who managed to teach me enough about the magic of computer science in a single semester to last me through a dozen years of programming and proving, with more still to come. And I am indebted to a whole host of other excellent teachers for their innumerable lessons: Stephen Gregory, Meg Curran, Richard Monroe, Paul Jourcin, Mark Stehlik, Klaus Sutner, Patricia Carpenter, and so many others. Lastly, I would like to thank Zo¨eKeating for her beautiful music, which has helped me to endure a long journey and to remain an optimist throughout. David Wilson Kitchin The University of Texas at Austin August 2013 vi Orchestration and Atomicity Publication No. David Wilson Kitchin, Ph.D. The University of Texas at Austin, 2013 Supervisor: Jayadev Misra Co-supervisor: William Cook This dissertation presents the concurrent programming language Ora, an extension of the Orc orchestration language with the capability to execute transactions. A new formal definition of transactions is given, in terms of two complementary properties: atomicity and coatomicity. These properties are described in terms of a partial order of events, rather than as properties of a totally ordered program trace. Atomicity and coatomicity are ensured in Ora programs by a novel algorithm for multiversion concurrency control. vii Contents Acknowledgments v Abstract vii Chapter 1 Introduction 1 1.1 Controlling Structured Concurrency . .1 1.2 Contributions of This Thesis . .3 Chapter 2 Orc 6 2.1 Orc as a Process Calculus . .6 2.1.1 Values . .7 2.1.2 Sites . .7 2.1.3 Stop . .8 2.1.4 Combinators . .8 2.1.5 Functions . .9 2.2 Orc as a Programming Language . 10 2.2.1 val ................................ 11 2.2.2 Operators . 11 2.2.3 Conditionals . 11 2.2.4 Flattening . 12 2.2.5 Structured Data . 13 2.2.6 Patterns . 13 2.2.7 Join . 14 2.2.8 Enhanced Function Definitions . 14 2.2.9 Mutable State . 15 viii 2.3 Formal Semantics . 17 2.3.1 Syntax . 18 2.3.2 Expression Semantics . 19 2.3.3 Environment Semantics . 21 2.3.4 Site Semantics . 25 Chapter 3 A Survey of Concurrency Control Methods 32 3.1 Locks . 33 3.2 Messages . 35 3.3 Transactions . 37 3.3.1 New Approaches to Transactional Memory . 38 3.3.2 Limitations of Transactional Memory . 40 Chapter 4 A General Principle of Concurrency Control 42 4.1 Representation of Concurrent Events . 43 4.1.1 Causality in Programs . 44 4.1.2 Causality at Sites . 45 4.2 Controlling Concurrent Events . 47 4.2.1 Defining Atoms . 53 4.2.2 Examples . 53 4.2.3 Redefining Atoms . 75 4.3 Related Work . 76 Chapter 5 Ora 78 5.1 The atomic combinator . 79 5.1.1 Unary atomic .......................... 79 5.1.2 The Abort Site . 79 5.2 Atomic Choice . 81 5.3 Writing Programs in Ora . 85 5.3.1 Account Transfer . 85 5.3.2 Permutation . 86 5.3.3 Dining Philosophers . 88 5.3.4 Atomic Timeout . 90 5.3.5 Retry Tactics . 91 5.3.6 Job Priority . 93 ix Chapter 6 Implementing Ora 95 6.1 Transactions . 96 6.1.1 Transactional Sites . 96 6.2 Observation . 98 6.2.1 Version Information . 99 6.2.2 Observing States . 100 6.2.3 Blocked Calls . 104 6.2.4 Tracking Causality . 105 6.2.5 Relationship to Distributed Snapshot . 107 6.3 Merging . 108 6.3.1 Resource Versions . 109 6.3.2 Commit . 110 Chapter 7 Formal Semantics of Ora 114 7.1 Syntax of Ora . 116 7.2 Internal Semantics . 118 7.2.1 Halting Judgment . 118 7.2.2 Execution Judgment . 120 7.3 External Semantics . 129 7.3.1 Environment and Event Grammar . 129 7.3.2 Site Transitions . 130 7.3.3 External Transitions . 131 7.4 Environment Operations . 135 7.4.1 Environment Filtering and Mapping . 135 7.4.2 Image . 136 7.4.3 State . 136 7.5 Observer Semantics . 138 7.5.1 Snapshot Judgment . 138 7.5.2 Boundary Judgment . 139 7.5.3 Observe Judgment . 140 7.6 Commit Semantics . 141 7.6.1 Merge Operation . 141 7.6.2 Graft Judgment . 142 7.6.3 Participants . 142 x 7.6.4 Boundary? Judgment . 143 7.6.5 Commit Judgment . 143 7.6.6 Conflict Judgment . 144 7.6.7 The Abort site . 144 7.7 Resource Semantics . 146 7.7.1 Guard . 146 7.7.2 Ref . 148 7.7.3 Cell . 150 7.7.4 Channel . 151 7.7.5 Semaphore . 154 Chapter 8 Formal Properties of Ora 156 8.1 Atomicity and Coatomicity . 156 8.1.1 Notation . 156 8.1.2 Internal Causality . 157 8.1.3 External Causality . 158 8.1.4 Virtual Causality . 159 8.1.5 Relevance . 162 8.1.6 The Bubble Conjecture . 163 8.2 Consistency . 163 Chapter 9 Discussion 166 9.1 Choosing Resources . 166 9.2 Incorporating Time . 167 9.3 Blocking . ..