Docsity

Real-Time Concepts for Embedded Systems, Study notes of Embedded Systems

Partial preview of the text

Download Real-Time Concepts for Embedded Systems and more Study notes Embedded Systems in PDF only on Docsity!

Real-Time Concepts

for

Embedded Systems

Qing Li

with Caroline Yao

San Francisco, CA • New York, NY • Lawrence, KS

To my wife, Huaying, and my daughter, Jane, for their love, understanding, and support.

To my parents, Dr. Y. H. and Dr. N. H. Li, and my brother, Dr. Yang Li, for being the exemplification of academic excellence.

“The book has a very good balance between the theory and practice of real-time embedded system designs. Most other books on real-time systems concentrate on theory without practical experi- ence or have a focus on design examples without the theoretical background.”

—Jun-ichiro itojun Hagino, Ph.D., Research Laboratory, Internet Initiative Japan Inc., IETF IPv Operations Working Group (v6ops) co-chair

“A clear, concise, and comprehensive introduction to embedded and pervasive computing. This book should be required reading for any engineer or product manager entering or looking to grow in the embedded marketplace. Beginning with basic concepts, Qing Li provides exceptional detail taking the new embedded reader to whatever level of granularity they require or would find inter- esting. Qing Li introduces the concept of embedded designs and clearly illustrates the differences between non-real-time and soft and hard real-time requirements. Taking the RTOS concept from its component structure (e.g., scheduler, objects, and services), he delves into great detail with each sub-component. His sections on I/O, exception handling, and protocol stacks create a comprehen- sive presentation for the embedded ‘newbee’ as well as the intermediate-level embedded devel- oper.”

—Jerry Krasner, Ph.D., MBA., vice-president, industry analyst, and consultant, Embedded Market Forecasters

“This book has comprehensive, practical, updated, and easy-to-understand content about real-time embedded computer systems. I strongly believe that the knowledge, theory, and concepts explained in this book are quite important not only for the engineers who design the real-time sys- tems and students in computer science and robotics departments, but also for every user of real-time embedded systems—especially a communication network operator, system administrator, or machinery engineer.”

—Dr. Shin Miyakawa, senior research manager, IPv6 Group, Innovative IP Architecture Center, NTT Communications Corporation

vi T ABLE OF C ONTENTS

ix

F OREWORD

We live in a world today in which software plays a critical part. The most critical soft- ware is not running on large systems and PCs. Rather, it runs inside the infrastructure and in the devices that we use every day. Our transportation, communications, and energy systems won’t work if the embedded software contained in our cars, phones, routers and power plants crashes. The design of this invisible, embedded software is crucial to all of us. Yet, there has been a real shortage of good information as to effective design and implementation practices specific to this very different world. Make no mistake, it is indeed different and often more difficult to design embedded software than more traditional programs. Time, and the interaction of multiple tasks in real-time, must be managed. Seemingly esoteric con- cepts, such as priority inversion, can become concrete in a hurry when they bring a device to its knees. Efficiency—a small memory footprint and the ability to run on lower cost hardware—become key design considerations because they directly affect cost, power usage, size, and battery life. Of course, reliability is paramount when so much is at stake—company and product reputations, critical infrastructure functions, and, some- times, even lives. Mr. Li has done a marvelous job of pulling together the relevant information. He lays out the issues, the decision and design process, and the available tools and methods. The latter part of the book provides valuable insights and practical experiences in under- standing application development, common design problems, and solutions. The book will be helpful to anyone embarking on an embedded design project, but will be of par- ticular help to engineers who are experienced in software development but not yet in real-time and embedded software development. It is also a wonderful text or reference volume for academic use. The quality of the pervasive, invisible software surrounding us will determine much about the world being created today. This book will have a positive effect on that quality and is a welcome addition to the engineering bookshelf.

Jerry Fiddler Chairman and Co-Founder, Wind River

x F OREWORD

This Page Intentionally Left Blank

xii P REFACE

I hope that Real-Time Concepts for Embedded Systems will become a key reference for you as you embark upon your development endeavors.

If you would like to sign up for e-mail news updates, please send a blank e-mail to: [email protected]. If you have a suggestion, correction, or addition to make to the book, e-mail me at [email protected]

Audience for this Book

This book is oriented primarily toward junior to intermediate software developers work- ing in the realm of embedded computing. If you are an experienced developer but new to real-time embedded systems develop- ment, you will also find the approach to design in this book quite useful. If you are a technical manager who is active in software design reviews of real-time systems, you can refer to this book to become better informed regarding the design and implementation phases. This book can also be used as complementary reference material if you are an engineering or computer science student. Before using this book, you should be proficient in at least one programming language and should have some exposure to the software-development process.

