Book contents
- Frontmatter
- Dedication
- Contents
- Preface
- Annotated Table of Contents
- Acknowledgments
- Part I Overview
- Part II Real-Time Software Design Method
- Part III Analysis of Real-Time Software Designs
- Part IV Real-Time Software Design Case Studies for Embedded Systems
- Appendix A Conventions Used in This Textbook
- Appendix B Catalog of Software Architectural Patterns
- Appendix C Pseudocode Templates for Concurrent Tasks
- Appendix D Teaching Considerations
- Glossary
- Bibliography
- Index
Appendix C - Pseudocode Templates for Concurrent Tasks
Published online by Cambridge University Press: 05 March 2016
- Frontmatter
- Dedication
- Contents
- Preface
- Annotated Table of Contents
- Acknowledgments
- Part I Overview
- Part II Real-Time Software Design Method
- Part III Analysis of Real-Time Software Designs
- Part IV Real-Time Software Design Case Studies for Embedded Systems
- Appendix A Conventions Used in This Textbook
- Appendix B Catalog of Software Architectural Patterns
- Appendix C Pseudocode Templates for Concurrent Tasks
- Appendix D Teaching Considerations
- Glossary
- Bibliography
- Index
Summary
This appendix provides pseudocode templates of the event sequencing logic for the different kinds of concurrent tasks described in Chapter 13 of this textbook. These templates include event driven input tasks; periodic input and algorithm tasks; and demand driven general purpose, coordinator, output, user interaction, and state dependent control tasks.
PSEUDOCODE FOR EVENT DRIVEN INPUT TASK
An event driven input task is needed when there is an event driven (also referred to as interrupt-driven) input device to which the system has to interface (Section 13.3.2). The event driven I/O task is activated by an external event (such as an interrupt) from the device, reads the input data, does any necessary processing of the data, including sending a message to a consumer or updating a passive entity object, and then waits for the next external event.
Initialize input device, if needed;
loop
–– Wait for external event from input device;
wait (inputEvent);
read input data;
if data is recognized
then –– Process data;
convert data to internal format if needed,
e.g., convert analog data to engineering units;
process data, if needed;
prepare message containing message name and optional parameters
–– send message to consumer task via connector;
aConnector.send (message);
else –– input was not recognized;
Handle error case;
end if;
end loop;
PSEUDOCODE FOR PERIODIC INPUT TASK
A periodic input task interfaces with a passive input device, where the device is polled on a regular basis (Section 13.3.3). The periodic input task is activated by a timer event, reads the sampled input data, does any necessary processing of the data, and then waits for the next timer event. The task's period is the time between successive activations.
Initialize input device, if needed;
loop
–– Wait for timer event;
wait (timerEvent);
read input data sample;
if data is recognized
then –– Process input data;
convert data to internal format if needed,
e.g., convert analog data to engineering units;
If Boolean data, check if data has changed from previous reading;
process data, if needed;
prepare message containing message name and optional parameters
–– send message to consumer or write to data repository;
dataRepository.update(newData);
else –– input was not recognized;
Handle error case;
end if;
end loop;
- Type
- Chapter
- Information
- Real-Time Software Design for Embedded Systems , pp. 551 - 556Publisher: Cambridge University PressPrint publication year: 2016