CodeBlanks Logo Icon CodeBlanks

What is embedded?

Learn the embedded system concept and C++ constraints.

What is embedded?

An embedded system is a computer designed for a specific task, with limited memory and power. A washing machine, a car engine control unit, a smart watch are all embedded systems.

Embedded C++ programs typically run without an operating system (bare-metal) or on an RTOS (Real-Time Operating System). Memory is very tight; tools that use dynamic memory like std::vector are avoided. Hardware is accessed directly through memory-mapped I/O.

Constraints and tools

In embedded systems dynamic memory allocation is constrained; the heap is small or absent. Large data is kept static or on the stack. Exception handling is usually disabled (-fno-exceptions); exception tables take memory.

Hardware access happens through memory-mapped I/O: writing to a specific memory address changes a register. These addresses are read/written as volatile pointers; this prevents the compiler from skipping reads. An RTOS handles task scheduling; bare-metal programs manage their own loop.

Practice Write an embedded-style message

In main write std::cout << "Embedded"; and end with return 0;.

Starter code

main.cpp
#include <iostream>

int main() {
    // Print the message
    return 0;
}

Sample solution

main.cpp
#include <iostream>

int main() {
    std::cout << "Embedded";
    return 0;
}

Expected output

Embedded

Questions and answers

Review the lesson questions together with their answers. To test yourself, solve the lesson interactively.

1 What characterizes an embedded system?

main.cpp
// program running on a microcontroller
  • Unlimited memory
  • General-purpose operating system
  • Designed for a specific task, constrained resources Correct answer
  • Always a powerful CPU

Explanation: An embedded system is designed for a specific task with constrained resources.

2 Complete the main name

Question
int ____(void) { /* embedded entry */ }
Answer
int main(void) { /* embedded entry */ }

Explanation: main is the program entry point.

3 Match each concept to its role

Term Meaning
RTOS Real-time kernel
MMIO Memory-mapped I/O
volatile Hardware access
interrupt Hardware interrupt

All lessons in Expert