Acknowledgments

We would like to thank the team at CMP Books and especially Paul Temme, Michelle O’Neal, Marc Briand, Brandy Ernzen, and Robert Ward. We wish to express our thanks to the reviewers Jerry Krasner, Shin Miyakawa, Jun-ichiro itojun Hagino, and Liliana Britvic for their contributions. We would like to thank Nauman Arshad for his initial participation on this project. We would also like to thank Anne-Marie Eileraas, Salvatore LiRosi, Loren Shade, and numerous other individuals at Wind River for their support. Finally, thanks go to our individual families for their love and support, Huaying and Jane Lee, Maya and William Yao.

C HAPTER 1

I NTRODUCTION

In ways virtually unimaginable just a few decades ago, embedded systems are reshaping the way people live, work, and play. Embedded systems come in an endless variety of types, each exhibiting unique characteristics. For example, most vehicles driven today embed intelligent computer chips that perform value-added tasks, which make the vehi- cles easier, cleaner, and more fun to drive. Telephone systems rely on multiple integrated hardware and software systems to connect people around the world. Even private homes are being filled with intelligent appliances and integrated systems built around embedded systems, which facilitate and enhance everyday life. Often referred to as pervasive or ubiquitous computers, embedded systems represent a class of dedicated computer systems designed for specific purposes. Many of these embedded systems are reliable and predictable. The devices that embed them are conve- nient, user-friendly, and dependable. One special class of embedded systems is distinguished from the rest by its requirement to respond to external events in real time. This category is classified as the real-time embedded system. As an introduction to embedded systems and real-time embedded systems, this chapter focuses on:

  • examples of embedded systems,
  • defining embedded systems,
  • defining embedded systems with real-time behavior, and
  • current trends in embedded systems.

In this chapter...

- Real Life Examples of Embedded _Systems........................ 2

  • Real-Time Embedded Systems...... 10
  • The Future of Embedded Systems... 16
  • Points to Remember.............. 17_

Real Life Examples of Embedded Systems 3

1.1.2 Embedded Systems in the Work Environment Embedded systems have also changed the way people conduct business. Perhaps the most significant example is the Internet, which is really just a very large collection of embedded systems that are interconnected using various networking technologies. Figure 1.2 illustrates what a small segment of the Internet might look like. From various individual network end-points (for example, printers, cable modems, and enterprise network routers) to the backbone gigabit switches, embedded technology has helped make use of the Internet necessary to any business model. The network routers and the backbone gigabit switches are examples of real-time embedded systems. Advancements in real-time embedded technology are making Internet connectivity both reliable and responsive, despite the enormous amount of voice and data traffic carried over the network.

Figure 1.2 Embedded systems at work.

4 C HAPTER 1: I NTRODUCTION

1.1.3 Embedded Systems in Leisure Activities At home, at work, even at play, embedded systems are flourishing. A child’s toy unexpectedly springs to life with unabashed liveliness. Automobiles equipped with in-car navigation systems transport peo- ple to destinations safely and effi- ciently. Listening to favorite tunes with anytime-anywhere freedom is readily achievable, thanks to embedded systems buried deep within sophisticated portable music players, as shown in Figure 1.3. Even the portable computing device, called a web tablet , shown in Figure 1.4, is an embedded system. Embedded systems also have teamed with other technologies to deliver benefits to the tradition- ally low-tech world. GPS technology, for exam- ple, uses satellites to pinpoint locations to centimeter-level accuracy, which allows hikers, cyclists, and other outdoor enthusiasts to use GPS handheld devices to enjoy vast spaces with- out getting lost. Even fishermen use GPS devices to store the locations of their favorite fishing holes. Embedded systems also have taken traditional radio-controlled airplanes, racecars, and boats to new heights…and speeds. As complex embedded systems in disguise, these devices take command inputs from joysticks and pass them wirelessly to the device’s receiver, enabling the model airplane, racecar, or boat to engage in speedy and complex maneuvers. In fact, the introduction of embedded technology has rendered these sports safer and more enjoyable for model owners by vir- tually eliminating the once-common threat of crashing due to signal interference.

1.1.4 Defining the Embedded System Some texts define embedded systems as computing systems or devices without a key- board, display, or mouse. These texts use the “look” characteristic as the differentiating factor by saying, “embedded systems do not look like ordinary personal computers; they look like digital cameras or smart toasters.” These statements are all misleading.

Figure 1.3 Navigation system and portable music

