Book Image

Embedded Programming with Modern C++ Cookbook

By : Igor Viarheichyk
Book Image

Embedded Programming with Modern C++ Cookbook

By: Igor Viarheichyk

Overview of this book

Developing applications for embedded systems may seem like a daunting task as developers face challenges related to limited memory, high power consumption, and maintaining real-time responses. This book is a collection of practical examples to explain how to develop applications for embedded boards and overcome the challenges that you may encounter while developing. The book will start with an introduction to embedded systems and how to set up the development environment. By teaching you to build your first embedded application, the book will help you progress from the basics to more complex concepts, such as debugging, logging, and profiling. Moving ahead, you will learn how to use specialized memory and custom allocators. From here, you will delve into recipes that will teach you how to work with the C++ memory model, atomic variables, and synchronization. The book will then take you through recipes on inter-process communication, data serialization, and timers. Finally, you will cover topics such as error handling and guidelines for real-time systems and safety-critical systems. By the end of this book, you will have become proficient in building robust and secure embedded applications with C++.
Table of Contents (17 chapters)

Exploring heartbeats for highly available systems

In the preceding recipe, we learned how to prevent software from hanging using watchdog timers. A similar technique can be used to implement a highly available system, which consists of one or more software or hardware components that can perform the same function. If one of the components fails, another one can take over.

The component that is currently active should periodically advertise its health status to other, passive components using messages that are called heartbeats. When it reports an unhealthy status or doesn't report it within a specific amount of time, a passive component detects it and activates itself. When the failed component recovers, it can either transition into passive mode, monitoring the now active component for failures, or initiate a failback procedure to claim the active status back.

In this recipe...