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 power-saving modes in Linux

When a system is in the idle state and does not have work to do, it can be put in a sleep state to save power. Similar to human sleep, it cannot do anything until it is woken up by external event, for example an alarm clock.

Linux supports multiple sleep modes. The choice of sleep mode and the amount of power it can save depends on the hardware support and the time it takes to enter the mode and wake up from it. 

The supported modes are as follows:

  • Suspend-to-idle (S2I): This is a light sleep mode that can be implemented purely in software and does not require any support from the hardware. The devices are put into low-power mode and time keeping is suspended to let the processor spend more time in a power-efficient idle state. A system is woken up by an interrupt from any of the peripheral devices.
  • Standby: This is similar...