,This page intentionally left blank
, BUILDING PARALLEL, EMBEDDED, AND REAL-TIME
APPLICATIONS WITH ADA
The arrival and popularity of multi-core processors have sparked a renewed interest
in the development of parallel programs. Similarly, the availability of low-cost
microprocessors and sensors has generated a great interest in embedded real-time
programs. This book provides students and programmers whose backgrounds are in
traditional sequential programming with the opportunity to expand their capabilities
into parallel, embedded, real-time, and distributed computing. It also addresses the
theoretical foundation of real-time scheduling analysis, focusing on theory that is
useful for actual applications.
Written by award-winning educators at a level suitable for undergraduates and
beginning graduate students, this book is the first truly entry-level textbook in the
subject. Complete examples allow readers to understand the context in which a new
concept is used, and enable them to build and run the examples, make changes, and
observe the results.
john w. mccormick is Professor of Computer Science at the University of
Northern Iowa.
frank singhoff is Professor of Computer Science at Université de
Bretagne Occidentale (University of Brest).
j ér ôme hugues is Associate Professor in the Department of Mathematics,
Computer Science, and Control at the Institute for Space and Aeronautics Engi-
neering (ISAE), Toulouse.
,
,BUILDING PARALLEL, EMBEDDED,
AND REAL-TIME APPLICATIONS
WITH ADA
JOHN W. MCCORMICK
University of Northern Iowa
FRANK SINGHOFF
Université de Bretagne Occidentale
J É R ÔME HUGUES
Institute for Space and Aeronautics
Engineering (ISAE), Toulouse
, cambridge university press
Cambridge, New York, Melbourne, Madrid, Cape Town,
Singapore, São Paulo, Delhi, Tokyo, Mexico City
Cambridge University Press
The Edinburgh Building, Cambridge CB2 8RU, UK
Published in the United States of America by Cambridge University Press, New York
www.cambridge.org
Information on this title: www.cambridge.org/9780521197168
C J. W. McCormick, F. Singhoff, and J. Hugues 2011
This publication is in copyright. Subject to statutory exception
and to the provisions of relevant collective licensing agreements,
no reproduction of any part may take place without the written
permission of Cambridge University Press.
First published 2011
Printed in the United Kingdom at the University Press, Cambridge
A catalog record for this publication is available from the British Library
Library of Congress Cataloging in Publication data
McCormick, John W., 1948–
Building parallel, embedded, and real-time applications with Ada / John W. McCormick,
Frank Singhoff, Jerome Hugues.
p. cm.
Includes bibliographical references and index.
ISBN 978-0-521-19716-8 (hardback)
1. Ada (Computer program language) 2. Parallel programming (Computer science)
3. Embedded computer systems – Programming. 4. Real-time data processing.
5. Multiprocessors – Programming.
I. Singhoff, Frank. II. Hugues, Jerome. III. Title.
QA76.73.A35M375 2011
004 .35 – dc22 2010053214
ISBN 978-0-521-19716-8 Hardback
Cambridge University Press has no responsibility for the persistence or
accuracy of URLs for external or third-party internet websites referred to
in this publication, and does not guarantee that any content on such
websites is, or will remain, accurate or appropriate.
The photograph on the cover shows astronaut Stephen K. Robinson standing on the end of the International Space
Station’s robotic manipulator system, Canadarm 2. This arm, built by MacDonald, Dettwiler, and Associates Ltd
for the Canadian Space Agency, is 17.6 m long when fully extended. It has seven motorized joints, each a complex
embedded real-time system. Given its crucial role on the space station, the reliability of Canadarm 2 must be
impeccable. The software for these joints and for the workstation that the astronauts use to control them is written
in Ada. This book provides an introduction to the concepts of concurrent programming, embedded systems, and
real-time constraints necessary for understanding and developing the software for such systems.
, Contents
List of illustrations page viii
List of tables x
Foreword xi
Preface xiii
1 Introduction and overview 1
1.1 Parallel programming 2
1.2 Distributed programming 11
1.3 Real-time systems 12
Summary 19
Exercises 20
2 Sequential programming with Ada 23
2.1 Control structures 26
2.2 Subprograms 30
2.3 The Ada type model 35
2.4 Blocks and exceptions 62
2.5 Programming in the large 65
2.6 Object-oriented programming 76
2.7 Low-level programming 82
Summary 102
Exercises 103
3 Task basics 107
3.1 Defining tasks 107
3.2 The task life cycle 109
3.3 Task hierarchies 113
3.4 Exceptions 117
3.5 The implementation of Ada tasking 119
3.6 Other task features 119
, vi Contents
Summary 121
Exercises 122
4 Communication and synchronization based on shared
objects 126
4.1 Mutual exclusion 126
4.2 The protected object 130
4.3 Synchronization 134
4.4 The protected entry 135
4.5 Restrictions 140
4.6 Entry queues 141
4.7 Some useful concurrent patterns 143
4.8 Requeue and private operations 149
4.9 Pragmas Atomic and Volatile 153
4.10 Interrupts 155
Summary 161
Exercises 162
5 Communication and synchronization based on direct
interaction 166
5.1 The rendezvous 166
5.2 The selective accept statement 171
5.3 Entry call options 180
5.4 State machines 181
Summary 191
Exercises 192
6 Distributed systems with Ada 195
6.1 What are distributed systems? 195
6.2 Middleware, architectures, and concepts 200
6.3 DSA, the Distributed Systems Annex 202
6.4 PolyORB: compilation chain and run-time for the DSA 212
6.5 Advanced DSA concepts 215
6.6 CORBA, the Common Object Request Broker
Architecture 221
6.7 Advanced CORBA concepts 236
6.8 CORBA versus the DSA 247
Summary 248
Exercises 250
7 Real-time systems and scheduling concepts 251
7.1 Task characteristics 253
7.2 Real-time schedulers 257