Real-Time Systems Development introduces computing students and professional programmers to the development of software for real-time applications. Based on the academic and commercial experience of the author, the book is an ideal companion to final year undergraduate options or MSc modules in the area of real-time systems design and implementation. Assuming a certain level of general systems design and programming experience, this text will extend students' knowledge and skills into an area of computing which has increasing relevance in a modern world of telecommunications and 'intelligent' equipment using embedded microcontrollers.
This book takes a broad, practical approach in discussing real-time systems. It covers topics such as basic input and output; cyclic executives for bare hardware; finite state machines; task communication and synchronization; input/output interfaces; structured design for real-time systems; designing for multitasking; UML for real-time systems; object oriented approach to real-time systems; selecting languages for RTS development; Linux device drivers; and hardware/software co-design. Programming examples using GNU/Linux are included, along with a supporting website containing slides; solutions to problems; and software examples.
This book will appeal to advanced undergraduate Computer Science students; MSc students; and, undergraduate software engineering and electronic engineering students.
* Concise treatment delivers material in manageable sections* Includes handy glossary, references and practical exercises based on familiar scenarios* Supporting website contains slides, solutions to problems and software examples
Inhaltsverzeichnis
1;Cover;1 2;Real-Time Systems Development;4 3;Contents;6 4;Preface;8 5;Recommended lab sessions;10 6;Acknowledgements and thanks;12 7;1 Introduction to real-time systems;14 7.1;1.1 Chapter overview;14 7.2;1.2 Real-time systems development;14 7.3;1.3 System complexity;15 7.4;1.4 Microprocessors and real-time applications;16 7.5;1.5 Definition of a real-time system;17 7.6;1.6 Programming structures;23 7.7;1.7 Response latency;24 7.8;1.8 Relative speeds;24 7.8.1;1.8.1 Polling an input too fast;24 7.8.2;1.8.2 Polling an input too slowly;25 7.8.3;1.8.3 Light sensing;26 7.9;1.9 Software timing;27 7.10;1.10 High speed timing;28 7.11;1.11 Output timing overload;29 7.12;1.12 Debugging real-time systems;30 7.13;1.13 Access to hardware;31 7.14;1.14 Machine I/O;32 7.15;1.15 Programmed I/O;33 7.16;1.16 Hardware/software cost tradeoff;34 7.17;1.17 Hard, soft and firm;35 7.18;1.18 Software Quality Assurance (SQA);36 7.19;1.19 Experience and history;37 7.20;1.20 Futures?;38 7.21;1.21 Chapter summary;38 7.22;1.22 Problems and issues for discussion;40 7.23;1.23 Suggestions for reading;40 8;2 Implementing simple real-time systems;42 8.1;2.1 Chapter overview;42 8.2;2.2 Multi-tasking;42 8.3;2.3 Task loops;43 8.4;2.4 Code timing problems;44 8.5;2.5 Interrupt-driven tasks;45 8.6;2.6 Task swapping: How? When? Which?;46 8.7;2.7 Task re-entry;46 8.8;2.8 Causes of task swapping;47 8.9;2.9 Resource sharing;48 8.10;2.10 Using the printer port for digital I/O;48 8.11;2.11 Electric motors;51 8.12;2.12 Operational details of stepper motors;51 8.13;2.13 Lifecycle of a professional programmer;55 8.14;2.14 Chapter summary;55 8.15;2.15 Problems and issues for discussion;57 8.16;2.16 Suggestions for reading;58 9;3 Basic input and output;59 9.1;3.1 Chapter overview;59 9.2;3.2 Memory-mapped ports;59 9.3;3.3 I/O mapped ports;61 9.4;3.4 Port registers the programmers view;63 9.5;3.5 Port polling;66 9.6;3.6 I/O access permissions;68 9.7;3.7 To block or not to block;72 9.8;3.8 Exception and interrupt process
ing service on demand;74 9.9;3.9 Multiple interrupt sources;75 9.10;3.10 Powerfail detection;78 9.11;3.11 Interrupt structure on the PC;81 9.12;3.12 Deferred interrupt processing;84 9.13;3.13 Use of exceptions and interrupts;85 9.14;3.14 Interrupt unpredictability;86 9.15;3.15 Critical data protection how to communicate with interrupts;87 9.16;3.16 Bu.ered I/O interrupt device drivers;90 9.17;3.17 Chapter summary;92 9.18;3.18 Problems and issues for discussion;92 9.19;3.19 Suggestions for reading;93 10;4 Cyclic executives for bare hardware;94 10.1;4.1 Chapter overview;94 10.2;4.2 The basic system;94 10.3;4.3 System tick;95 10.4;4.4 Extended tasks;96 10.5;4.5 Implementation of a cyclic executive;97 10.6;4.6 Cyclic executive execution pattern;98 10.7;4.7 Demonstation cyclic executive code;99 10.8;4.8 Keypad application;100 10.9;4.9 Chapter summary;105 10.10;4.10 Problems and issues for discussion;105 10.11;4.11 Suggestions for reading;106 11;5 Finite state machines design tool;107 11.1;5.1 Chapter overview;107 11.2;5.2 Defining the perimeter;107 11.3;5.3 Channel bandwidths;108 11.4;5.4 Finite State Diagrams (FSD);110 11.5;5.5 Auxiliary variables;112 11.6;5.6 Vehicle detection;113 11.7;5.7 Simplification techniques;114 11.8;5.8 Input data and trigger events;115 11.9;5.9 Teas-made;115 11.10;5.10 Hierarchical state charts;117 11.11;5.11 Concurrent FSMs;119 11.12;5.12 OO design patterns and state machines;120 11.13;5.13 Chapter summary;120 11.14;5.14 Problems and issues for discussion;121 11.15;5.15 Suggestions for reading;122 12;6 Finite state machines implementation options;123 12.1;6.1 Chapter overview;123 12.2;6.2 Implementing an FSD;123 12.3;6.3 Implementation by direct sequential coding;124 12.4;6.4 THE SWITCH-CASE IMPLEMENTATION MODEL;127 12.5;6.5 The GOTO/LABEL implementation model;131 12.6;6.6 FST implementation model;134 12.7;6.7 An object-oriented approach to implementation;141 12.8;6.8 FSM scheduling issues;148 12.9;6.9 More FST;150 12.10;6.10 Run-time environ
ment;158 12.11;6.11 Chapter summary;160 12.12;6.12 Problems and issues for discussion;160 12.13;6.13 Suggestions for reading;161 13;7 Why multi-task?;163 13.1;7.1 Chapter overview;163 13.2;7.2 Recognizing a real-time application;163 13.3;7.3 Multi-tasking and multi-threading;164 13.4;7.4 Run-time support environment;165 13.5;7.5 Run-time scheduling;167 13.6;7.6 Justifying the use of multi-tasking;168 13.7;7.7 Responsiveness;169 13.8;7.8 Intellectual simplicity of design;170 13.9;7.9 Rigour of implementation;171 13.10;7.10 Unit testing;171 13.11;7.11 System integrity;172 13.12;7.12 System integration testing;173 13.13;7.13 Exploitation of multi-processor hardware;173 13.14;7.14 Processor support for task swapping;175 13.15;7.15 Starting new tasks in Linux;178 13.16;7.16 Chapter summary;180 13.17;7.17 Problems and issues for discussion;180 13.18;7.18 Suggestions for reading;181 14;8 Task communication and synchronization;182 14.1;8.1 Chapter overview;182 14.2;8.2 Data sharing;182 14.3;8.3 Event flags;185 14.4;8.4 Semaphores;185 14.5;8.5 Lock files;186 14.6;8.6 Intercept signals;187 14.7;8.7 Shared data buffers;195 14.8;8.8 Pipes;196 14.9;8.9 Control queues;204 14.10;8.10 Sockets;204 14.11;8.11 Remote Procedure Calls (RPC);209 14.12;8.12 ADA rendezvous;210 14.13;8.13 Java synchronization;211 14.14;8.14 Chapter summary;212 14.15;8.15 Problems and issues for discussion;212 14.16;8.16 Suggestions for reading;213 15;9 Real-time executives;214 15.1;9.1 Chapter overview;214 15.2;9.2 Real-time systems implementations;214 15.3;9.4 Porting application code for RTEs;216 15.4;9.5 Hardware support for an RTE;216 15.5;9.6 RTE facilities;218 15.6;9.7 Linux;219 15.7;9.8 POSIX facilities;221 15.8;9.9 Scheduling;227 15.9;9.10 Unix Filesystem Hierarchy Standard (FHS);228 15.10;9.11 Configuring and building the Linux kernel;229 15.11;9.12 Linux for embedded applications;230 15.12;9.13 Booting embedded Linux;230 15.13;9.14 Language support;230 15.14;9.15 Licensing issues;232 15.15;9.16 Ch
apter summary;234 15.16;9.17 Problems and issues for discussion;234 15.17;9.18 Suggestions for reading;235 16;10 Using input/output interfaces;237 16.1;10.1 Chapter overview;237 16.2;10.2 Input and output operations;237 16.3;10.3 Categories;238 16.4;10.4 Operating system support;239 16.5;10.5 Raw I/O;241 16.6;10.6 I/O with Linux;242 16.7;10.7 Direct device driver;245 16.8;10.8 Device drivers under interrupt;246 16.9;10.9 Queuing theory;248 16.10;10.10 Chapter summary;252 16.11;10.11 Problems and issues for discussion;252 16.12;10.12 Suggestions for reading;253 17;11 Structured design for real-time systems;254 17.1;11.1 Chapter overview;254 17.2;11.2 Design methods;254 17.3;11.3 Incremental functional decomposition;256 17.4;11.4 Use of diagrams in design;257 17.5;11.5 Data Flow Diagrams (DFD);258 17.6;11.6 Implementing a DFD;259 17.7;11.7 Reading structure charts;266 17.8;11.8 Yourdon structured analysis and design for real-time systems;268 17.9;11.9 Implementing an event-based DFD;269 17.10;11.10 Stored data modelling EAR modelling;273 17.11;11.11 Transforming ERD to DFD;276 17.12;11.12 Normalizing stored data;277 17.13;11.13 Chapter summary;278 17.14;11.14 Problems and issues for discussion;278 17.15;11.15 Suggestions for reading;278 18;12 Designing for multi-tasking;280 18.1;12.1 Chapter overview;280 18.2;12.2 SA/SD for multi-tasking;280 18.3;12.3 Partitioning into tasks;281 18.4;12.4 Cohesion and coupling;283 18.5;12.5 Designing for intertask communication;284 18.6;12.6 Device interfacing;286 18.7;12.7 Task diagrams;287 18.8;12.8 The CODARTS method;291 18.9;12.9 Re-entrant code;292 18.10;12.10 Setting task priorities;293 18.11;12.11 Execution timing;294 18.12;12.12 Run-time support;295 18.13;12.13 Chapter summary;295 18.14;12.14 Problems and issues for discussion;296 18.15;12.15 Suggestions for reading;296 19;13 UML for real-time systems;298 19.1;13.1 Chapter overview;298 19.2;13.2 A Unified Modelling Language;298 19.3;13.3 Use-cases;299 19.4;13.4 Objects and cla
sses;300 19.5;13.5 Object collaboration diagrams;301 19.6;13.6 Class diagrams;302 19.7;13.7 Interobject messaging;304 19.8;13.8 Interaction diagrams;305 19.9;13.9 Activity diagrams;307 19.10;13.10 Chapter summary;308 19.11;13.11 Problems and issues for discussion;308 19.12;13.12 Suggestions for reading;309 20;14 Object-oriented approach for real-time systems;310 20.1;14.1 Chapter overview;310 20.2;14.2 Real-time object-oriented design and development;310 20.3;14.3 Designing for real-time;311 20.4;14.4 Objects, objects;312 20.5;14.5 Finding the objects;313 20.6;14.6 Analysis class stereotypes;314 20.7;14.7 Tasking;315 20.8;14.8 Multi-threading with Java;316 20.9;14.9 Design patterns;318 20.10;14.10 Chapter summary;321 20.11;14.11 Problems and issues for discussion;322 20.12;14.12 Suggestions for reading;322 21;15 System integrity;324 21.1;15.1 Chapter overview;324 21.2;15.2 Software crisis;324 21.3;15.3 Fault tolerance;326 21.4;15.4 System requirements;327 21.5;15.5 Requirements analysis techniques;328 21.6;15.6 Verification and validation;329 21.7;15.7 Good design;329 21.8;15.8 Simulation studies;330 21.9;15.9 Petri nets;331 21.10;15.10 Design for security source code checking: lint;334 21.11;15.11 Code reuse;334 21.12;15.12 Compile-time checking;335 21.13;15.13 Code testing;335 21.14;15.14 System integration testing;336 21.15;15.15 Run-time error trapping;337 21.16;15.16 Run-time checking: assert;338 21.17;15.17 Run-time checking: exceptions and hardware watchdog;339 21.18;15.18 Run-time checking: stack length checking;340 21.19;15.19 Visual assistance;340 21.20;15.20 A wet Monday morning;341 21.21;15.21 Concurrent version control system (CVS);342 21.22;15.22 Setting up a CVS repository;344 21.23;15.23 Conducting design and code reviews;345 21.24;15.24 Extreme Programming;346 21.25;15.25 Software standards;347 21.26;15.26 MISRA;349 21.27;15.28 Chapter summary;351 21.28;15.29 Problems and issues for discussion;351 21.29;15.30 Suggestions for Reading;352 22;16 Langua
ges for RTS development C, Ada and Java;354 22.1;16.1 Chapter overview;354 22.2;16.2 The choice;354 22.3;16.3 General criteria for programming languages;355 22.4;16.4 Special criteria for real-time compilers;357 22.5;16.5 Compiler optimization;360 22.6;16.6 C for real-time;363 22.7;16.7 Ada;364 22.8;16.8 Java;365 22.9;16.9 Cross-compilers;369 22.10;16.10 Chapter summary;369 22.11;16.11 Problems and issues for discussion;369 22.12;16.12 Suggestions for reading;370 23;17 Cross-development techniques;371 23.1;17.1 Chapter overview;371 23.2;17.2 Hosttarget development;371 23.3;17.3 Cross-compilers and linkers;372 23.4;17.4 The gcc compilation process;373 23.5;17.5 Startup code;374 23.6;17.6 GNU linker, ld and linker script file;377 23.7;17.7 Entry point;380 23.8;17.8 Building a gcc cross-compiler;380 23.9;17.9 Tips!;385 23.10;17.10 Executable and Linking Format (ELF);386 23.11;17.11 C++ global constructors and destructors in ELF;390 23.12;17.12 Debugging techniques;390 23.13;17.13 Program memory options;399 23.14;17.14 Flash memory;399 23.15;17.15 Installing target code;401 23.16;17.16 Chapter summary;403 23.17;17.17 Problems and issues for discussion;404 23.18;17.18 Suggestions for reading;404 24;18 Microcontroller embedded systems;406 24.1;18.1 Chapter overview;406 24.2;18.2 Microprocessors and microcontrollers;406 24.3;18.3 Intel 8051 8 bit family;407 24.4;18.4 Automatic vending technology;410 24.5;18.5 ARM 32 bit family;412 24.6;18.6 StrongARM processor;412 24.7;18.7 Puppeteer StrongARM microcomputer;415 24.8;18.8 Application;417 24.9;18.9 FPGA usage;419 24.10;18.10 Serial access memory;419 24.11;18.11 Chapter summary;420 24.12;18.12 Problems and issues for discussion;420 24.13;18.13 Suggestions for reading;421 25;19 Linux device drivers;423 25.1;19.1 Chapter overview;423 25.2;19.2 Embedded Linux;423 25.3;19.3 Porting Linux;424 25.4;19.4 The role of device drivers;428 25.5;19.5 Major and minor numbers;429 25.6;19.6 Index blocks, the Unix inode;431 25.7;19.7 Types of
Linux device drivers;437 25.8;19.8 The new devfs;445 25.9;19.9 Chapter summary;445 25.10;19.10 Problems and issues for discussion;446 25.11;19.11 Suggestions for reading;446 26;20 Hardware/software co-design;448 26.1;20.1 Chapter overview;448 26.2;20.2 Systems-on-chip;448 26.3;20.3 Intellectual property;449 26.4;20.4 Reconfigurable hardware;450 26.5;20.5 Software support;452 26.6;20.6 Altera APEX/Excalibur device;453 26.7;20.7 Processor cores;456 26.8;20.8 Chapter summary;456 26.9;20.9 Problems and issues for discussion;456 26.10;20.10 Suggestions for reading;457 27;Appendix A: Using an oscilloscope for software debugging;458 27.1;A1.1 Overview;458 27.2;A1.2 Using an oscilloscope;458 27.3;A1.3 Turning on an analogue CRT scope;458 27.4;A1.4 Introduction to the oscilloscope;460 27.5;A1.5 Digital storage scopes;461 28;Index;464 28.1;A;464 28.2;B;464 28.3;C;464 28.4;D;465 28.5;E;465 28.6;F;465 28.7;G;465 28.8;H;465 28.9;I;465 28.10;J;466 28.11;K;466 28.12;L;466 28.13;M;466 28.14;N;466 28.15;O;466 28.16;P;466 28.17;Q;467 28.18;R;467 28.19;S;467 28.20;T;467 28.21;U;467 28.22;V;468 28.23;W;468 28.24;X;468 28.25;Y;468