5 exercises on core RTOS terminology: task, scheduler, preemptive scheduling, priority inversion, and priority ceiling protocol. Advanced
0 / 5 completed
1 / 5
Your team lead says: "Each task in our RTOS gets its own stack and runs independently."
What is a task in an RTOS context?
Correct: B. In RTOS terminology, a task (also called a thread in some RTOSes) is a self-contained, schedulable unit of execution. Each task has its own stack, program counter, and priority. The RTOS kernel switches the CPU between tasks based on their priorities and states.
Term
Meaning
Task / Thread
Independent execution unit with its own stack and priority
Task states
Running, Ready, Blocked, Suspended
Context switch
Saving one task's state and restoring another's
2 / 5
A colleague explains: "The scheduler decided to preempt Task A because Task B became ready."
What is the scheduler in an RTOS?
Correct: B. The scheduler is the heart of the RTOS kernel. It runs on every context-switch trigger (tick, interrupt, or task state change) and applies a scheduling algorithm — typically fixed-priority preemptive — to select the highest-priority ready task for execution.
Algorithm
Description
Fixed-priority preemptive
Always runs highest-priority ready task; most common in RTOS
Round-robin
Equal-priority tasks share CPU time in rotation
Cooperative
Tasks yield voluntarily; no forced preemption
3 / 5
During a code review your lead says: "This is fine because we use preemptive scheduling — the sensor task will run the moment it becomes ready."
What does preemptive scheduling mean?
Correct: B.Preemptive scheduling means the RTOS can interrupt — preempt — the currently running task at any time if a task with higher priority becomes ready (e.g., unblocked by an ISR). This guarantees that the most critical work is always attended to first, which is essential in real-time systems.
Scheduling type
CPU taken away?
Typical use
Preemptive
Yes — by higher-priority task
Most RTOSes (FreeRTOS, Zephyr)
Cooperative
No — task must yield
Simple or resource-constrained systems
4 / 5
Your tech lead warns: "We have a classic priority inversion bug in the sensor task — it's waiting on a mutex held by the logging task."
What is priority inversion?
Correct: B.Priority inversion is a scheduling anomaly. It occurs when: (1) a low-priority task holds a mutex, (2) a high-priority task tries to acquire the same mutex and blocks, and (3) medium-priority tasks keep running, starving the high-priority task. The Mars Pathfinder mission famously suffered from this bug.
Participant
Role in priority inversion
High-priority task
Blocked waiting for mutex
Low-priority task
Holds mutex but gets preempted
Medium-priority tasks
Run freely, preventing low-priority task from finishing
5 / 5
A colleague says: "We solved the priority inversion by implementing the priority ceiling protocol on that shared mutex."
What does the priority ceiling protocol do?
Correct: B. The priority ceiling protocol (PCP) assigns each shared resource a ceiling equal to the maximum priority of any task that will ever lock it. When a task locks the resource its priority is immediately raised to that ceiling, so no medium-priority task can preempt it before it releases the resource — eliminating priority inversion.