100% found this document useful (1 vote)
44 views

(Ebook) Design Patterns for Embedded Systems in C: An Embedded Software Engineering Toolkit by Bruce Powel Douglass ISBN 9781856177078, 1856177076 instant download

The document lists various ebooks related to embedded systems and software engineering, authored by Bruce Powel Douglass and others. It includes titles such as 'Design Patterns for Embedded Systems in C' and 'Making Embedded Systems: Design Patterns for Great Software.' Each entry provides ISBN numbers and links for downloading the ebooks.

Uploaded by

amosersrgei
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PDF, TXT or read online on Scribd
100% found this document useful (1 vote)
44 views

(Ebook) Design Patterns for Embedded Systems in C: An Embedded Software Engineering Toolkit by Bruce Powel Douglass ISBN 9781856177078, 1856177076 instant download

The document lists various ebooks related to embedded systems and software engineering, authored by Bruce Powel Douglass and others. It includes titles such as 'Design Patterns for Embedded Systems in C' and 'Making Embedded Systems: Design Patterns for Great Software.' Each entry provides ISBN numbers and links for downloading the ebooks.

Uploaded by

amosersrgei
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PDF, TXT or read online on Scribd
You are on page 1/ 30

(Ebook) Design Patterns for Embedded Systems in

C: An Embedded Software Engineering Toolkit by


Bruce Powel Douglass ISBN 9781856177078,
1856177076 download
https://ebooknice.com/product/design-patterns-for-embedded-
systems-in-c-an-embedded-software-engineering-toolkit-4167368

Explore and download more ebooks at ebooknice.com


We believe these products will be a great fit for you. Click
the link to download now, or visit ebooknice.com
to discover even more!

(Ebook) Real-Time UML Workshop for Embedded Systems by Bruce


Powel Douglass ISBN 9780124077812, 9781865843834, 1865843830,
0124077811

https://ebooknice.com/product/real-time-uml-workshop-for-embedded-
systems-5411244

(Ebook) Making Embedded Systems: Design Patterns for Great


Software by Elecia White

https://ebooknice.com/product/making-embedded-systems-design-patterns-for-
great-software-56259492

(Ebook) Real-time design patterns: robust scalable architecture


for real-time systems by Douglass, Bruce Powel ISBN
9780201699562, 0201699567

https://ebooknice.com/product/real-time-design-patterns-robust-scalable-
architecture-for-real-time-systems-11809678

(Ebook) Making Embedded Systems: Design Patterns for Great


Software by Elecia White ISBN 9781098151546, 1098151542

https://ebooknice.com/product/making-embedded-systems-design-patterns-for-
great-software-57674922
(Ebook) Making Embedded Systems: Design Patterns for Great
Software, 2nd Edition by Elecia White ISBN 9781098151546,
1098151542

https://ebooknice.com/product/making-embedded-systems-design-patterns-for-
great-software-2nd-edition-56246860

(Ebook) Software Engineering for Embedded Systems: Methods,


Practical Techniques, and Applications by Robert Oshana

https://ebooknice.com/product/software-engineering-for-embedded-systems-
methods-practical-techniques-and-applications-55831158

(Ebook) Software Engineering for Embedded Systems by Robert


Oshana, Mark Kraeling ISBN 9780128094488, 0128094486,
■0128094486

https://ebooknice.com/product/software-engineering-for-embedded-
systems-10959124

(Ebook) So You Wanna Be an Embedded Engineer: The Guide to


Embedded Engineering, From Consultancy to the Corporate Ladder
by Lewin Edwards Lewin Edwards is an embedded engineer with over
15 years experience designing embedded systems hardware
firmware and control software ISBN 9780750679534, 0750679530
https://ebooknice.com/product/so-you-wanna-be-an-embedded-engineer-the-
guide-to-embedded-engineering-from-consultancy-to-the-corporate-
ladder-4645686

(Ebook) Embedded Systems Handbook,: Embedded Systems Design and


Verification by Shehrzad Qureshi ISBN 9780387252803, 0387252800

https://ebooknice.com/product/embedded-systems-handbook-embedded-systems-
design-and-verification-1270576
Design Patterns for
Embedded Systems in C
This page intentionally left blank
Design Patterns for
Embedded Systems in C
An Embedded Software Engineering Toolkit

Bruce Powel Douglass, PhD

AMSTERDAM • BOSTON • HEIDELBERG • LONDON


