Copyright
Newnes is an imprint of Elsevier
The Boulevard, Langford Lane, Kidlington, Oxford OX5 1GB, United Kingdom
50 Hampshire Street, 5th Floor, Cambridge, MA 02139, United States
Copyright 2021 Elsevier Ltd. All rights reserved.
No part of this publication may be reproduced or transmitted in any form or by any means, electronic or mechanical, including photocopying, recording, or any information storage and retrieval system, without permission in writing from the publisher. Details on how to seek permission, further information about the Publishers permissions policies and our arrangements with organizations such as the Copyright Clearance Center and the Copyright Licensing Agency, can be found at our website: www.elsevier.com/permissions.
This book and the individual contributions contained in it are protected under copyright by the Publisher (other than as may be noted herein).
Notices
Knowledge and best practice in this field are constantly changing. As new research and experience broaden our understanding, changes in research methods, professional practices, or medical treatment may become necessary.
Practitioners and researchers must always rely on their own experience and knowledge in evaluating and using any information, methods, compounds, or experiments described herein. In using such information or methods they should be mindful of their own safety and the safety of others, including parties for whom they have a professional responsibility.
To the fullest extent of the law, neither the Publisher nor the authors, contributors, or editors, assume any liability for any injury and/or damage to persons or property as a matter of products liability, negligence or otherwise, or from any use or operation of any methods, products, instructions, or ideas contained in the material herein.
British Library Cataloguing-in-Publication Data
A catalogue record for this book is available from the British Library
Library of Congress Cataloging-in-Publication Data
A catalog record for this book is available from the Library of Congress
ISBN: 978-0-12-822851-7
For Information on all Newnes publications visit our website at https://www.elsevier.com/books-and-journals
Publisher: Mara Conner
Acquisitions Editor: Tim Pitts
Editorial Project Manager: Mariana Henriques
Production Project Manager: Kamesh Ramajogi
Cover Designer: Mark Rogers
Typeset by MPS Limited, Chennai, India
Dedication
Dedicated to everybody who has taught me stuff: my parents, wives, children, and other family members; my teachers and those whom I have taught; colleagues, managers, and associates. I hope that I can give something back.
Foreword
Embedded systems have steadily become more complex with more devices than ever being connected to the Internet. The timing requirements for these systems have become more complicated as the system must meet all its scheduling deadlines for sampling sensors, managing Wi-Fi, Bluetooth, USB, interacting with the user through a GUI, securing communications through encryption, authenticating and verifying integrity through hashing and signatures along with many other common system activities. With so many activities competing for CPU time, developers must rely on a real-time operating system (RTOS) to help schedule all their tasks in order to ensure all their deadlines and timing requirements can be met.
Over the last decade, RTOS usage has increased dramatically to the point where an RTOS is used in nearly two-thirds of embedded systems projects! (Aspencore 2019 Embedded Market Survey) An RTOS has become a critical, foundational component that modern systems are built upon and the tools that an RTOS provides a developer are indispensable to ensuring that task deadlines are met and that system response times are reasonable.
Despite the wide use of RTOSes, many embedded developers do not have an in-depth understanding of what is happening under the hood with an RTOS. This book provides developers with the behind-the-scenes knowledge necessary to make critical decisions for their system architecture and implementation. Colin does a fantastic job not only explaining how various RTOS components are used but also explaining how they are built so that the reader can use this book to also build their own lightweight RTOS.
The book dives into the kernel and provides the reader with an in-depth understanding of how a commercial RTOS kernel works. This knowledge removes the veil and mystery that often surrounds using an RTOS in a product and provides the reader with an understanding that allows them to truly master RTOS design no matter what RTOS it is they are using. The book provides the reader with an example kernel that can be leveraged to then build their own RTOS features around. All the main elements of an RTOS have a chapter each to cover details of their operation and implementation.
One of the most important RTOS features in my opinion, and one that is the most neglected, can be found in : Semaphores.)
An RTOS is certainly not complete without additional synchronization and mutual exclusion facilities. Colin explains how to build and integrate RTOS components such as mailboxes (: Pipes). These components help developers move data and messages around the application and can throw a kernel or application developer a context curveball if they are not careful with how they handle interrupts.
There are plenty of other topics in this book that the reader will find interesting. For example, , Diagnostics and error checking, goes into details on diagnostic and error checking facilities that are included in an RTOS. Diagnostic information can be absolutely critical to a developer successfully debugging their application and understanding how that application behaves. Diagnostic information can include as little as how many times a task executes in a given period all the way through a full-fledged event recorder that can be used to trace the RTOS execution and visualize how its application is performing.
Whether you are a developer looking to gain insights into how an RTOS works behind the scenes or are a kernel developer looking to jump start your own RTOS kernel, you are going to find that this book provides you everything you need to understand to develop with and build an RTOS.
Jacob Beningo
Embedded Software Consultant
www.beningo.com
Preface
Having worked with real-time operating systems (RTOSes) throughout my careerapplying them, supporting users, and writing them myselfit was inevitable that I would write about them at some point. Indeed, over the years I have written countless articles, blog posts, and conference presentations on the topic. Even my first book, Programming Dedicated Microprocessors