player.

Figure 1.4 A web tablet.

6 C HAPTER 1: I NTRODUCTION

provide interfaces to support a variety of external peripheral devices. These processors result in large power consumption, heat production, and size. The complexity means these processors are also expensive to fabricate. In the early days, embedded systems were commonly built using general-purpose processors. Because of the quantum leap in advancements made in microprocessor technology in recent years, embedded systems are increasingly being built using embedded processors instead of general-purpose processors. These embedded processors are special-purpose processors designed for a specific class of applications. The key is application awareness, i.e., knowing the nature of the applications and meeting the requirement for those appli- cations that it is designed to run. One class of embedded processors focuses on size, power consumption, and price. Therefore, some embedded processors are limited in functionality, i.e., a processor is good enough for the class of applications for which it was designed but is likely inade- quate for other classes of applications. This is one reason why many embedded proces- sors do not have fast CPU speeds. For example, the processor chosen for a personal digital assistant (PDA) device does not have a floating-point co-processor because float- ing-point operations are either not needed or software emulation is sufficient. The pro- cessor might have a 16-bit addressing architecture instead of 32-bit, due to its limited memory storage capacity. It might have a 200MHz CPU speed because the majority of the applications are interactive and display-intensive, rather than computation-intensive. This class of embedded processors is small because the overall PDA device is slim and fits in the palm of your hand. The limited functionality means reduced power consump- tion and long-lasting battery life. The smaller size reduces the overall cost of processor fabrication. On the other hand, another class of embedded processors focuses on performance. These embedded processors are powerful and packed with advanced chip-design tech- nologies, such as advanced pipeline and parallel processing architecture. These proces- sors are designed to satisfy those applications with intensive computing requirements not achievable with general-purpose processors. An emerging class of highly specialized and high-performance embedded processors includes network processors developed for the network equipment and telecommunications industry. Overall, system and applica- tion speeds are the main concerns. Yet another class of embedded processors focuses on all four requirements—perfor- mance, size, power consumption, and price. Take, for example, the embedded digital sig- nal processor (DSP) used in cell phones. Real-time voice communication involves digital signal processing and cannot tolerate delays. A DSP has specialized arithmetic units, optimized design in the memory, and addressing and bus architectures with multipro- cessing capability that allow the DSP to perform complex calculations extremely fast in real time. A DSP outperforms a general-purpose processor running at the same clock speed many times over comes to digital signal processing. These reasons are why DSPs, instead of general-purpose processors, are chosen for cell phone designs. Even though

Real Life Examples of Embedded Systems 7

DSPs are incredibly fast and powerful embedded processors, they are reasonably priced, which keeps the overall prices of cell phones competitive. The battery from which the DSP draws power lasts for hours and hours. A cell phone under $100 fits in half the palm-size of an average person at the time this book was written.

System-on-a-chip (SoC) processors are especially attractive for embedded systems. The SoC processor is comprised of a CPU core with built-in peripheral modules, such as a programmable general-purpose timer, programmable interrupt controller, DMA con- troller, and possibly Ethernet interfaces. Such a self-contained design allows these embedded proces- sors to be used to build a variety of embedded appli- cations without needing additional external peripheral devices, again reducing the overall cost and size of the final product.

1.1.6 Hardware and Software

Co-Design Model

Commonly both the hardware and the software for an embedded system are developed in parallel. Con- stant design feedback between the two design teams should occur in this development model. The result is that each side can take advantage of what the other can do. The software component can take advantage of special hardware features to gain per- formance. The hardware component can simplify module design if functionality can be achieved in software that reduces overall hardware complexity and cost. Often design flaws, in both the hardware and software, are uncovered during this close collab- oration.

The hardware and software co-design model reemphasizes the fundamental characteris- tic of embedded systems—they are application-specific. An embedded system is usually built on custom hardware and software. Therefore, using this development model is both permissible and beneficial.

1.1.7 Cross-Platform Development

Another typical characteristic of embedded systems is its method of software develop- ment, called cross-platform development , for both system and application software. Soft- ware for an embedded system is developed on one platform but runs on another. In this

Sometimes a gray area exists when using processor type to differentiate between embed- ded and non-embedded sys- tems. It is worth noting that, in large-scale, high-performance embedded systems, the choice between embedded processors and universal microprocessors is a difficult one. In high-end embedded systems, system performance in a pre- defined context outweighs power consumption and cost. The choice of a high-end, general purpose processor is as good as the choice of a high-end, special- ized embedded processor in some designs. Therefore, using processor type alone to classify embedded systems may result in wrong classifications.