NEW YORK • OXFORD • PARIS • SAN DIEGO
SAN FRANCISCO • SINGAPORE • SYDNEY • TOKYO
Newnes is an imprint of Elsevier Newnes
Newnes is an imprint of Elsevier
Linacre House, Jordan Hill, Oxford OX2 8DP, UK
30 Corporate Drive, Suite 400, Burlington, MA 01803, USA

First edition 2011

Copyright © 2011 Elsevier Inc. All rights reserved.

No part of this publication may be reproduced, stored in a retrieval system or transmitted in


any form or by any means electronic, mechanical, photocopying, recording or otherwise
without the prior written permission of the publisher.

Permissions may be sought directly from Elsevier’s Science & Technology Rights
Department in Oxford, UK: phone (+44) (0) 1865 843830; fax (+44) (0) 1865 853333;
email: [email protected]. Alternatively you can submit your request online by visiting
the Elsevier web site at http://www.elsevier.com/locate/permissions, and selecting Obtaining
permission to use Elsevier material.

Notice:
No responsibility is assumed by the publisher 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.
Because of rapid advances in the medical sciences, in particular, independent verification
of diagnoses and drug dosages should be made.

Library of Congress Cataloging-in-Publication Data


Douglass, Bruce Powel.
Design patterns for embedded C: an embedded software engineering toolkit / Bruce Powel Douglass – 1st ed.
p. cm.
Includes index.
ISBN 978-1-85617-707-8
1. C (Computer program language) 2. Embedded computer systems–Programming. 3. Software patterns. I. Title.
QA76.73.C15D685 2011
005.13’3–dc22
2010027721
A catalog record for this book is available from the Library of Congress

British Library Cataloguing in Publication Data


A catalogue record for this book is available from the British Library

For information on all Newnes publications


visit our website at books.elsevier.com

ISBN: 978-1-85617-707-8

Printed and bound in USA


13 12 11 10 9 8 7 6 5 4 3 2 1

Working together to grow


libraries in developing countries
www.elsevier.com | www.bookaid.org | www.sabre.org
Dedication
This book is dedicated to my elder son Scott, who graduated with an
almost-4.0 average in physics and is going on to graduate school – nicely
done Scott!
This page intentionally left blank
Contents
Preface ............................................................................................................ xv
Acknowledgements .......................................................................................... xvii
About the Author ...........................................................................................xviii
Chapter 1 What Is Embedded Programming? .................................................. 1
1.1 What’s Special About Embedded Systems? .......................................................... 1
1.1.1 Embedded Design Constraints................................................................... 3
1.1.2 The Embedded Tool Chain ........................................................................ 4
1.1.3 OS, RTOS, or Bareback? ........................................................................... 5
1.1.4 Embedded Middleware .............................................................................. 6
1.1.5 Codevelopment with Hardware ................................................................. 7
1.1.6 Debugging and Testing .............................................................................. 8
1.2 OO or Structured – It’s Your Choice..................................................................... 9
1.2.1 Classes...................................................................................................... 10
1.2.2 Objects ..................................................................................................... 13
1.2.3 Polymorphism and Virtual Functions ...................................................... 14
1.2.4 Subclassing............................................................................................... 15
1.2.5 Finite State Machines............................................................................... 25
1.3 What Did We Learn? ........................................................................................... 33
Chapter 2 Embedded Programming with The HarmonyTM for Embedded
RealTime Process........................................................................................ 35
2.1 Basic Elements of the Harmony Process............................................................. 36
2.1.1 A Quick Overview of the Development Workflow................................. 36
2.1.2 What Is a Design Pattern? ....................................................................... 44
2.1.3 Basic Structure of Design Patterns .......................................................... 45
2.1.4 How to Read Design Patterns in This Book ........................................... 46
2.1.5 Using Design Patterns in Development................................................... 47
2.1.6 Observer Pattern....................................................................................... 66
2.2 The Approach ...................................................................................................... 77
2.3 What’s Coming Up .............................................................................................. 78
Chapter 3 Design Patterns for Accessing Hardware....................................... 79
3.1 Basic Hardware Access Concepts........................................................................ 81

vii
Contents

3.2 Hardware Proxy Pattern....................................................................................... 85


