PROCESS-ORIENTED PATTERNS FOR CONCURRENT SOFTWARE ENGINEERING A THESIS SUBMITTED TO THE UNIVERSITY OF KENT IN THE SUBJECT OF COMPUTER SCIENCE FOR THE DEGREE OF DOCTOR OF PHILOSOPHY. By Adam T. Sampson 2008 Abstract Concurrency is unavoidable in modern software development, owing to the increasing complexity of computer systems and the widespread use of parallel computer hard- ware. Conventional approaches to concurrency are fraught with danger: in particular, uncontrolled access to shared resources, poor scalability and the inability of the pro- grammer to reason about the correctness of a program. Process-oriented programming is a software design approach that offers solutions to many of these problems. A process-oriented program is constructed as a network of isolated, concurrent processes that interact only using synchronisation objects such as channels and barriers. Using techniques drawn from CSP and the p-calculus, de- sign rules can be constructed that enable the programmer to easily build systems with known safety properties. Since process-oriented programs expose by their nature a high degree of explicit concurrency, they can be efficiently distributed across multiple processors and clusters of machines. This thesis describes a pattern language for the engineering of process-oriented pro- grams. Design patterns describe reusable, adaptable solutions to common problems that may arise during the design and development of a system. A pattern language serves the dual purposes of documenting the proven design solutions developed by a community, and providing a common technical vocabulary. The patterns described in this thesis are drawn from a variety of existing process- oriented real-world applications, and have been used to construct new applications in fields such as embedded systems, multimedia processing, and complex systems simu- lation. While much of this work has been conducted using the occam-p programming language, the patterns—and the new language and library facilities they inform—are applicable to process-oriented systems built in any language. ii Acknowledgements I would like to thank the members of the Programming Languages and Systems group at the University of Kent, those involved in the TUNA and CoSMoS projects, and the Communicating Process Architectures community at large for the many interesting and fruitful discussions that we have had during the course of this work—and for their willingness to let me use their applications as case studies. This work was supported by EPSRC: both directly through a research studentship (EP/P50029X/1), and through case studies from the TUNA (EP/C516966/1), CoSMoS (EP/E049419/1) and RMoX (EP/D061822/1) projects. iii Contents Abstract ii Acknowledgements iii Contents iv List of Figures viii 1 Introduction 1 1.1 Roadmap . 2 1.2 Conventions . 3 2 Background 4 2.1 Process-Oriented Programming . 4 2.1.1 Concurrency . 4 2.1.2 Isolation . 5 2.1.3 Communication . 6 2.1.4 Composition . 6 2.1.5 Reasoning . 7 2.1.6 POP and Other Paradigms . 7 2.1.7 Problems with POP . 8 2.2 Basic Facilities . 8 2.2.1 Processes . 9 2.2.2 Channels . 12 2.2.3 Barriers . 16 2.2.4 Synchronisation Objects . 18 2.2.5 Mobility . 21 2.3 Process-Oriented Environments . 24 2.3.1 Implementing Processes . 24 2.3.2 occam . 27 2.3.3 From Newsqueak to Go . 29 2.3.4 Erlang . 31 2.3.5 Java . 32 2.3.6 C# . 33 2.3.7 Python . 34 2.3.8 Haskell . 36 2.4 Design Patterns . 39 2.4.1 “A Pattern Language” . 39 iv 2.4.2 “Design Patterns” . 40 2.4.3 Other Concurrent Patterns . 41 2.5 Process Diagrams . 42 2.5.1 The Syntax of Process Diagrams . 43 2.5.2 Drawing Process Diagrams . 44 2.5.3 Other Kinds of Diagrams . 45 3 Case Studies 47 3.1 Flightsim . 47 3.2 occam-X11 . 50 3.3 KRoC . 51 3.3.1 The Module System . 53 3.3.2 General Utilities . 53 3.3.3 Graphics . 54 3.3.4 Operating System Bindings . 54 3.3.5 Distributed Application Support . 55 3.4 RMoX . 56 3.4.1 Substrates . 57 3.4.2 Network Stack . 57 3.4.3 USB Stack . 60 3.5 TUNA . 61 3.5.1 Life . 61 3.5.2 Simulating Life . 63 3.5.3 Blood Clotting . 66 3.6 occvid . 68 3.7 LOVE . 70 3.8 Occade . 77 3.8.1 Implementation . 79 3.8.2 Sending Events . 80 3.8.3 Future Directions . 80 3.9 CoSMoS . 81 3.9.1 Occoids . 83 3.9.2 Distributed Simulations . 86 3.9.3 Generalised Space Model . 90 3.9.4 Ccoids . 91 3.10 Plumbing . 92 4 Process-Oriented Patterns 96 4.1 Process Patterns . 96 4.1.1 Producer and Consumer . 97 4.1.2 Black Hole . 97 4.1.3 Filter . 98 4.1.4 Buffer . 99 4.1.5 Glue . 102 4.1.6 Valve . 102 4.1.7 Grouper and Ungrouper . 104 4.1.8 Merge . 105 4.1.9 Collector . 106 v 4.1.10 Delta . 107 4.1.11 Distributor . 108 4.1.12 Factory . 108 4.1.13 Oracle . 109 4.2 Patterns of Structure . 110 4.2.1 Pipeline . 110 4.2.2 Fan-Out . 113 4.2.3 Location . 115 4.2.4 Ring . 116 4.2.5 Client-Server . 118 4.2.6 Farm . 121 4.2.7 Intermediary . 123 4.3 Patterns of Cooperation . 124 4.3.1 Acknowledgement . 124 4.3.2 I/O-SEQ and I/O-PAR . 125 4.3.3 Phases . 127 4.3.4 Clock . 128 4.3.5 Lazy Updates . 129 4.3.6 Just In Time . 130 4.3.7 Messenger . 133 4.4 Patterns of Mobility . ..
Details
-
File Typepdf
-
Upload Time-
-
Content LanguagesEnglish
-
Upload UserAnonymous/Not logged-in
-
File Pages209 Page
-
File Size-