Cyber-Physical Systems Series

Embedded Systems and Real-Time Operation

The small computers inside cyber-physical systems, and how they make sure every action happens on time.

What Is an Embedded System?

An embedded system is a computer built inside a device to do one job, like controlling a car's brakes or a drone's motors. Most use a microcontroller: a single chip that holds a processor, memory, a clock, and connections to sensors and actuators.

A microcontroller chip containing a processor, memory, timers, inputs from a sensor, and outputs to an actuator.
A microcontroller reads sensors through its inputs and drives actuators through its outputs.

Small

Limited memory and processing power

Low power

Often runs on a battery for years

Long-lived

May stay in service for 10 to 30 years

On time

Must respond before the physical world moves on

Embedded Computing in the News

A clear trend: products now split work between a powerful computer for AI and a small, predictable computer for anything that must happen exactly on time.

Arduino UNO Q board

Two brains on one board

The Arduino UNO Q pairs a Linux processor for AI and vision with a real-time microcontroller that handles sensors and motors. The two talk through a software bridge.

Derek Molloy, July 2026
Rivian autonomy computer

Fewer, smarter car computers

Rivian cut the number of control computers in its R1 vehicles from nearly 20 to 7 by grouping functions into zones, and designed its own chip for self-driving.

IEEE Spectrum, September 2026
Humanoid robots handling metal parts

One computer for a robot's mind and body

UK company Humanoid is replacing its robots' two onboard computers with a single NVIDIA Jetson Thor system that links sensing, AI, and motor control.

Humanoids Daily, October 2026

Talking to the Physical World

Sampling

A sensor's signal changes smoothly, but a computer can only take samples: measurements at separate moments. If it samples too slowly, it gets a false picture of what is happening.

Rule of thumb: sample at least twice as fast as the fastest change you care about. Control systems usually sample 10 or more times faster than that.

The same wave sampled quickly, which captures its shape, and too slowly, which produces a false slower wave.

Polling and interrupts

A computer can find out about events in two ways. Polling means checking again and again, like looking out the window for a delivery. An interrupt is like a doorbell: hardware signals the processor the moment something happens.

Interrupts respond faster, but they pause whatever the processor was doing, which makes timing harder to predict.

Polling checks repeatedly and notices an event at the next check; an interrupt responds immediately and then returns to other work.

What "Real-Time" Really Means

A real-time system is one where an answer is only correct if it arrives by its deadline. Real-time does not mean fast; it means predictable. A system that always responds in 10 milliseconds is more real-time than one that usually takes 1 millisecond but sometimes takes 200.

Three graphs of how valuable a result is depending on when it arrives: hard deadlines drop to failure, firm deadlines drop to zero value, soft deadlines decline gradually.
How much a result is worth depending on when it arrives. Hard: an airbag. Firm: a video frame. Soft: a map update.
Why doesn't the same code always take the same time? Modern processors use shortcuts like memory caches that are fast only some of the time. Interrupts pause the work, and other programs compete for the same hardware. Engineers must plan for the worst-case execution time, not the average.

Scheduling: Many Jobs, One Processor

An embedded computer usually runs several tasks that repeat on a schedule, such as reading a camera or updating motor commands. A scheduler decides which task runs at each moment. Two common rules:

Fixed priority

Every task gets a permanent rank, and the highest-ranked task that is ready always runs. Tasks that repeat more often usually get higher ranks (called rate monotonic). Most real-time operating systems work this way.

Earliest deadline first

Whichever job is due soonest runs next, so priorities change as deadlines approach. It can keep a processor busier without missing deadlines.

Timeline of two tasks, control and vision. Under fixed priority, vision misses its deadline at time 7. Under earliest deadline first, both tasks meet their deadlines.
The same two tasks on the same processor. Only the scheduling rule changes, and with it, whether a deadline is missed.

For safety-critical systems, engineers do not just test schedules. They use schedulability analysis, math that proves every deadline will be met in the worst case.

Case Study: The Bug on Mars

NASA Mars Pathfinder mission

Image: NASA/JPL-Caltech

In 1997, days after landing on Mars, NASA's Pathfinder lander began rebooting itself over and over. The cause was priority inversion:

  • A low-priority task locked a shared resource.
  • A high-priority task needed that resource, so it had to wait.
  • Medium-priority tasks kept interrupting the low-priority task, so it could never finish and release the lock.

A built-in timing check saw the high-priority work falling behind and reset the system. Engineers turned on a feature called priority inheritance and sent the fix to Mars. (Read the lead engineer's account)

Timeline of low, medium, and high priority tasks. Without inheritance, the medium task delays the high-priority task. With inheritance, the low task finishes quickly and the high-priority task completes sooner.
With priority inheritance, the task holding the lock temporarily borrows the waiting task's high priority, so medium tasks can't cut in.

Software That Runs These Devices

Simple loopOne program repeats forever: read sensors, decide, act. Easy to understand; hard to grow.Small gadgets, hobby projects
Real-time operating system (RTOS)A small operating system that runs many tasks by priority and guarantees fast, predictable switching.FreeRTOS, Zephyr, VxWorks, QNX
Real-time LinuxRegular Linux with real-time support, built in since 2024. It is more capable, but its timing is harder to guarantee.Robots, industrial PCs

Try It Yourself

Wokwi

Simulate a microcontroller with sensors and motors in your browser, and try timers and interrupts with no hardware.

wokwi.com

MicroPython

Python for microcontrollers. Its online emulator lets you blink LEDs and read sensors on a virtual board.

Try it online

FreeRTOS Beginner's Guide

A gentle introduction to tasks, priorities, and real-time operating systems from the most widely used open-source RTOS.

freertos.org

Zephyr Getting Started

Set up the open-source RTOS used on the Arduino UNO Q's real-time chip, and run a first sample.

zephyrproject.org

SimSo

For programmers: a Python simulator for comparing real-time scheduling rules on your own task sets.

SimSo project

Further Reading