3.2.1 Abstract .................................................................................................... 85
3.2.2 Problem .................................................................................................... 86
3.2.3 Pattern Structure....................................................................................... 86
3.2.4 Collaboration Roles ................................................................................. 87
3.2.5 Consequences........................................................................................... 88
3.2.6 Implementation Strategies........................................................................ 89
3.2.7 Related Patterns........................................................................................ 89
3.2.8 Example ................................................................................................... 89
3.3 Hardware Adapter Pattern.................................................................................... 96
3.3.1 Abstract .................................................................................................... 96
3.3.2 Problem .................................................................................................... 96
3.3.3 Pattern Structure....................................................................................... 96
3.3.4 Collaboration Roles ................................................................................. 96
3.3.5 Consequences........................................................................................... 97
3.3.6 Implementation Strategies........................................................................ 98
3.3.7 Related Patterns........................................................................................ 98
3.3.8 Example ................................................................................................... 98
3.4 Mediator Pattern................................................................................................. 100
3.4.1 Abstract .................................................................................................. 100
3.4.2 Problem .................................................................................................. 100
3.4.3 Pattern Structure..................................................................................... 101
3.4.4 Collaboration Roles ............................................................................... 101
3.4.5 Consequences......................................................................................... 102
3.4.6 Implementation Strategies...................................................................... 102
3.4.7 Related Patterns...................................................................................... 102
3.4.8 Example ................................................................................................. 103
3.5 Observer Pattern..................................................................................................111
3.5.1 Abstract ...................................................................................................111
3.5.2 Problem ...................................................................................................112
3.5.3 Pattern Structure......................................................................................112
3.5.4 Collaboration Roles ................................................................................112
3.5.5 Consequences..........................................................................................114
3.5.6 Implementation Strategies.......................................................................114
3.5.7 Related Patterns.......................................................................................115
3.5.8 Example ..................................................................................................115
3.6 Debouncing Pattern............................................................................................ 122
3.6.1 Abstract .................................................................................................. 123
3.6.2 Problem .................................................................................................. 123
3.6.3 Pattern Structure..................................................................................... 123
3.6.4 Collaboration Roles ............................................................................... 123
3.6.5 Consequences......................................................................................... 125

viii
Contents

3.6.6 Implementation Strategies...................................................................... 125


3.6.7 Related Patterns...................................................................................... 126
3.6.8 Example ................................................................................................. 126
3.7 Interrupt Pattern ................................................................................................. 130
3.7.1 Abstract .................................................................................................. 130
3.7.2 Problem .................................................................................................. 130
3.7.3 Pattern Structure..................................................................................... 131
3.7.4 Collaboration Roles ............................................................................... 131
3.7.5 Consequences......................................................................................... 132
3.7.6 Implementation Strategies...................................................................... 134
3.7.7 Related Patterns...................................................................................... 135
3.7.8 Example ................................................................................................. 135
3.8 Polling Pattern.................................................................................................... 138
3.8.1 Abstract .................................................................................................. 138
3.8.2 Problem .................................................................................................. 138
3.8.3 Pattern Structure..................................................................................... 138
3.8.4 Collaboration Roles ............................................................................... 138
3.8.5 Consequences......................................................................................... 141
3.8.6 Implementation Strategies...................................................................... 141
3.8.7 Related Patterns...................................................................................... 142
3.8.8 Example ................................................................................................. 142
3.9 So, What Did We Learn?................................................................................... 147
Chapter 4 Design Patterns for Embedding Concurrency and Resource
Management ............................................................................................ 149
4.1 Basic Concurrency Concepts ............................................................................. 152
4.1.1 Identifying Tasks.................................................................................... 160
4.1.2 Concurrency in the UML....................................................................... 161
4.1.3 Real-Time Operating Systems ............................................................... 163
Scheduling Patterns............................................................................................... 164
4.2 Cyclic Executive Pattern.................................................................................... 164
4.2.1 Abstract .................................................................................................. 165
4.2.2 Problem .................................................................................................. 165
4.2.3 Pattern Structure..................................................................................... 165
4.2.4 Collaboration Roles ............................................................................... 165
4.2.5 ConcreteCEThread ................................................................................. 166
4.2.6 Consequences......................................................................................... 167
4.2.7 Implementation Strategies...................................................................... 167
4.2.8 Related Patterns...................................................................................... 167
4.2.9 Example ................................................................................................. 167
4.3 Static Priority Pattern ......................................................................................... 170
4.3.1 Abstract .................................................................................................. 170
4.3.2 Problem .................................................................................................. 171

