RTOS Vocabulary: FreeRTOS, Tasks, and Real-Time Concepts in English
Essential RTOS vocabulary for embedded engineers: tasks, scheduling, priorities, semaphores, mutexes, queues, ISR, and key FreeRTOS concepts explained in plain English.
A Real-Time Operating System (RTOS) provides the scheduling, synchronisation, and communication primitives that embedded systems need to meet timing requirements. FreeRTOS is the world’s most widely deployed RTOS. Whether you’re writing firmware, reviewing embedded code, or discussing RTOS design in a technical interview, this vocabulary guide covers the essential concepts.
RTOS Fundamentals
RTOS (Real-Time Operating System)
An RTOS is an operating system designed to execute tasks within strict timing constraints — guaranteeing that critical operations complete within a specified deadline.
Contrast with a general-purpose OS (Linux, Windows) — those prioritise throughput and fairness; an RTOS prioritises determinism and deadline adherence.
“We use FreeRTOS because the motor controller loop must execute every 1ms — a general-purpose OS can’t provide that guarantee.”
Hard Real-Time vs Soft Real-Time
- Hard real-time — missing a deadline causes system failure or safety violation (e.g., airbag controller, pacemaker)
- Soft real-time — missing a deadline degrades quality but doesn’t cause catastrophic failure (e.g., audio buffering, display refresh)
Determinism
A deterministic system has predictable, bounded response times. RTOS design prioritises determinism over throughput.
Latency
In RTOS context, latency is the time between an event (interrupt, signal) and the start of the handler that responds to it. Minimising worst-case latency is critical.
Jitter
Jitter is variability in timing — the difference between earliest and latest actual execution times. Low jitter is essential for periodic control loops.
Tasks
Task (Thread)
A task is an independent unit of execution in an RTOS — analogous to a thread in a desktop OS. Each task has:
- Its own stack
- A priority level
- A state (Running, Ready, Blocked, Suspended)
“We have four tasks: motor control (highest priority), sensor reading, display update, and communication (lowest priority).”
Task States
| State | Description |
|---|---|
| Running | Currently executing on the CPU |
| Ready | Can run but waiting for the CPU (preempted by higher-priority task) |
| Blocked | Waiting for an event, delay, or resource |
| Suspended | Explicitly paused; not eligible to run until resumed |
Task Priority
Each task has a priority — a number indicating its scheduling precedence. Higher priority tasks preempt lower priority tasks.
“The motor controller runs at priority 7 (highest). The logging task runs at priority 1 (near idle). If both are ready, the motor controller always runs first.”
Stack Size
Every task needs a stack — a region of RAM for local variables, function call frames, and interrupt handling. RTOS tasks require careful stack sizing to avoid overflow.
“The task stack overflowed because the function was allocating 1KB of local variables — the task’s stack was only 512 bytes.”
Idle Task
The idle task runs when no other task is ready — it performs background cleanup and can put the CPU into a low-power sleep state.
Scheduling
Scheduler
The scheduler is the RTOS component that decides which task runs at any given moment, based on priority and state.
Preemptive Scheduling
In preemptive scheduling, the scheduler can interrupt a running task at any time to switch to a higher-priority ready task.
“The sensor interrupt sets a flag. The scheduler immediately switches from the display task to the sensor processing task because it has higher priority.”
Cooperative (Non-Preemptive) Scheduling
In cooperative scheduling, tasks voluntarily yield the CPU by calling a blocking function or explicitly yielding. Lower overhead but risky if a task misbehaves and monopolises the CPU.
Tick
The tick is the RTOS time base — a periodic interrupt (e.g., every 1ms) that allows the scheduler to evaluate task states and implement time-delayed operations.
Tick period — the interval between ticks. FreeRTOS default: configTICK_RATE_HZ (typically 1000 Hz = 1ms ticks).
Context Switch
A context switch is the process of saving the current task’s registers/state and restoring another task’s state. RTOS context switches are typically 1–10 microseconds.
Round Robin Scheduling
Round robin scheduling gives equal time slices to tasks of the same priority, cycling through them sequentially.
Synchronisation Primitives
Semaphore
A semaphore is a signalling mechanism used to synchronise tasks.
- Binary semaphore — a flag that can be given (signalled) and taken (waited for). Classically used for ISR-to-task signalling.
- Counting semaphore — like a counter; allows up to N concurrent acquisitions. Used for resource pool management.
“The UART ISR writes to a buffer and gives the binary semaphore. The UART task blocks on the semaphore — it wakes only when the ISR signals new data is available.”
Mutex (Mutual Exclusion Semaphore)
A mutex provides exclusive access to a shared resource. Unlike a binary semaphore, a mutex has an owner (the task that acquired it) and supports priority inheritance.
Priority inheritance prevents priority inversion: if a low-priority task holds a mutex that a high-priority task is waiting for, the low-priority task temporarily inherits the high priority so it can release the mutex quickly.
“We use a mutex, not a semaphore, for the SPI bus — mutexes prevent priority inversion, which could cause our motor control task to miss its deadline.”
Priority Inversion
Priority inversion is when a high-priority task is blocked by a lower-priority task holding a shared resource — and a medium-priority task is preempting the low-priority holder, preventing resource release.
Classic example: Mars Pathfinder mission (1997) suffered priority inversion — resolved mid-mission by enabling priority inheritance.
Deadlock
A deadlock in RTOS occurs when two or more tasks are each waiting for a resource held by the other — both blocked indefinitely.
“Task A holds Mutex 1 and waits for Mutex 2. Task B holds Mutex 2 and waits for Mutex 1. Deadlock.”
Inter-Task Communication
Queue
A queue (message queue) is a FIFO buffer for passing data between tasks or from an ISR to a task. Provides a safe, thread-safe mechanism for communication.
“The sensor reading task puts 8-byte measurement structs into a queue. The processing task blocks on the queue and processes each measurement as it arrives.”
Queue Length / Depth
The queue depth is how many items the queue can hold. If the queue is full, senders can block or return an error.
Notification
Task notifications (FreeRTOS) are a lightweight, fast mechanism for signalling a specific task — faster than semaphores because they operate directly on the task’s notification value.
Stream Buffer / Message Buffer
FreeRTOS stream buffers allow sending arbitrary-length byte streams from ISR/task to one receiver. Message buffers extend this to handle discrete messages with length framing.
Interrupts and ISRs
ISR (Interrupt Service Routine)
An ISR is the function that executes in response to a hardware interrupt. ISRs must be short and fast — they preempt all tasks regardless of priority.
“The ADC ISR runs every 500µs. It only stores the sample and gives a semaphore — all processing happens in the ADC task.”
ISR-Safe Functions
FreeRTOS provides ISR-safe variants of API functions (e.g., xQueueSendFromISR, xSemaphoreGiveFromISR) — these can be called from an ISR.
⚠️ Never call regular RTOS functions from an ISR — it will corrupt the scheduler state.
Interrupt Priority
On ARM Cortex-M, interrupt priority levels control which interrupts can preempt others. RTOS-aware interrupts must run at configurable priority levels below the configMAX_SYSCALL_INTERRUPT_PRIORITY threshold.
Interrupt Latency
Interrupt latency is the time from interrupt assertion to the ISR start. Critical for time-sensitive hardware events.
Memory Management
Heap
The heap is dynamically allocated memory. FreeRTOS provides several heap allocation schemes (heap_1 through heap_5) with different trade-offs between fragmentation and determinism.
“We use heap_4 because it supports both allocation and deallocation with a best-fit algorithm — but we allocate all resources at startup to avoid runtime fragmentation.”
Stack Overflow Detection
FreeRTOS can fill task stacks with a known pattern and check for corruption. configCHECK_FOR_STACK_OVERFLOW enables this.
Useful Phrases
In design discussions:
- “The motor control task needs preemptive scheduling with priority 7 — if any lower-priority task runs too long, the motor loop misses its 1ms deadline.”
- “We replaced the binary semaphore with a mutex here because we need priority inheritance to prevent inversion.”
In code reviews:
- “This function allocates a local array on the task stack — make sure the task’s stack size is large enough.”
- “Never call
vTaskDelayfrom an ISR — use theFromISRvariant of the API.”
Practice
Build your embedded systems vocabulary with the Embedded Systems & IoT exercise set and the Embedded & IoT Engineer learning path.