ebook img

Real-time embedded components and systems : with Linux and RTOS PDF

483 Pages·2016·8.78 MB·English
by  
Save to my drive
Quick download
Download
Most books are stored in the elastic cloud where traffic is expensive. For this reason, we have a limit on daily download.

Preview Real-time embedded components and systems : with Linux and RTOS

R -T EAL IME E MBEDDED C OMPONENTS S AND YSTEMS with L and RTOS INUX Sam Siewert John Pratt MERCURY LEARNING AND INFORMATION Dulles, Virginia Boston, Massachusetts New Delhi Copyright ©2016 by Mercury Learning And Information LLC. All rights reserved. This publication, portions of it, or any accompanying software may not be reproduced in any way, stored in a retrieval system of any type, or transmitted by any means, media, electronic display or mechanical display, including, but not limited to, photocopy, recording, Internet postings, or scanning, without prior permission in writing from the publisher. Publisher: David Pallai Mercury Learning and Information 22841 Quicksilver Drive Dulles, VA 20166 [email protected] www.merclearning.com (800) 232-0223 S. Siewert and J. Pratt. Real-Time Embedded Components and Systems with LINUX and RTOS. ISBN: 978-1-942270-04-1 The publisher recognizes and respects all marks used by companies, manufacturers, and developers as a means to distinguish their products. All brand names and product names mentioned in this book are trademarks or service marks of their respective companies. Any omission or misuse (of any kind) of service marks or trademarks, etc. is not an attempt to infringe on the property of others. Library of Congress Control Number: 2015944870 151617321 This book is printed on acid-free paper. Our titles are available for adoption, license, or bulk purchase by institutions, corporations, etc. For additional information, please contact the Customer Service Dept. at 800-232-0223(toll free). All of our titles are available in digital format at authorcloudware.com and other digital vendors. Companion fi les (fi gures and code listings) for this title are available by contacting [email protected]. The sole obligation of Mercury Learning and Information to the purchaser is to replace the disc, based on defective materials or faulty workmanship, but not based on the operation or functionality of the product. LICENSE, DISCLAIMER OF LIABILITY, AND LIMITED WARRANTY By purchasing or using this book (the “Work”), you agree that this license grants permission to use the contents contained herein, but does not give you the right of ownership to any of the textual content in the book or ownership to any of the information or products contained in it. This license does not permit uploading of the Work onto the Internet or on a network (of any kind) without the writ- ten consent of the Publisher. Duplication or dissemination of any text, code, simulations, images, etc. contained herein is limited to and subject to licensing terms for the respective products, and permission must be obtained from the Publisher or the owner of the content, etc., in order to reproduce or network any portion of the textual material (in any media) that is contained in the Work. Mercury Learning And Information (“MLI” or “the Publisher”) and any- one involved in the creation, writing, or production of the companion disc, ac- companying algorithms, code, or computer programs (“the software”), and any accompanying Web site or software of the Work, cannot and do not warrant the performance or results that might be obtained by using the contents of the Work. The author, developers, and the Publisher have used their best ef- forts to insure the accuracy and functionality of the textual material and/or pro- grams contained in this package; we, however, make no warranty of any kind, express or implied, regarding the performance of these contents or programs. The Work is sold “as is” without warranty (except for defective materials used in manufacturing the book or due to faulty workmanship). The author, developers, and the publisher of any accompanying content, and anyone involved in the composition, production, and manufacturing of this work will not be liable for damages of any kind arising out of the use of (or the inability to use) the algorithms, source code, computer programs, or textual material contained in this publication. This includes, but is not limited to, loss of revenue or profi t, or other incidental, physical, or consequential damages arising out of the use of this Work. The sole remedy in the event of a claim of any kind is expressly limited to re- placement of the book, and only at the discretion of the Publisher. The use of “implied warranty” and certain “exclusions” vary from state to state, and might not apply to the purchaser of this product. PREFACE This book is intended to provide the practicing engineer with the necessary background to apply real-time theory to the design of embedded components and systems in order to successfully field a real-time embedded system. The book also is intended to provide a senior-year undergraduate or first-year grad- uate student in electrical engineering, computer science, or related fields of study with a balance of fundamental theory, review of industry practice, and hands-on experience to prepare for a career in the real-time embedded system industries. Typical industries include aerospace, medical diagnostic and thera- peutic systems, telecommunications, automotive, robotics, industrial process control, media systems, computer gaming, and electronic entertainment, as well as multimedia applications for general-purpose computing. Real-time sys- tems have traditionally been fielded as hard real-time applications, such as digi- tal flight control systems, antilock braking systems, and missile guidance. More recently, however, intense interest in soft real-time systems has arisen due to the quickly growing market for real-time digital media services and systems. This updated edition adds three new chapters focused on key technology ad- vancements in embedded systems and with wider coverage of real-time archi- tectures. The overall focus remains the RTOS (Real-Time Operating System), but use of Linux for soft real-time, hybrid FPGA (Field Programmable Gate Array) architectures and advancements in multi-core system-on-chip (SoC), as well as software strategies for asymmetric and symmetric multiprocessing (AMP and SMP) relevant to real-time embedded systems, has been added. Specifically, a new Chapter 9 provides an overview of RTOS advancements, including AMP and SMP configurations, with a discussion of future directions for RTOS use in multi-core architectures, such as SoC. A new Chapter 10 is devoted to open source RTOS, with emphasis on FreeRTOS. A new Chapter 11 is focused on methods to integrate embedded Linux into real-time embed- ded systems, with emphasis on soft real-time requirements, methods to patch and improve the Linux kernel for predictable response, and finally best prac- tices for implementation of real-time services and applications that make use of POSIX real-time extensions in the 1003.1 2013 standard. The original Chapters 9, 10, and 11 have been preserved and are now Chapters 12 to 14, and Part III remains unchanged other than chapter renumbering to accommodate the insertion of the new chapters. xii (cid:129) PREFACE John Pratt, a new co-author, has contributed extensively to this edition, with specific focus on FreeRTOS, and brings a unique perspective to this updated version with his commercial mobile embedded systems expertise. The new Linux examples and extended coverage of Linux in this edition are based upon a summer version of the course Real-Time Embedded Systems taught at the University of Colorado, Boulder, to offer an alternative to the tra- ditional fall course that has used the Wind River VxWorks RTOS. The summer course has emphasized the same hard and soft real-time theory, but practice has focused on using Linux to achieve predictable response for systems that require real-time, but where occasional missed deadlines are not catastrophic. For example, mobile digital media, augmented reality applications, computer vision and digital entertainment and interactive systems. While hard real-time mission critical systems are still a major concern, many emergent applications require predictable response and simply need to provide high-quality of ser- vice. The use of buffering and time stamps to work ahead and provide high- quality presentation of results is, for example, a method used in digital video encode, transport, and decode, where the systems software is not required to provide deterministic proven hard real-time processing, as has been the goal for the RTOS. Likewise, many systems today use best-effort or soft real-time embedded Linux configurations with coprocessors, either FPGA or ASIC (Ap- plication Specific Integrated Circuits), that provide guaranteed hard real-time processing with hardware state machines. Numerous improvements and corrections have been made to the original edition text to improve readability and clarity based on excellent feedback by many undergraduate and graduate students at the University of Colorado who have used the original edition text since August 2006. While it’s impossible to keep up with all the advancements related to real- time embedded systems, we hope the reader will find the new chapters and expanded example material included on the DVD a useful extension to tradi- tional cyclic executive and RTOS real-time system components and systems architecture. The expanded guidelines and strategies are intended to help the practicing engineer and to introduce advanced undergraduate and graduate students in computer and software engineering disciplines to design strategies and methods to tackle many of the challenges found in real-time embedded systems. This challenging engineering area continues to evolve and relies upon the careful validation and verification efforts of practicing engineers to ensure and balance safety, cost, and capabilities of these complex and critical applica- tions on which we all depend. PREFACE (cid:129) xiii Companion Files Companion files (figures and code listings) for this title are also available by contacting [email protected]. Sam Siewert December 2015 CONTENTS Preface xi Acknowledgments xv Part I: Real-Time Embedded Theory Chapter 1 Introduction 3 1.1 Introduction 3 1.2 A Brief History of Real-Time Systems 4 1.3 A Brief History of Embedded Systems 7 1.4 Real-Time Services 7 1.5 Real-Time Standards 16 Summary 18 Exercises 18 Chapter References 19 Chapter 2 System Resources 21 2.1 Introduction 21 2.2 Resource Analysis 23 2.3 Real-Time Service Utility 31 2.4 Scheduling Classes 38 2.4.1 Multiprocessor Systems 39 2.5 The Cyclic Executive 39 2.6 Scheduler Concepts 41 2.6.1 Preemptive vs. Non-preemptive Schedulers 44 2.6.2 Preemptive Fixed-Priority Scheduling Policy 47 2.7 Real-Time Operating Systems 50 2.8 Thread-Safe Reentrant Functions 59 Summary 61 Exercises 62 Chapter References 64 Chapter 3 Processing 67 3.1 Introduction 67 3.2 Preemptive Fixed-Priority Policy 68 3.3 Feasibility 72 3.4 Rate-Monotonic Least Upper Bound 73 3.5 Necessary and Sufficient Feasibility 84 3.5.1 Scheduling Point Test 84 3.5.2 Completion Time Test 87 vi (cid:129) CONTENTS 3.6 Deadline-Monotonic Policy 89 3.7 Dynamic-Priority Policies 91 Summary 95 Exercises 96 Chapter References 98 Chapter 4 Resources 99 4.1 Introduction 99 4.2 Worst-Case Execution Time 100 4.3 Intermediate IO 104 4.4 Execution Efficiency 107 4.5 IO Architecture 110 Summary 111 Exercises 112 Chapter References 113 Chapter 5 Memory 115 5.1 Introduction 115 5.2 Physical Hierarchy 116 5.3 Capacity and Allocation 120 5.4 Shared Memory 120 5.5 ECC Memory 121 5.6 Flash File Systems 126 Summary 127 Exercises 128 Chapter References 128 C hapter 6 Multiresource Services 129 6.1 Introduction 129 6.2 Blocking 130 6.3 Deadlock and Livelock 130 6.4 Critical Sections to Protect Shared Resources 132 6.5 Priority Inversion 132 6.5.1 Unbounded Priority Inversion Solutions 134 6.6 Power Management and Processor Clock Modulation 138 Summary 139 Exercises 139 Chapter References 140 Chapter 7 Soft Real-Time Services 141 7.1 Introduction 141 7.2 Missed Deadlines 142 7.3 Quality of Service 143 7.4 Alternatives to Rate-Monotonic Policy 144 CONTENTS (cid:129) vii 7.5 Mixed Hard and Soft Real-Time Services 147 Summary 148 Exercises 148 Chapter References 149 Part II: Designing Real-Time Embedded Components Chapter 8 Embedded System Components 153 8.1 Introduction 153 8.2 Hardware Components 155 8.2.1 Sensors 155 8.2.2 Actuators 158 8.2.3 IO Interfaces 159 8.2.4 Processor Complex or SoC 163 8.2.5 Processor and IO Interconnection 164 8.2.6 Bus Interconnection 165 8.2.7 High-Speed Serial Interconnection 170 8.2.8 Low-Speed Serial Interconnection 172 8.2.9 Interconnection Systems 173 8.2.10 Memory Subsystems 174 8.3 Firmware Components 176 8.3.1 Boot Code 176 8.3.2 Device Drivers 177 8.3.3 Operating System Services 178 8.4 RTOS System Software 178 8.4.1 Message Queues 179 8.4.2 Binary Semaphores 180 8.4.3 Mutex Semaphores 181 8.4.4 Software Virtual Timers 181 8.4.5 Software Signals 182 8.5 Software Application Components 182 8.5.1 Application Services 182 8.5.2 Reentrant Application Libraries 185 8.5.3 Communicating and Synchronized Services 186 Summary 188 Exercises 188 Chapter References 189 Chapter 9 Traditional Hard Real-Time Operating Systems 191 9.1 Introduction 191 9.2 Evolution of Real-Time Scheduling and Resource Management 192 9.3 AMP (Asymmetric Multi-core Processing) 194 9.4 SMP (Symmetric Multi-core Processing) 199 viii (cid:129) CONTENTS 9.5 Processor Core Affinity 200 9.6 Future Directions for RTOS 216 9.7 SMP Support Models 217 9.8 RTOS Hypervisors 218 Summary 219 Exercises 219 Chapter References 220 Chapter 10 Open Source Real-Time Operating Systems 221 10.1 FreeRTOS Alternative to Proprietary RTOS 221 10.2 FreeRTOS Platform and Tools 225 10.3 FreeRTOS Real-Time Service Programming Fundamentals 228 Exercises 235 Chapter References 235 Chapter 11 Integrating Embedded Linux into Real-Time Systems 237 11.1 Introduction 237 11.2 Embedding Mainline Linux: Interactive and Best-Effort 238 11.3 Linux as a Non-Real-Time Management and User Interface Layer 244 11.4 Methods to Patch and Improve Linux for Predictable Response 245 11.5 Linux for Soft Real-Time Systems 249 11.6 Tools for Linux for Soft Real-Time Systems 249 Summary 250 Exercises 250 Chapter References 251 Chapter 12 Debugging Components 253 12.1 Introduction 253 12.2 Exceptions 254 12.3 Assert 262 12.4 Checking Return Codes 263 12.5 Single-Step Debugging 264 12.6 Kernel Scheduler Traces 273 12.7 Test Access Ports 278 12.8 Trace Ports 280 12.9 Power-On Self-Test and Diagnostics 282 12.10 External Test Equipment 287 12.11 Application-Level Debugging 291 Summary 292 Exercises 293 Chapter References 293

Description:
This book is intended to provide a senior undergraduate or graduate student in electrical engineering or computer science with a balance of fundamental theory, review of industry practice, and hands-on experience to prepare for a career in the real-time embedded system industries. It is also intende
See more

The list of books you might like

Most books are stored in the elastic cloud where traffic is expensive. For this reason, we have a limit on daily download.