ix
Contents

4.3.3 Pattern Structure..................................................................................... 171


4.3.4 Collaboration Roles ............................................................................... 172
4.3.5 Consequences......................................................................................... 173
4.3.6 Implementation Strategies...................................................................... 173
4.3.7 Related Patterns...................................................................................... 174
4.3.8 Example ................................................................................................. 175
Task Coordination Patterns ................................................................................... 182
4.4 Critical Region Pattern....................................................................................... 182
4.4.1 Abstract .................................................................................................. 182
4.4.2 Problem .................................................................................................. 182
4.4.3 Pattern Structure..................................................................................... 182
4.4.4 Collaboration Roles ............................................................................... 183
4.4.5 Consequences......................................................................................... 184
4.4.6 Implementation Strategies...................................................................... 184
4.4.7 Related Patterns...................................................................................... 184
4.4.8 Example ................................................................................................. 184
4.5 Guarded Call Pattern.......................................................................................... 190
4.5.1 Abstract .................................................................................................. 190
4.5.2 Problem .................................................................................................. 190
4.5.3 Pattern Structure..................................................................................... 190
4.5.4 Collaboration Roles ............................................................................... 191
4.5.5 Consequences......................................................................................... 192
4.5.6 Implementation Strategies...................................................................... 192
4.5.7 Related Patterns...................................................................................... 193
4.5.8 Example ................................................................................................. 194
4.6 Queuing Pattern ................................................................................................. 207
4.6.1 Abstract .................................................................................................. 207
4.6.2 Problem .................................................................................................. 207
4.6.3 Pattern Structure..................................................................................... 208
4.6.4 Collaboration Roles ............................................................................... 208
4.6.5 Consequences......................................................................................... 209
4.6.6 Implementation Strategies...................................................................... 210
4.6.7 Related Patterns...................................................................................... 210
4.6.8 Example ................................................................................................. 210
4.7 Rendezvous Pattern............................................................................................ 224
4.7.1 Abstract .................................................................................................. 225
4.7.2 Problem .................................................................................................. 226
4.7.3 Pattern Structure..................................................................................... 226
4.7.4 Collaboration Roles ............................................................................... 226
4.7.5 Consequences......................................................................................... 227
4.7.6 Implementation Strategies...................................................................... 228

x
Contents

4.7.7 Related Patterns...................................................................................... 228


4.7.8 Example ................................................................................................. 228
Deadlock Avoidance Patterns ............................................................................... 231
4.8 Simultaneous Locking Pattern ........................................................................... 232
4.8.1 Abstract .................................................................................................. 232
4.8.2 Problem .................................................................................................. 233
4.8.3 Pattern Structure..................................................................................... 233
4.8.4 Collaboration Roles ............................................................................... 234
4.8.5 Consequences......................................................................................... 236
4.8.6 Implementation Strategies...................................................................... 236
4.8.7 Related Patterns...................................................................................... 236
4.8.8 Example ................................................................................................. 236
4.9 Ordered Locking ................................................................................................ 242
4.9.1 Abstract .................................................................................................. 242
4.9.2 Problem .................................................................................................. 243
4.9.3 Pattern Structure..................................................................................... 243
4.9.4 Collaboration Roles ............................................................................... 244
4.9.5 Consequences......................................................................................... 247
4.9.6 Implementation Strategies...................................................................... 248
4.9.7 Related Patterns...................................................................................... 248
4.9.8 Example ................................................................................................. 248
4.10 So, What Have We Learned?........................................................................... 255
Chapter 5 Design Patterns for State Machines............................................ 257
5.1 Oh Behave! ........................................................................................................ 259
5.2 Basic State Machine Concepts........................................................................... 261
5.2.1 OR-States ............................................................................................... 263
5.2.2 AND-States ............................................................................................ 265
5.2.3 Special Stuff: Timeouts, Conditionals, and More.................................. 267
5.2.4 Synchronous versus Asynchronous? ..................................................... 270
5.3 Single Event Receptor Pattern ........................................................................... 274
5.3.1 Abstract .................................................................................................. 274
5.3.2 Problem .................................................................................................. 274
5.3.3 Pattern Structure..................................................................................... 274
5.3.4 Collaboration Roles ............................................................................... 275
5.3.5 Consequences......................................................................................... 278
5.3.6 Implementation Strategies...................................................................... 278
5.3.7 Related Patterns...................................................................................... 278
5.3.8 Example ................................................................................................. 278
5.4 Multiple Event Receptor Pattern........................................................................ 287
5.4.1 Abstract .................................................................................................. 287
5.4.2 Problem .................................................................................................. 287

