4.2.3 Advantages and Limitations of the Π Calculus
Total Page:16
File Type:pdf, Size:1020Kb
DynamiTE: A 21st-Century Framework for Concurrent Component-Based Design Andrew John Hughes 11th of December 2009 This thesis is submitted for the degree of Doctor of Philosophy Department of Computer Science University of Sheffield Abstract The free ride for software developers is over. In the past, computer programs have increased in performance simply by running on new hardware with ever increasing clock speeds. Now, however, this line of development has reached its end and chip designers are producing new processors, not with faster clocks, but with more cores. To take advantage of the speed increases offered by these new products, applications need to be redesigned with parallel processing firmly in mind. The problem is that mainstream designs are still inherently sequential. Concur- rency tends to be an afterthought that may be useful to gain a performance boost, not an essential part of the design process. The current vogue for object-oriented designs tends to also have the side-effect of making them heavily data-oriented which doesn’t scale well; each shared element of data has to be protected from simultane- ous access, resulting in operations becoming sequential again. In addition, the usual methods for protecting data tend to be very low-level and error-prone. In this thesis, we introduce a new design method whereby applications are con- structed from small sequential tasks connected by intercommunication primitives. Our approach is based on a two-stage process; first, the individual tasks are cre- ated as independent entities and tested with appropriate inputs, then secondly, the communication infrastructure between them is developed. We provide support for the latter via the DynamiTE framework, which allows the interactions to be defined using the terms of a process calculus. Depending on the developer’s background, they can treat this as just another API, as a design pattern or as an algebraic ex- pression which can be property checked for issues such as deadlocks. Either way, the communication layer can be developed, tested and evaluated separately from the tasks once it is known how the tasks will interface with one another. To supplement DynamiTE, we define our own process calculus, Nomadic Time, using a carefully chosen novel selection of constructs. Among the features of the calculus are the ability to perform communication both locally (one-to-one) and globally (one-to-many), and the flexibility to change the location of tasks during execution. Security is paramount to the design of Nomadic Time and migratory operations can be limited in two ways; by simple enumeration of possibilities or by the optional typing of constructs to allow restriction on a task-by-task basis. While it can’t eradicate all the problems inherent in designing concurrent appli- cations, DynamiTE can make things easier by reducing the dependency on shared resources and enhancing the reusability of concurrent components. iv Acknowledgements This work was supported by a grant from the Engineering and Physical Sciences Research Council (EPSRC) for the first three years. Thanks to everyone else for keeping it bonkers! Contents 1 Introduction 1 1.1 Rationale ................................. 1 1.2 StatusQuo ................................ 2 1.2.1 Multiprogramming . 2 1.2.2 Resource Contention . 3 1.2.3 SemaphoresandMonitors . 5 1.2.4 Interprocess Communication . 11 1.3 OurProposedSolution . 14 1.3.1 A Prototypical Application . 16 1.4 ContributionstoKnowledge . 18 1.5 StructureoftheThesis . 20 2 Algebraic Process Calculi 24 2.1 Introduction................................ 24 2.2 The Calculus of Communicating Systems . 26 2.2.1 TheDiningPhilosophers . 29 2.3 Advantages and Limitations of CCS . 31 2.4 Conclusion................................. 33 3 Global Synchronisation 35 3.1 Introduction................................ 35 3.2 TemporalProcessLanguage(TPL) . 35 3.3 ExtendingTPL .............................. 37 3.4 The Calculus of Synchronous Encapsulation . 37 3.4.1 Timeouts ............................. 38 3.4.2 ClockStoppingandInsistency . 39 3.4.3 Encapsulation........................... 40 3.5 Conclusion................................. 41 v vi CONTENTS 4 Mobility 44 4.1 Introduction................................ 44 4.2 ScopeMobility .............................. 45 4.2.1 The π Calculus .......................... 45 4.2.2 Variants of the π Calculus .................... 46 4.2.3 Advantages and Limitations of the π Calculus . 52 4.3 DistributionandMigration. 53 4.3.1 The Distributed Join Calculus . 58 4.3.2 The Ambient Calculus . 59 4.3.3 Variants of the Ambient Calculus . 62 4.3.4 Advantages and Limitations of the Ambient Calculus . 65 4.3.5 PSystems............................. 65 4.4 ComparingModellingApproaches . 68 4.5 Bigraphs.................................. 71 4.6 Conclusion................................. 72 5 Nomadic Time 74 5.1 Introduction................................ 74 5.2 LocalisingtheCalculus. 76 5.3 AddingMobility.............................. 78 5.3.1 LocationMobility. 80 5.3.2 ProcessMobility ......................... 83 5.4 Bouncers.................................. 84 5.5 TheSemantics............................... 85 5.6 ASimpleExample ............................ 91 5.7 A Prototypical Application in NT . 95 5.8 Conclusion................................. 98 6 The DynamiTE Framework 100 6.1 Introduction................................100 6.2 WhyJava?.................................101 6.2.1 Concurrency Provision . 103 6.2.2 Popularity.............................108 6.3 MappingTheorytoPracticality . 109 6.4 TheContextoftheCalculus . .114 6.4.1 ThePluginAbstraction . .116 6.5 TheEvolverFramework . .118 6.6 A Prototypical Application in DynamiTE . 123 6.7 RelatedWork ...............................131 6.7.1 Obliq................................131 6.7.2 NomadicPict ...........................134 CONTENTS vii 6.7.3 The Safe Ambients Abstract Machine . 135 6.7.4 JavaSeal ..............................136 6.8 Conclusion.................................138 7 Typed Nomadic Time 140 7.1 Introduction................................140 7.2 ExistingTypedCalculi . .140 7.2.1 Type Systems for the π Calculus ................141 7.2.2 Type Systems for the Ambient Calculus . 143 7.3 Mobility Types for Nomadic Time . 145 7.4 DynamiTEandtheTypeSystem . .149 7.5 TypedMusicalChairs . .153 7.6 Conclusion.................................154 8 Contributions and Future Work 156 8.1 OurContributions ............................156 8.2 FutureWork................................160 8.2.1 NomadicTime ..........................160 8.2.2 DynamiTE ............................162 8.2.3 TheTypeSystem.........................163 8.2.4 OtherApplications . .164 Bibliography 165 A Progress 174 B Preservation 178 List of Figures 1.1 The Traditional Software Development Process . 16 1.2 DynamiTE Variant of the Software Development Process . 16 1.3 Structure of the Prototypical Application . 18 2.1 Graph of a.0 a.0............................. 28 | 2.2 Graph of a.0+ a.0 ............................ 28 4.1 Spatial diagram of m[in n.out n.P ] n[]................. 60 4.2 Spatial diagram of n[m[out n.P ]] ....................| 60 4.3 Spatial diagram of m[P ] n[]....................... 60 4.4 ExamplePSystem ............................| 67 5.1 Derivation of Nomadic Time . 75 5.2 Clock Hiding in n[E m[F k[G]{σ}]{ρ}]{γ} ............... 78 5.3 TheMusicalChairsEnvironment| | . 92 7.1 Derivation of Typed Nomadic Time . 145 viii List of Tables 2.1 CCSSemantics .............................. 29 3.1 CaSESemantics.............................. 42 3.2 Derivation of CaSE from CCS . 43 4.1 LCCSDynamicSOSRules. 54 5.1 Feature Summary from the Literature Survey . 75 5.2 CoreSemantics .............................. 87 5.3 MobilitySemantics ............................ 88 5.4 StructuralCongruenceLaws . 88 5.5 Derivation of Nomadic Time from CaSE . 89 5.6 Summary of Processes and Derived Syntax for Musical Chairs . 93 6.1 Translation Schema from NT to DynamiTE Process Subclasses . 110 6.2 Translation Schema from NT to DynamiTE Classes . 110 7.1 Typing Rules from (Sangiorgi, 2002) . 143 7.2 Types ...................................147 7.3 TimeoutTypes ..............................147 7.4 TheBouncerType ............................147 7.5 MobilityTypes ..............................148 7.6 StructuralCongruenceLawswithTypes . 149 ix Chapter 1 Introduction 1.1 Rationale Recent changes in the direction of computer hardware development have created an impasse in the domain of software engineering. Over the past few years, new microprocessors have not seen the same increase in clock speed that has prevailed over previous decades. Instead, the use of multiple ‘cores’ has become common, due largely to physical limitations which prevent the individual elements of a single processor core becoming any smaller. As a result, the performance benefits of these new processors arise not from being able to execute a single task faster than before, but from the parallel execution of many such tasks. However, this leads to a problem. The existing dominant methods for designing software systems are inherently sequential. Current imperative and object-oriented programming languages are still founded on the principles of early computational models, such as the Turing machine (Turing, 1936). These take an idealised view of events where they always occur sequentially and in isolation. Programs are thus still effectively written as a sequence of reads and writes to a form of memory. The problem