Design Patterns Embedded Systems
Design Patterns Embedded Systems
An Embedded
Design
Patterns for
Systems
in C
Douglass, PhD
AMSTERDAM
BOSTON
HEIDELBERG LONDON
NEW YORK
OXFORD
PARIS
SAN DIEGO
SYDNEY TOKYO
imprint of Elsevier
Newnes
Contents
Preface
xv
Acknowledgements
About the Author
xvii
xviii
Chapter
What Is Embedded
Programming?
/ 1 3 4 5 6 7 8 9 10 13
1.1 What's
OS, RTOS,
or
Bareback?
Objects
Polymorphism
Subclassing
14 15 25
33 with The
Chapter 2
2.1
Embedded
Programming
Harmony for
Embedded 35
36 36 44 45 46 47 66 77
RealTime Process Basic Elements of the Harmony Process 2.1.1 A Quick Overview of the Development Workflow 2.1.2 What Is
to
a
Design Pattern?
Patterns
Design 2.1.4 How Read Design Patterns in This Book 2.1.5 Using Design Patterns in Development
2.1.6 Observer Pattern
2.2 The 2.3 What's
Approach Coming Up
Patterns
78
Chapter 3 Design
3.1
79
81
Proxy
Pattern
85 85 86 86 87 88
89 89 89
Consequences
Implementation Strategies
96 96 96 96 96 97
98
Consequences
3.3.8
Consequences
Implementation Strategies Example
3.4.7 Related Patterns 3.5 Observer Pattern 3.5.1 Abstract 3.5.2 Problem 3.5.3 Pattern Structure
103
Ill Ill 112 112 112 114 114 115 115 122
3.5.4 Collaboration Roles 3.5.5 Consequences 3.5.6 Implementation Strategies 3.5.7 Related Patterns 3.5.8 Example
3.6
Debouncing
Pattern
3.6.1 Abstract
3.6.2 Problem
123
123 123 123 125
Consequences
viii
Contents
Strategies
Interrupt Pattern
3.7.1 Abstract 3.7.2 Problem 3.7.3 Pattern Structure
3.7.4 Collaboration Roles 3.7.5
Consequences
Polling
3.8.1
Pattern
Abstract
3.8.5 Consequences
3.8.6 3.8.8 3.9
141
142
142 147
Concurrency Concepts Identifying Tasks 4.1.2 Concurrency in the UML 4.1.3 Real-Time Operating Systems Scheduling Patterns 4.2 Cyclic Executive Pattern
4.1.1 4.2.1 Abstract 4.2.2 Problem 4.2.3 Pattern Structure 4.2.4 Collaboration Roles 4.2.5 ConcreteCEThread 4.2.6 4.2.7 4.2.9
Basic
Consequences
Implementation Strategies
4.3.2 Problem
ix
Consequences
4.3.8
4.4 Critical 4.4.1 4.4.3 4.4.5 4.4.6 4.4.8 4.5.1
4.4.7 Related Patterns 4.5 Guarded Call Pattern 4.5.2 Problem 4.5.3 Pattern Structure 4.5.4 Collaboration Roles 4.5.5
4.5.6
190
191
192
4.5.8
209
210 210 210 224 225 226 226 226 227 228
Rendezvous Pattern
4.7.1
228
228 231 232 232
Locking
Pattern
236 236
236 242 242 243 243 244 247 248 248 248 255
4.9 Ordered
Locking
Abstract
4.9.2 Problem
Consequences
4.9.6
4.9.8
Implementation Strategies
Example
Chapter
5.1
Design
Patterns
for
State Machines
257
259 261 263 265 267 270
Oh Behave!
Concepts
5.3
Timeouts, Conditionals, and More Special Synchronous versus Asynchronous? Single Event Receptor Pattern
5.2.4 5.3.1 Abstract 5.3.2 Problem 5.3.3 Pattern Structure 5.3.4 Collaboration Roles 5.3.5 5.3.6 5.3.8
5.2.3
Stuff:
274
274 274 274 275 278 278 278 278 287
Consequences
Implementation Strategies
287 287
xi
288
288 290 290
5.5.1 Abstract
5.5.2 Problem 5.5.3 Pattern Structure 5.5.4 Collaboration Roles 5.5.5 5.5.6 5.5.8
Consequences
Implementation Strategies
Example
Decomposed
Consequences
Example
Patterns
357
359 360 361 362 362 362
6.2
Safety Reliability Safety and Reliability Related Faults 6.1.2 Achieving Safety and Reliability One's Complement Pattern
6.2.1 Abstract 6.2.2 Problem
and
xii
Contents
362 362 363 363 363 363 367 367 367 368 368 369 369 369 369 380 380 381 381
6.2.5 Consequences 6.2.6 Implementation 6.2.7 Related Patterns 6.2.8 Example 6.3 CRC Pattern
6.3.1
Strategies
Abstract
6.3.2 Problem
6.3.3 Pattern Structure 6.3.4 Collaboration Roles 6.3.5 Consequences 6.3.6 Implementation
6.3.7 6.3.8
Strategies
Related Patterns
Example
Abstract
Consequences
6.4.6
Implementation Strategies
Abstract
395
396 397 397 397
6.5.5
Example
6.6 Protected
Single Channel
Pattern
Abstract
6.6.2 Problem 6.6.3 Pattern Structure 6.6.4 Collaboration Roles 6.6.5 6.6.7
403
404
x/7/*
Contents
6.7 Dual
Channel Pattern
Abstract
413 413 414 414 414 417 417 417 421 422 425
6.7.1
6.7.8 Example
6.8 Summary
Appendix A
UML Notation
Diagram
Sequence Diagram
1.2.1 Semantic Elements
Diagram
Semantic Elements
index
437