xi
Contents

5.4.3 Pattern Structure..................................................................................... 288


5.4.4 Collaboration Roles ............................................................................... 288
5.4.5 Consequences......................................................................................... 290
5.4.6 Implementation Strategies...................................................................... 290
5.4.7 Related Patterns...................................................................................... 290
5.4.8 Example ................................................................................................. 290
5.5 State Table Pattern ............................................................................................. 296
5.5.1 Abstract .................................................................................................. 296
5.5.2 Problem .................................................................................................. 296
5.5.3 Pattern Structure..................................................................................... 296
5.5.4 Collaboration Roles ............................................................................... 297
5.5.5 Consequences......................................................................................... 299
5.5.6 Implementation Strategies...................................................................... 299
5.5.7 Related Patterns...................................................................................... 299
5.5.8 Example ................................................................................................. 300
5.6 State Pattern ....................................................................................................... 308
5.6.1 Abstract .................................................................................................. 308
5.6.2 Problem .................................................................................................. 308
5.6.3 Pattern Structure..................................................................................... 308
5.6.4 Collaboration Roles ............................................................................... 310
5.6.5 Consequences......................................................................................... 312
5.6.6 Implementation Strategies...................................................................... 313
5.6.7 Related Patterns...................................................................................... 313
5.6.8 Example ................................................................................................. 314
5.7 AND-States ........................................................................................................ 327
5.8 Decomposed AND-State Pattern ....................................................................... 330
5.8.1 Abstract .................................................................................................. 331
5.8.2 Problem .................................................................................................. 331
5.8.3 Pattern Structure..................................................................................... 331
5.8.4 Collaboration Roles ............................................................................... 331
5.8.5 Consequences......................................................................................... 333
5.8.6 Implementation Strategies...................................................................... 333
5.8.7 Related Patterns...................................................................................... 334
5.8.8 Example ................................................................................................. 334
5.9 OK, What Have We Learned? ........................................................................... 356
Chapter 6 Safety and Reliability Patterns ................................................... 357
6.1 A Little Bit About Safety and Reliability.......................................................... 359
6.1.1 Safety and Reliability Related Faults .................................................... 360
6.1.2 Achieving Safety and Reliability ........................................................... 361
6.2 One’s Complement Pattern ................................................................................ 362
6.2.1 Abstract .................................................................................................. 362
6.2.2 Problem .................................................................................................. 362

xii
Contents

6.2.3 Pattern Structure..................................................................................... 362


6.2.4 Collaboration Roles ............................................................................... 362
6.2.5 Consequences......................................................................................... 363
6.2.6 Implementation Strategies...................................................................... 363
6.2.7 Related Patterns...................................................................................... 363
6.2.8 Example ................................................................................................. 363
6.3 CRC Pattern ....................................................................................................... 367
6.3.1 Abstract .................................................................................................. 367
6.3.2 Problem .................................................................................................. 367
6.3.3 Pattern Structure..................................................................................... 368
6.3.4 Collaboration Roles ............................................................................... 368
6.3.5 Consequences......................................................................................... 369
6.3.6 Implementation Strategies...................................................................... 369
6.3.7 Related Patterns...................................................................................... 369
6.3.8 Example ................................................................................................. 369
6.4 Smart Data Pattern ............................................................................................. 380
6.4.1 Abstract .................................................................................................. 380
6.4.2 Problem .................................................................................................. 381
6.4.3 Pattern Structure..................................................................................... 381
6.4.4 Collaboration Roles ............................................................................... 382
6.4.5 Consequences......................................................................................... 382
6.4.6 Implementation Strategies...................................................................... 383
6.4.7 Related Patterns...................................................................................... 383
6.4.8 Example ................................................................................................. 383
6.5 Channel Pattern.................................................................................................. 395
6.5.1 Abstract .................................................................................................. 395
6.5.2 Problem .................................................................................................. 395
6.5.3 Pattern Structure..................................................................................... 395
6.5.4 Collaboration Roles ............................................................................... 395
6.5.5 Consequences......................................................................................... 396
6.5.6 Implementation Strategies...................................................................... 397
6.5.7 Related Patterns...................................................................................... 397
6.5.8 Example ................................................................................................. 397
6.6 Protected Single Channel Pattern ...................................................................... 402
6.6.1 Abstract .................................................................................................. 402
6.6.2 Problem .................................................................................................. 402
6.6.3 Pattern Structure..................................................................................... 403
6.6.4 Collaboration Roles ............................................................................... 404
6.6.5 Implementation Strategies...................................................................... 405
6.6.6 Related Patterns...................................................................................... 405
6.6.7 Example ................................................................................................. 405

