Embedded Multitasking

Embedded Multitasking

by Keith E. Curtis

View All Available Formats & Editions

In an embedded system, firmware is the software that directly interfaces with the microcontroller, controlling the system’s function. The major forces driving the embedded firmware development process today are reduced development times, increased complexity, and the need to handle multiple tasks simultaneously. These forces translate into strenuous design


In an embedded system, firmware is the software that directly interfaces with the microcontroller, controlling the system’s function. The major forces driving the embedded firmware development process today are reduced development times, increased complexity, and the need to handle multiple tasks simultaneously. These forces translate into strenuous design requirements for embedded engineers and programmers. Many low-level embedded microcontroller designs have insufficient memory and/or architectural limitations that make the use of a real-time operating system impractical. The techniques presented in this book allow the design of robust multitasking firmware through the use of interleaved state machines. This book presents a complete overview of multitasking terminology and basic concepts. Practical criteria for task selection and state machine design are also discussed.
Designing multitasking firmware is arduous, complex and fraught with potential for errors, and there is no one, “standard” way to do it. This book will present a complete and well-organized design approach with examples and sample source code that designers can follow.

• Covers every aspect of design from the system level to the component level, including system timing, communicating with the hardware, integration and testing.
• Accompanying companion website contains the source code for the text examples and other useful design tools.

Product Details

Elsevier Science
Publication date:
Embedded Technology Series
Edition description:
Product dimensions:
7.40(w) x 9.10(h) x 1.10(d)

Read an Excerpt

Embedded Multitasking

By Keith Curtis


Copyright © 2006 Elsevier Inc.
All right reserved.

ISBN: 978-0-08-049471-5

Chapter One

What's In This Book, and Why Should I Read It?

When I told my friends that I was writing a book, several of them told me that I had to have a very good opening. "A good opening," they said, "fires the reader's imagination and draws them into the book." The theory being, I suppose, if the reader is drawn in, then they will have to buy the book.

Well, being an engineer, I very seldom say things that fire the imagination. In fact, at parties, most people's eyes tend to glaze over right after I tell them I am an engineer. So, I have decided instead to appeal to the universal sense of enlightened self-interest. In short, I will begin this book by demonstrating why good programming is in the best interest of every software designer. Now, it may not get you a cubicle with a window, or even an office with a door. But I can promise that producing products that are not profitable is the surest way to become unemployed. So, while there may not be a direct cash benefit to producing profitable products, the alternative is definitely worse.

However, before we get into the explanation of profitability and engineering, we need to take a few moments and discuss some basic business concepts—specifically, how the price of a product is divided up between the various costs and profit.

If we consider a generic product, the sale price of the product is divided into two parts: the cost of producing the product and the profit on the sale. The cost of producing the product includes recurring and nonrecurring production costs, general and administrative overhead costs, cost of sales, and support costs. The profit is the difference between what the company spent to produce the product and what it was paid CSA is a registered trademark of the Canadian Standards Association. UL is a registered trademark of Underwriters Laboratories. CE is a registered trademark of The Council of the European Communities. for the product. Essentially, profit is the company's return on the investment it made in producing the product.

So, let's take a little closer look at the costs, starting with the recurring and nonrecurring production costs.

A recurring production cost is any expense that is incurred each time a product is made. It includes the cost of the materials used to produce the product and the labor expense of having workers assemble the product. It can also include the cost of packaging, printing a user's manual, license fees, even the material cost of the shrink wrap to seal up the package.

Nonrecurring production costs, on the other hand, are expenses that are incurred to enable a production run, and typically cover expenses such as investments in equipment, product testing such as Conformity European (CE®)/Underwriter's Laboratory (UL®)/Canadian Standards Association (CSA®), and materials that enable production, but are not part of the product produced. For example, the cost of the plastic used to injection mold the case for a product is a recurring cost because it is incurred each time a unit is produced. However, the cost of testing for UL acceptance, assembly benches, tools, even the mold used to produce each unit are nonrecurring costs because they are incurred just once during the production cycle.

Nonrecurring costs are also often referred to as fixed production costs, because they do not increase and decrease with the number of units produced. They can also be thought of as an investment in the production process. For instance, the cost of having a special tool produced would be considered an investment because it reduced the recurring cost through shortening the assembly time. Nonrecurring costs are also typically amortized, or divided up, over some portion of the product's lifetime. If a mold is to be used over the production of a million units, then .00001% of the cost of the mold is then added to the cost of each of the first one million units produced. Of course, the one million and first unit produced does not incur this cost, and as a result, the profit on that unit, and every one produced after it, is correspondingly higher, assuming the price and other costs remain constant.

The next cost is also typically considered a fixed cost, that being the administrative and overhead cost. This cost, typically listed as the G&A (General and Accounting), is the expense of operating a business. It includes administrative cost, including the salaries of the company executives, the secretaries, the accountants, and even the janitors. It also includes costs for services, such as electricity, water, and phones. Basically, any expense that is incurred to pay for a general support function of the company will be lumped into this category. And, like a nonrecurring production cost, it is also divided up and tacked onto the production cost of the products. However, unlike a nonrecurring production cost, it never goes away.

A similar cost to that of G&A is the cost of sales. It includes expenses for things like advertising, shipping, product promotions, customer contests, even commissions paid to salesmen. These costs are those associated with putting the product in front of the customers, either through advertising, or through placing the product on the shelf in a local store. Any cost incurred that is directly tied to the act of selling the product typically falls under this category. This is one of the few general costs that is typically allocated based on the number of units sold. So, if the cost of sales is high for a group of units, then the profits for that group of units will be correspondingly lower. As a result, management will generally pay close attention to the cost of goods sold.

