THE ARCHITECTURE of CONCURRENT PROGRAMS Prentice-Hall Series in Automatic Computation
Total Page:16
File Type:pdf, Size:1020Kb
THE ARCHITECTURE OF CONCURRENT PROGRAMS Prentice-Hall Series in Automatic Computation AHO, ed., Currents in the Theory of Computing AHO and ULLMAN, The Theory of Parsing, Translation, and Compiling, Volume I: Parsing; Volume II: Compiling ANDREE, Computer Programming: Techniques, Analysis, and Mathematics ANSELONE, Collectively Compact Operator Approximation Theory and Applications to Integral Equations AVRIEL, Nonlinear Programming: Analysis and Methods BENNETT, JR., Scientific and Engineering Problem.Solving with the Computer BLAAUW, Digital System Implementation BLUMENTHAL, Management Information Systems BRENT, Algorithms for Minimization without Derivatives BRINCH HANSEN, The Architecture of Concurrent Programs BRINCH HANSEN, Operating System Principles BRZOZOWSKI and YOELL, Digital Networks COFFMAN and DENNING, Operating Systems Theory CRESS, et al., FORTRAN IV with WATFOR and WATFIV DAHLQUIST, BJORCK, and ANDERSON, Numerical Methods DANIEL, The Approximate Minimization of Functionals DEO, Graph Theory with Applications to Engineering and Computer Science DESMONDE, Computers and Their Uses, 2nd ed. DIJKSTRA, A Discipline of Programming DRUMMOND, Evaluation and Measurement Techniques for Digital Computer Systems EC KHOUSE, Minicomputer Systems: Organization and Programming (PDP-11) FIKE, Computer Evaluation of Mathematical Functions FIKE, PL /1 for Scientific Programmers FORSYTHE, MALCOLM, and MOLLER, Computer Methods for Mathematical Computations FORSYTHE and MOLLER, Computer Solution of Linear Algebraic Systems GEAR, Numerical Initial Value Problems in Ordinary Differential Equations GILL, Applied Algebra for the Computer Sciences GORDON, System Simulation GRISWOLD, String and List Processing in SNOBOL4: Techniques and Applications HANSEN, A Table of Series and Products HARTMANIS and STEARNS, Algebraic Structure Theory of Sequential Machines HILBURN and JULICH, Microcomputers/Microprocessor: Hardware, Software, and Applications HUGHES and MICHTOM, A Structured Approach to Programming JACOBY, et al., Iterative Methods for Nonlinear Optimization Problems JOHNSON, System Structure in Data, Programs, and Computers KIVIAT, et al., The SIMSCRIPT II Programming Language LAWSON and HANSON, Solving Least Squares Problems LO RIN, Parallelism in Hardware and Software: Real and A pparen t Concurrency LOUDEN and LEDIN, Programming the IBM 1130, 2nd ed. MARTIN, Communications Satellite Systems MARTIN, Computer Data-Base Organization, 2nd ed. MARTIN, Design of Man-Computer Dialogues LIBRARY MARTIN, Design of Real-Time Computer Systems MARTIN, Future Developments in Telecommunications, 2nd ed. MARTIN, Principles of Data-Base Management MARTIN, Programming Real-Time Computing Systems MARTIN, Security, Accuracy, and Privacy in Computer Systems MARTIN, Systems Analysis for Data Transmission MARTIN, Telecommunications and the Computer, 2nd ed. MARTIN, Teleprocessing Network Organization MARTIN and NORMAN, The Computerized Society MCKEEMAN, et al., A Compiler Generator MEYERS, Time-Sharing Computation in the Social Sciences MINSKY~ Computation: Finite and Infinite Machines NIEVERGELT, et al., Computer Approaches to Mathematical Problems PLANE and MCMILLAN, Discrete Optimization POLIVKA and PAKIN, APL: The Language and Its Usage PRITSKER and KIVIAT, Simulation with GASP II: A FORTRAN-based Simulation Language PYLYSHYN, ed., Perspectives on the Computer Revolution RICH, Internal Sorting Methods Illustrated with PL / LPrograms RUDD, Assembly Language Programming and the IBM 360 and 370 Computers SACKMANN and CITRENBAUM, eds., On-Line Planning: Towards Creative Problem-Solving SALTON, ed., The SMART Retrieval System: Experiments in Automatic Document Processing SAMMET, Programming Languages: History and Fundamentals SCHAEFER, A Mathematical Theory of Global Program Optimization SCHULTZ, Spline Analysis SCHWART Z, et al., Numerical Analysis of Symmetric Matrices SHAH, Engineering Simulation Using Small Scientific Computers SHAW, :The Logical Design of Operating Systems SHERMAN, Techniques in Computer Programming SIMON and SIKLOSSY, eds., Representation and Meaning: Experiments with Information Processing Systems STERBENZ, Floating-Point Computation STOUTEMYER, PL /1 Programming for Engineering and Science STRANG and FIX, An Analysis of the Finite Element Method STROUD, Approximate Calculation of Multiple Integrals TANEN BAUM, Structured Computer Organization TAVISS, ed., The Computer Impact UHR, Pattern Recognition, Learning, and Thought: Computer-Programmed Models of Higher Mental Processes VAN TASSEL, Computer Security Management VARGA, Matrix Iterative Analysis WAITE, Implementing Software for Non-Numeric Application WILKINSON, Rounding Errors in Algebraic Processes WIRTH, Algorithms + Data Structures = Programs WIRTH, Systematic Programming: An Introduction YEH, ed., Applied Computation Theory: Analysis, Design, Modeling To my father THE ARCHITECTURE OF CONCURRENT PROGRAMS PER BRINCH HANSEN University of Southern California M 4,1 L Li67pA,9~ PRENTICE-HALL, INC. Englewood Cliffs, New Jersey 07632 Library of Congress Cataloging in Publication Data Brinch Hansen, Per, The architecture of concurrent programs. (Prentice-Hall series in automatic computation) Summary in Danish. Bibliography: p. Includes index. 1. Concurrent Pascal (Computer programming language) 2. Operating systems (Computers) I. Title. QA76.73.C65B73 1977 001.6'424 77-4901 ISBN 0-13-044628-9 73 ,C 5 / 77 C,I © 1977 by Prentice-Hall, Inc., Englewood Cliffs, New Jersey 07632 All rights reserved. No part of this book may be reproduced in any form, by mimeography or by any means, without permission in writing from the publisher. 109876543 Printed in the United States of America PRENTICE-HALL INTERNATIONAL, INC., London PRENTICE-HALL OF AUSTRALIA PTY. LTD., Sydney PRENTICE-HALL OF CANADA, LTD., Toronto PRENTICE-HALL OF INDIA PRIVATE LIMITED, New Delhi PRENTICE-HALL OF JAPAN, INC., Tokyo PRENTICE-HALL OF SOUTH EAST ASIA PTE. LTD., Singapore WHITEHALL BOOKS LIMITED, Wellington, New Zealand CONTENTS PROGRAMMING TOOLS 1. DESIGN PRINCIPLES 3 "j 1.1. Program quality 3 1.2. Simplicity 4 1.3. Reliability 6 1.4. Adaptability 8 1.5. Portability 9 1.6. Efficiency 9 1.7. Generality 10 1.8. Conclusion 11 1.9. Literature 11 2. PROGRAMMING CONCEPTS 15 2.1. Concurrent processes 16 2.2. Private data 17 2.3. Peripherals 19 .... 2.4. Shai-ed data 19 2.5. Access rights 21 2.6. Abstract data types 23 2.7. Hierarchical structure 25 vii viii CONTENTS 3. SEQUENTIAL PASCAL 29 3.1. Program structure 30 3.2. Constants and variables 31 3.3. Simple data types 33 3.4. Structured data types 36 3.5. Routines 40 3.6. Scope rules 41 3.7. Type checking 42 3.8. Literature 45 4. CONCURRENT PASCAL 47 4.1. Input]output 47 4.2. Processes 49 4.3. Monitors 52 4.4. Queues 54 4.5. Classes 54 4.6. A complete program 57 4.7. Execution times 62 4.8. Conclusion 63 4.9. Literature 65 CONCURRENT PROGRAMS 67 5. THE SOLO OPERATING SYSTEM 69 5.1. Overview 69 5.2. Job interface 80 5.3. Processes, monitors, and classes 98 5.4. Disk scheduling 142 5.5 List of Solo components 147 6. THE JOB STREAM SYSTEM 148 6.1. Function and performance 148 6.2. Sequential programs and files 153 6.3. Concurrent program 166 6.4. Final remarks 186 6.5. List of Job stream components 187 7. A REAL-TIME SCHEDULER 189 7.1. Purpose and design 189 7.2. Programming 197 7.3. Testing 214 7.4. Final remarks 226 7.5. List of Real-time components 227 CONTENTS ix LANGUAGE DETAILS 229 8. CONCURRENT PASCAL REPORT 231 8.1. Introduction 231 8.2. Syntax graphs 232 8.3. Character set 232 8.4. Basic symbols 233 8.5. Blocks 235 8.6. Constants 235 8.7. Types 236 8.8. Variables 246 8.9. Expressions 249 8.10. Statements 250 8.11. Routines 251 8.12. Queues 255 8.13. Scope rules 256 8.14. Concurrent programs 257 8.15. PDP 11/45 system 257 8.16. ASCII character set 267 8.17. Index of report 268 9. CONCURRENT PASCAL MACHINE 271 9.1. Store allocation 271 9.2. Code interpretation 278 9.3. Kernel 283 9.4. Compiler 293 THE NEXT STEP 298 REFERENCES 301 LIST OF PROGRAM COMPONENTS 304 DANISH SUMMARY 307 INDEX 311 PREFACE CONCURRENT PROGRAMMING This book describes a method for writing concurrent computer pro- grams of high quality. It is written for professional programmers and stu- dents who are faced with the complicated task of building reliable computer operating systems or real-time control programs. The motivations for mastering concurrent programming are both eco- nomic and intellectual. Concurrent programming makes it possible to use a computer where many things need attention at the same time--be they people at terminals or temperatures in an industrial plant. It is without doubt the most difficult form of programming. This book presents a systematic way of developing concurrent programs in a structured language called Concurrent Pascal--the first of its kind. The use of this language is illustrated by three non-trivial concurrent programs : a single-user operating system, a job-stream system, and a real-time sched- uler. All of these have been used successfully on a PDP 11/45 computer. The book includes the complete text of these three programs and explains how they are structured, programmed, tested, and described. In an earlier book, Operating System Principles [Prentice-Hall, 1973], xi xii PREFACE I tried to establish a background for studying existing operating systems in terms of basic concepts. This new text tells the other side of the story: how concurrent programs can be constructed systematically from scratch. It also illustrates details of important design problems--the