xiii
Contents

6.7 Dual Channel Pattern ......................................................................................... 413


6.7.1 Abstract .................................................................................................. 413
6.7.2 Problem .................................................................................................. 414
6.7.3 Pattern Structure..................................................................................... 414
6.7.4 Collaboration Roles ............................................................................... 414
6.7.5 Consequences......................................................................................... 417
6.7.6 Implementation Strategies...................................................................... 417
6.7.7 Related Patterns...................................................................................... 417
6.7.8 Example ................................................................................................. 421
6.8 Summary ............................................................................................................ 422
Appendix A UML Notation ........................................................................ 425
1.1 Class Diagram .................................................................................................... 425
1.1.1 Semantic Elements ................................................................................. 425
1.2 Sequence Diagram ............................................................................................. 429
1.2.1 Semantic Elements ................................................................................. 429
1.3 State Diagram..................................................................................................... 430
1.3.1 Semantic Elements ................................................................................. 430
Index ....................................................................................................... 437

xiv
Preface

The predominate language for the development of embedded systems is clearly C. Other
languages certainly have their allure, but over 80% of all embedded systems are developed
in this classic language. Many of the advances in the industry assume the use of object-oriented
languages, web clients, and technologies that are either unavailable in the bare-metal develop-
ment environment of embedded systems, or are too memory or resource intensive to be
effectively deployed.
Design patterns are one of these profitable areas of advancement. A design pattern is a
generalized solution to a recurring problem. Design patterns allow several advantages. First,
they allow users to reason about solutions in a more abstract way and to codify their important
properties. Since all design patterns are about optimization of some set of design criteria at the
expense of others, different design patterns might address the same operational context but
provide different benefits and costs. By reifying design patterns as a basic concept, we can
reason about the best ways to optimize our systems and the technologies and approaches to
accomplish that.
Secondly, design patterns allow us to reuse solutions that have proven themselves to be
effective in other, similar circumstances. This is certainly a larger scope of reuse than reusing
lines of code or individual functions. Because design patterns can be analyzed for their
performance and optimization properties, we can select the best patterns for our particular
problems.
Additionally, design patterns give us a larger set of reusable building blocks with which to
describe our system. If you say the system uses a “symmetric deployment pattern with RMS
multitasking scheduling and a triple modular redundancy approach” that sums up a significant
portion of the architectural optimization decisions about your system. Design patterns make our
vocabulary larger and more expressive.
Lastly, design patterns provide a unit of reference. If you Google “design patterns” you get
over 3,000,000 hits. If you search the Amazon book department online, you get a list of 793
books. There is a great deal of work that goes on in the area of defining and using design
patterns, so we are exposed to an enormous wealth of reusable and proven solutions from which
we can select, mix, and bring to bear appropriate solutions.

xv
Preface

This book brings the power of design patterns to the embedded C developer. Where
appropriate, we use an object-based implementation policy with code examples to see how
the patterns are implemented and used. The patterns are divided up into different areas of
relevance to the embedded developer, including:
• Hardware access
• Concurrency
• State machine implementation
• Safety and reliability
In each area, different patterns are provided that address common concerns.

Audience
The book is oriented toward the practicing professional software developer and the computer
science major, in the junior or senior year. It focuses on practical experience by solving posed
problems from the context of the examples. The book assumes a reasonable proficiency in the
C programming language. UML is used to graphically represent the structure and behavior of
the patterns, but code examples are given to clearly show the design and implementation
concepts.

Goals
The goal of this book is to provide a toolbox for the embedded C developer and to train him
or her on the appropriate use of those tools. An agile development workflow, called the
Harmony Process™ (developed by the author) is discussed in Chapter 2 to provide a process
framework in which patterns have a definite role. However, the use of patterns transcends any
individual process, no matter how coolly named.
By the time you’ve reached the end of the book, you will hopefully have the expertise to
tackle the real design issues that you face in your life as a professional developer of embedded
systems.

