Modeling and Analysis of Front-matter Real-Time and Embedded Systems with UML and MARTE This page intentionally left blank Modeling and Analysis of Real-Time and Embedded Systems with UML and MARTE Developing Cyber-Physical Systems Bran Selic´ Sébastien Gérard AMSTERDAM • BOSTON • HEIDELBERG • LONDON NEW YORK • OXFORD • PARIS • SAN DIEGO SAN FRANCISCO • SINGAPORE • SYDNEY • TOKYO Morgan Kaufmann is an imprint of Elsevier Acquiring Editor: Andrea Dierna Editorial Project Manager: Kaitlin Herbert Project Manager: Punithavathy Govindaradjane Designer: Mark Rogers Morgan Kaufmann is an imprint of Elsevier 225 Wyman Street, Waltham, MA 02451, USA Copyright © 2014 Elsevier Inc. All rights reserved No part of this publication may be reproduced or transmitted in any form or by any means, electronic or mechanical, including photocopying, recording, or any information storage and retrieval system, without permission in writing from the publisher. Details on how to seek permission, further information about the Publisher’s permissions policies and our arrangements with organizations such as the Copyright Clearance Center and the Copyright Licensing Agency, can be found at our website: www.elsevier.com/permissions. This book and the individual contributions contained in it are protected under copyright by the Publisher (other than as may be noted herein). Notices Knowledge and best practice in this field are constantly changing. As new research and experience broaden our understanding, changes in research methods or professional practices, may become necessary. Practitioners and researchers must always rely on their own experience and knowledge in evaluating and using any information or methods described herein. In using such information or methods they should be mindful of their own safety and the safety of others, including parties for whom they have a professional responsibility. To the fullest extent of the law, neither the Publisher nor the authors, contributors, or editors, assume any liability for any injury and/or damage to persons or property as a matter of products liability, negligence or otherwise, or from any use or operation of any methods, products, instructions, or ideas contained in the material herein. Library of Congress Cataloging-in-Publication Data Selic´, Bran. Modeling and analysis of real-time and embedded systems with UML and MARTE: developing cyber-physical systems / Bran Selic´, Sébastien Gérard. pages cm Includes bibliographical references and index. ISBN 978-0-12-416619-6 (alk. paper) 1. Embedded computer systems—Computer simulation. 2. UML (Computer science) I. Gérard, Sébastien. II. Title. TK7895.E42S3985 2014 006.2'2—dc23 2013027695 British Library Cataloguing-in-Publication Data A catalogue record for this book is available from the British Library ISBN: 978-0-12-416619-6 Printed and bound in the United States of America 14 15 16 17 18 10 9 8 7 6 5 4 3 2 1 For information on all MK publications visit our website at www.mkp.com To Lillian, Andrew, Matthew, and Sandy and To Marie, Zélie, Nicole, and Jean-Marie This page intentionally left blank Contents Acknowledgments ...............................................................................................................................xiii Foreword ...............................................................................................................................................xv Preface ..................................................................................................................................................xix PART I INTRODUCTION TO MARTE CHAPTER 1 An Overview of MARTE ������������������������������������������������������������������3 1�1 Introduction ..................................................................................................................3 1�2 Why model? .................................................................................................................4 1�3 A simple example ........................................................................................................5 1�4 What does MARTE add to UML? .............................................................................10 1�5 Conceptual foundations and design principles ..........................................................11 1.5.1 Foundational concepts: Applications, platforms, and deployment ..................12 1.5.2 Foundational concepts (1): Resources, brokers, services, usages ....................13 1.5.3 Foundational concepts (2): Physical data types and values .............................14 1.5.4 Foundational concepts (3): Time and timed behavior .....................................14 1.5.5 Foundational concepts (4): Class/instance unification [Advanced] .................15 1.5.6 Core design principle (1): Support for concern-specific representations [Advanced] ..................................................................................................... 15 1.5.7 Core design principle (2): Composite stereotypes [Advanced] .......................16 1.5.8 Core design principle (3): Modularity for scalability [Advanced] ..................16 1�6 Standard use cases for MARTE .................................................................................17 1.6.1 Use case (1): Application modeling .................................................................17 1.6.2 Use case (2): Modeling platforms ....................................................................18 1.6.3 Use case (3): Specifying deployment ..............................................................19 1.6.4 Use case (4): Analyze model ...........................................................................19 1.6.5 Use case (5): Create a new analysis profile .....................................................20 1.6.6 Use case (6): Configure product variant ..........................................................21 1.6.7 Use case (7): Extend MARTE .........................................................................22 1�7 Tool support for MARTE ...........................................................................................22 1�8 Summary ....................................................................................................................22 References .........................................................................................................................23 PART II FOUNDATIONS CHAPTER 2 An Introduction to UML Profiles ���������������������������������������������������27 2�1 Introduction ................................................................................................................27 2�2 The two kinds of profiles ...........................................................................................28 vii viii Contents 2�3 How profiles work .....................................................................................................30 2.3.1 Metamodels .....................................................................................................30 2.3.2 The stereotype concept ....................................................................................31 2.3.3 First-class language concepts ..........................................................................33 2.3.4 Profile packages ...............................................................................................34 2.3.5 Using stereotypes in models ............................................................................34 2.3.6 Under the hood: How stereotypes are implemented ........................................36 2.3.7 Denotational and annotational properties of stereotypes .................................36 2.3.8 Multibased stereotypes ....................................................................................38 2�4 Conventions related to the use of profiles ..................................................................39 2.4.1 Default values of omitted stereotype properties ..............................................39 2.4.2 Transitivity of class stereotypes to elements representing instances ...............39 2.4.3 Inheritance of stereotype applications .............................................................40 2�5 Model libraries for profiles ........................................................................................41 2�6 Specializing profiles ...................................................................................................41 2�7 Summary ....................................................................................................................41 References .........................................................................................................................43 CHAPTER 3 MARTE Foundations: Specifying Non-functional Properties �����������45 3�1 Introduction ................................................................................................................45 3�2 The modeling of physical data types in MARTE ......................................................47 3�3 How to use the MARTE standard physical types ......................................................51 3.3.1 Time types, time values, and time expressions ................................................51 3�4 Adding new physical data types [Advanced] .............................................................54 3.4.1 Step 1: Defining the physical units and their concrete representation .............55 3.4.2 Step 2: Defining the unit type (Dimension) of the physical type ....................55 3.4.3 Step 3: Defining the new physical type ...........................................................56 3�5 Specifying probabilistic values for physical data types [Advanced] .........................57 3�6 Specifying required and offered values .....................................................................58 3�7 Summary ....................................................................................................................59 References .........................................................................................................................59 CHAPTER 4 MARTE Foundations: Modeling Time and Resources ���������������������61 4�1 Introduction ................................................................................................................61 4�2 Modeling with time and clocks ..................................................................................62 4.2.1 Two alternatives for dealing with time values .................................................62 4.2.2 MARTE models of time ...................................................................................63 4.2.3 Base concepts for explicit reference clock modeling ......................................64 4.2.4 Modeling clocks ...............................................................................................65 4.2.5 The ideal clock .................................................................................................68 4.2.6 Associating behavior with time .......................................................................68 4.2.7 Timed constraints .............................................................................................74 4.2.8 Modeling timers and timeouts .........................................................................77 Contents ix 4�3 Modeling resources ....................................................................................................77 4.3.1 Conceptual framework for representing resources ..........................................78 4.3.2 Modeling resources ..........................................................................................79 4.3.3 Modeling resource services .............................................................................81 4.3.4 Modeling resource usages ................................................................................82 4�4 Summary ....................................................................................................................82 References .........................................................................................................................83 PART III MODELING REAL-TIME SYSTEMS WITH MARTE CHAPTER 5 Modeling Software Applications ��������������������������������������������������87 5�1 Introduction ................................................................................................................87 5�2 Distinguishing characteristics of “real-time” applications ........................................88 5�3 Application modeling foundations ............................................................................90 5.3.1 Software resources ...........................................................................................90 5.3.2 Software resource services...............................................................................92 5�4 Dealing with concurrency ..........................................................................................93 5.4.1 Modeling concurrent tasks ...............................................................................94 5.4.2 Modeling synchronization mechanisms ........................................................103 5.4.3 Modeling task communications mechanisms ................................................107 5�5 Dealing with timeliness ...........................................................................................111 5.5.1 Modeling clocks and timers via the implicit approach ..................................111 5.5.2 Associating time with services and service invocations [Advanced] ............113 5.5.3 Modeling cyclical behaviors ..........................................................................115 5�6 Dealing with asynchrony and hardware interfacing ................................................117 5.6.1 Modeling interrupt sources and interrupt handling .......................................118 5.6.2 Modeling signal-based notifications ..............................................................120 5�7 Dealing with resource limitations (Specifying platform requirements) ..................121 5�8 Summary ..................................................................................................................123 References .......................................................................................................................123 CHAPTER 6 Modeling Platforms ������������������������������������������������������������������125 6�1 Introduction ..............................................................................................................125 6�2 What is a platform? ..................................................................................................126 6�3 Why model platforms? ............................................................................................127 6�4 MARTE approach to modeling platforms ...............................................................128 6.4.1 Platform modeling—core concepts ...............................................................129 6.4.2 Modeling processing resources ......................................................................130 6.4.3 Modeling storage resources ...........................................................................131 6.4.4 Modeling communications resources ............................................................135 6.4.5 Modeling concurrency resources ...................................................................140 6.4.6 Modeling synchronization resources .............................................................141