Skip to the content ForoHackers
Log inJoin

RTOS: start here

RTOS
#2947 · · Quote · Report

A real-time operating system schedules tasks so that the right one runs within a known time. "Real time" means predictable, not fast: a late answer counts as a wrong one. On a microcontroller an RTOS gives you tasks, priorities, queues and timers in a few kilobytes.

Key concepts

  • Preemptive scheduling: the highest-priority ready task runs, and an event can take the CPU away at once.
  • Synchronisation: mutexes, semaphores, queues and event flags pass data and wake tasks safely.
  • Priority inversion: a low task holding a lock blocks a high one; priority inheritance bounds it.
  • Determinism: worst-case execution time and interrupt latency matter more than averages.
  • Memory: static allocation, stacks sized per task, and stack overflow checks.

Vocabulary

  • Tick: the periodic interrupt that drives time slicing and timeouts; tickless modes skip it to save power.
  • ISR: interrupt service routine; it defers work to a task instead of doing it all.
  • Hard and soft real time: missing a deadline is a failure, or only a degradation.
  • FreeRTOS, Zephyr, NuttX: common open RTOSes, from a small kernel to a full platform.

What to study, in order

  1. Bare-metal interrupts and a super-loop, to feel what an RTOS replaces.
  2. Two tasks and a queue in FreeRTOS; then a mutex and a priority inversion you cause on purpose.
  3. Measure latency with a GPIO toggle and an oscilloscope or logic analyser.
  4. Zephyr's device model and build system, for a larger platform.
  5. Rate-monotonic analysis, to prove a set of tasks meets its deadlines.

Related tags

#microcontrollers #firmware #concurrency #functional-safety

You are not logged in, so this goes up anonymously: no account, no name and no address is stored with it, and it may carry no link and no image. Log in or join to post under your name. Our web server's logs keep the address and time of every request for up to 14 days; to keep yours out of them, use Tor. To reach the staff in confidence, use the drop. Sign as a returning source (a key kept only in this browser)

Sending takes a few seconds here: your browser first works out a proof of work against spam.

Reply