Bruce Powel Douglass, Ph.D.

xvi
Acknowledgements

I want to thank my wife Sarah for being supportive even though I work too much, and my great
kids – Scott, Blake, and Tamera – for being awesome even though I work too much.

xvii
About the Author

Bruce Powel Douglass was raised by wolves in the Oregon wilderness. He taught himself to
read at age 3 and learned calculus before age 12. He dropped out of school when he was 14 and
traveled around the U.S. for a few years before entering the University of Oregon as a
mathematics major. He eventually received his M.S. in exercise physiology from the University
of Oregon and his Ph.D. in neurophysiology from the USD Medical School, where he
developed a branch of mathematics called autocorrelative factor analysis for studying informa-
tion processing in multicellular biological neural systems.
Bruce has worked as a software developer in real-time systems for over 30 years and is a
well-known speaker, author, and consultant in the area of real-time embedded systems and
systems engineering. He is on the Advisory Board of the Embedded Systems conference and
has taught courses in software estimation and scheduling, project management, object-
oriented analysis and design, communications protocols, finite state machines, design
patterns, and safety-critical systems design. He develops and teaches courses and consults
in real-time object-oriented analysis and design and project management and has done so for
many years. He has authored articles for a many journals and periodicals, especially in the
real-time domain.
He is the Chief Evangelist1 for IBM Rational, a leading producer of tools for real-time
systems development, including the widely-used Rhapsody modeling tool. Bruce worked with
other UML partners on the specification of the UML. He is a former co-chair of the Object
Management Group’s Real-Time Analysis and Design Working Group. He is the author of
several other books on software, including

• Doing Hard Time: Developing Real-Time Systems with UML, Objects, Frameworks, and
Patterns (Addison-Wesley, 1999)
• Real-Time Design Patterns: Robust Scalable Architecture for Real-Time Systems (Addison-
Wesley, 2002)
• Real-Time UML Third Edition: Advances in the UML for Real-Time Systems (Addison-
Wesley, 2004)

1
Being a Chief Evangelist is much like being a Chief Scientist, except for the burning bushes and stone tablets.

xviii
About the Author

• Real-Time UML Workshop for Embedded Systems (Elsevier, 2007)


• Real-Time Agility (Addison-Wesley, 2009)
and several others, including a short textbook on table tennis.
Bruce enjoys classical music and has played classical guitar professionally. He has competed
in several sports, including table tennis, bicycle racing, running, triathlons, and full-contact Tae
Kwon Do, although he currently only fights inanimate objects that don’t hit back.

xix
Random documents with unrelated
content Scribd suggests to you:
of a refund. If you received the work electronically, the person
or entity providing it to you may choose to give you a second
opportunity to receive the work electronically in lieu of a refund.
If the second copy is also defective, you may demand a refund
in writing without further opportunities to fix the problem.

1.F.4. Except for the limited right of replacement or refund set


forth in paragraph 1.F.3, this work is provided to you ‘AS-IS’,
WITH NO OTHER WARRANTIES OF ANY KIND, EXPRESS OR
IMPLIED, INCLUDING BUT NOT LIMITED TO WARRANTIES OF
MERCHANTABILITY OR FITNESS FOR ANY PURPOSE.

1.F.5. Some states do not allow disclaimers of certain implied


warranties or the exclusion or limitation of certain types of
damages. If any disclaimer or limitation set forth in this
agreement violates the law of the state applicable to this
agreement, the agreement shall be interpreted to make the
maximum disclaimer or limitation permitted by the applicable
state law. The invalidity or unenforceability of any provision of
this agreement shall not void the remaining provisions.

1.F.6. INDEMNITY - You agree to indemnify and hold the


Foundation, the trademark owner, any agent or employee of the
Foundation, anyone providing copies of Project Gutenberg™
electronic works in accordance with this agreement, and any
volunteers associated with the production, promotion and
distribution of Project Gutenberg™ electronic works, harmless
from all liability, costs and expenses, including legal fees, that
arise directly or indirectly from any of the following which you
do or cause to occur: (a) distribution of this or any Project
Gutenberg™ work, (b) alteration, modification, or additions or
deletions to any Project Gutenberg™ work, and (c) any Defect
you cause.
Section 2. Information about the Mission
of Project Gutenberg™
Project Gutenberg™ is synonymous with the free distribution of
electronic works in formats readable by the widest variety of
computers including obsolete, old, middle-aged and new
computers. It exists because of the efforts of hundreds of
volunteers and donations from people in all walks of life.