The final costs are those tied to support of the product after the sale. These typically include expenses like a 24-hour support phone line, repair technicians, failure analysis, repair costs, and upgrades/bug fixes. Like G&A, support cost is also spread across the production run as a fixed expense.

Note: Because the support cost is typically treated like an overhead expense, it is often hidden from management supervision. This leads some management to the mistaken assumption that a product is reliable and well-liked by the customer when in fact there is a quality problem and customer satisfaction is dropping.

A closer look at profits reveals that it is also divided up into multiple sections. Some of the profits are spent as dividends paid out to the investors. This increases the desirability of the stock in the company and can serve to attract additional investors who, in turn, add money to the company by buying stock. Some of the profit is held as a cash reserve, to cover future equipment purchases and expansion. And, most importantly to engineering, some of the profits are used to fund new product development.

See, I told you there was a reason why engineers should have a personal interest in making sure the products they design are profitable. The larger the profit on a product, the more money will be available to fund new equipment, hire more engineers, and pay for new projects. Now, this is not to say that all of the profits will be channeled into engineering. However, it does say that if the products are not profitable, then any new product development must be paid for using borrowed money. That means that the product will not only have to repay the money, plus interest, but will also have to do that before it generates any new monies to pay for future projects.

Engineering and Profits

So, if a profitable product produces the necessary surplus of cash required to fund new projects, and if engineers are responsible for the design of the profitable products, then it falls to us as software and hardware engineers to generate designs that will produce the best product for the least cost.

OK, how do we do that? We could just increase the cost of the product. Some companies have tried this, although most who have are now owned by their competitors, so for now we will ignore that option. The better place to start is by understanding where the costs of a product come from, and then analyze what we can do as designers to minimize those costs. To do that, we have to understand the product life cycle.

A typical product has multiple phases in its lifetime. For the purpose of discussion here, we will limit this to five general phases:

1. Product definition: In this phase, the initial concept for the product is generated and market research is conducted.

2. Design: Engineering is charged with developing the product that will meet the market requirements, including performance, price and profit.

3. Initial production: The design then moves to production, where a production facility is configured to produce the design. Product support will also analyze the design at this point to determine its support requirements.

4. Sustained production: At this point in the product's life cycle, the production facility has reached its optimal production volume, and support is managing the day-to-day customer support requirements of the product.

5. End of life: At this point, the product has reached the end of its profitability. The production facility will ramp down production, and support will plan for any remaining customer support needs.

Let's start our analysis, with a quick description of each of the phases of a product's life. We can then examine the different phases to determine where changes in a design strategy can be employed to help reduce cost.

The birth of a product is in the product definition phase of its life. The marketing group within a company is generally tasked with ongoing market research, looking for new product ideas. When they find a potential product idea, they then do further research to determine how big the market is for the proposed product. What is the share of the market which the company can reasonably expect to capture? What features will the product need to be successful in the market? And what price point is needed to capture the anticipated market share?

Estimating the total size of a potential market is somewhat of an art, and I am certainly not qualified to either explain or critique the process. For our purposes here, just take it for granted that the marketing group is well versed in the subject and that their evaluation will result in a reasonably accurate estimate of the total number of products that the proposed market will demand and the expected market share that the company can expect to capture. They will also estimate the minimal number of features required by potential users and the optimal price point that will allow capture of the market share. These numbers will then be analyzed to determine the potential profitability that the company can expect for the product.

If it looks as if the product will bring in a reasonable profit to justify the investment in a development phase, then the product idea will be summarized in a requirements document and passed on to the design phase. If the profitability of the product does not justify the development cost, the product idea will either be shelved for future consideration, re-evaluated by marketing with a different set of features, or just dropped.

In the design phase, engineering will then generate a design based on the requirements document. Once the design of the product is complete, engineering then oversees any certification testing required, such as FCC, CE, CSA, or UL. Any changes to the design required to correct any design deficiencies will then be made, and the product will be resubmitted until it passes.

The final step in the design process is to generate any collateral material required for the sale of the product. This material typically includes testing procedures and fixtures, user's manuals, documentation for both the production and support groups, and any packaging or shipping containers.

Once the design phase is complete, initial production begins. In this phase, the production group works with engineering to determine the most cost-effective method to produce the design.The production group will also create any quality assurance documentation needed, as well as production jigs required by the design. The production and test staff will also receive training in the product production process.

The support group will also begin its analysis of the design with engineering, evaluating potential sources of faults and failures. They should also become fluent in the operation of the design to facilitate fault analysis and repair. The result of this analysis and training will be troubleshooting procedures and the purchase of the appropriate test equipment and stocks of repair parts. Further, the repair technicians and the help desk operators will be trained to handle problems, perform fault analysis, and do cost-effective repairs.


Excerpted from Embedded Multitasking by Keith Curtis Copyright © 2006 by Elsevier Inc.. Excerpted by permission of Newnes. All rights reserved. No part of this excerpt may be reproduced or reprinted without permission in writing from the publisher.
Excerpts are provided by Dial-A-Book Inc. solely for the personal use of visitors to this web site.

Meet the Author

Keith E. Curtis earned a BSEE from Montana State University. Following graduation, he was employed by Tele-Tech Corporation as a design and project engineer, and also began consulting part-time as an embedded engineer. He was then employed by Bally Gaming in Las Vegas as an engineer and later the electronics engineering manager, working for various Nevada gaming companies in both design and management. In 2000 he began work as a Principal Application Engineer for Microchip, where he is still employed.
He has written a number of articles and regularly gives a popular course on multitasking firmware design at the Embedded Systems Conference.

Customer Reviews

Average Review:

Write a Review

and post it to your social network


Most Helpful Customer Reviews

See all customer reviews >