Volunteers and financial support to provide volunteers with the


assistance they need are critical to reaching Project
Gutenberg™’s goals and ensuring that the Project Gutenberg™
collection will remain freely available for generations to come. In
2001, the Project Gutenberg Literary Archive Foundation was
created to provide a secure and permanent future for Project
Gutenberg™ and future generations. To learn more about the
Project Gutenberg Literary Archive Foundation and how your
efforts and donations can help, see Sections 3 and 4 and the
Foundation information page at www.gutenberg.org.

Section 3. Information about the Project


Gutenberg Literary Archive Foundation
The Project Gutenberg Literary Archive Foundation is a non-
profit 501(c)(3) educational corporation organized under the
laws of the state of Mississippi and granted tax exempt status
by the Internal Revenue Service. The Foundation’s EIN or
federal tax identification number is 64-6221541. Contributions
to the Project Gutenberg Literary Archive Foundation are tax
deductible to the full extent permitted by U.S. federal laws and
your state’s laws.

The Foundation’s business office is located at 809 North 1500


West, Salt Lake City, UT 84116, (801) 596-1887. Email contact
links and up to date contact information can be found at the
Foundation’s website and official page at
www.gutenberg.org/contact

Section 4. Information about Donations to


the Project Gutenberg Literary Archive
Foundation
Project Gutenberg™ depends upon and cannot survive without
widespread public support and donations to carry out its mission
of increasing the number of public domain and licensed works
that can be freely distributed in machine-readable form
accessible by the widest array of equipment including outdated
equipment. Many small donations ($1 to $5,000) are particularly
important to maintaining tax exempt status with the IRS.

The Foundation is committed to complying with the laws


regulating charities and charitable donations in all 50 states of
the United States. Compliance requirements are not uniform
and it takes a considerable effort, much paperwork and many
fees to meet and keep up with these requirements. We do not
solicit donations in locations where we have not received written
confirmation of compliance. To SEND DONATIONS or determine
the status of compliance for any particular state visit
www.gutenberg.org/donate.

While we cannot and do not solicit contributions from states


where we have not met the solicitation requirements, we know
of no prohibition against accepting unsolicited donations from
donors in such states who approach us with offers to donate.

International donations are gratefully accepted, but we cannot


make any statements concerning tax treatment of donations
received from outside the United States. U.S. laws alone swamp
our small staff.
Please check the Project Gutenberg web pages for current
donation methods and addresses. Donations are accepted in a
number of other ways including checks, online payments and
credit card donations. To donate, please visit:
www.gutenberg.org/donate.

Section 5. General Information About


Project Gutenberg™ electronic works
Professor Michael S. Hart was the originator of the Project
Gutenberg™ concept of a library of electronic works that could
be freely shared with anyone. For forty years, he produced and
distributed Project Gutenberg™ eBooks with only a loose
network of volunteer support.

Project Gutenberg™ eBooks are often created from several


printed editions, all of which are confirmed as not protected by
copyright in the U.S. unless a copyright notice is included. Thus,
we do not necessarily keep eBooks in compliance with any
particular paper edition.

Most people start at our website which has the main PG search
facility: www.gutenberg.org.

This website includes information about Project Gutenberg™,


including how to make donations to the Project Gutenberg
Literary Archive Foundation, how to help produce our new
eBooks, and how to subscribe to our email newsletter to hear
about new eBooks.
Welcome to our website – the ideal destination for book lovers and
knowledge seekers. With a mission to inspire endlessly, we offer a
vast collection of books, ranging from classic literary works to
specialized publications, self-development books, and children's
literature. Each book is a new journey of discovery, expanding
knowledge and enriching the soul of the reade

Our website is not just a platform for buying books, but a bridge
connecting readers to the timeless values of culture and wisdom. With
an elegant, user-friendly interface and an intelligent search system,
we are committed to providing a quick and convenient shopping
experience. Additionally, our special promotions and home delivery
services ensure that you save time and fully enjoy the joy of reading.

Let us accompany you on the journey of exploring knowledge and


personal growth!

ebooknice.com

You might also like