Task starvation happens when a low-priority task never gets CPU time because higher-priority tasks keep running. It means the low-priority task is 'starved' of processing time.
Click to reveal answer
intermediate
Explain priority inversion in FreeRTOS.
Priority inversion occurs when a high-priority task waits for a resource held by a low-priority task, but a medium-priority task keeps running and blocks the low-priority task from releasing the resource.
Click to reveal answer
intermediate
How does FreeRTOS help prevent priority inversion?
FreeRTOS uses priority inheritance. When a low-priority task holds a resource needed by a high-priority task, it temporarily inherits the higher priority to finish quickly and release the resource.
Click to reveal answer
beginner
What is a real-life example of task starvation?
Imagine a busy cashier (high priority) always serving customers, so the cleaner (low priority) never gets a chance to clean the floor. The cleaner is starved of time.
Click to reveal answer
beginner
Why is task starvation a problem in real-time systems?
Because some tasks may never run, causing missed deadlines or system failures. Real-time systems need all tasks to run on time to work correctly.
Click to reveal answer
What causes task starvation in FreeRTOS?
AHigh-priority tasks always running and blocking low-priority tasks
BLow-priority tasks running too fast
CAll tasks having the same priority
DUsing too many semaphores
✗ Incorrect
Task starvation happens when high-priority tasks keep running and prevent low-priority tasks from executing.
What is priority inversion?
AA low-priority task blocking a high-priority task indirectly
BA high-priority task running before a low-priority task
CAll tasks running at the same priority
DA task losing its priority permanently
✗ Incorrect
Priority inversion is when a low-priority task holds a resource needed by a high-priority task, causing the high-priority task to wait.
How does FreeRTOS solve priority inversion?
ABy disabling interrupts
BBy killing low-priority tasks
CBy increasing stack size
DBy using priority inheritance
✗ Incorrect
FreeRTOS uses priority inheritance to temporarily raise the priority of the low-priority task holding the resource.
Which of these is a symptom of task starvation?
AAll tasks run equally
BTasks run out of memory
CA task never gets CPU time
DTasks crash randomly
✗ Incorrect
Task starvation means some tasks never get CPU time because others keep running.
Why is priority inversion dangerous in real-time systems?
AIt speeds up low-priority tasks too much
BIt can cause high-priority tasks to miss deadlines
CIt disables interrupts
DIt causes memory leaks
✗ Incorrect
Priority inversion can delay high-priority tasks, causing them to miss critical deadlines.
Describe task starvation and how it affects system behavior in FreeRTOS.
Think about what happens when some tasks never get CPU time.
You got /3 concepts.
Explain priority inversion and how FreeRTOS uses priority inheritance to solve it.
Consider how a low-priority task can block a high-priority task.
You got /3 concepts.
Practice
(1/5)
1. What does task starvation mean in FreeRTOS?
easy
A. Some tasks never get CPU time because others run too much
B. All tasks get equal CPU time regardless of priority
C. Tasks run in a random order without priority
D. Tasks share CPU time only when a mutex is free
Solution
Step 1: Understand task scheduling in FreeRTOS
FreeRTOS schedules tasks based on priority, so higher priority tasks run more often.
Step 2: Define task starvation
Task starvation happens when low priority tasks never get CPU time because higher priority tasks keep running.
Final Answer:
Some tasks never get CPU time because others run too much -> Option A
Quick Check:
Task starvation = some tasks starve for CPU [OK]
Hint: Starvation means some tasks get no CPU time [OK]
Common Mistakes:
Confusing starvation with equal CPU sharing
Thinking tasks run randomly
Assuming mutex controls CPU time directly
2. Which FreeRTOS API is used to create a mutex that supports priority inheritance?
easy
A. xQueueCreate()
B. xSemaphoreCreateMutex()
C. vTaskDelay()
D. xTaskCreate()
Solution
Step 1: Identify mutex creation functions
FreeRTOS uses xSemaphoreCreateMutex() to create mutexes with priority inheritance.
Step 2: Differentiate other APIs
xQueueCreate() creates queues, vTaskDelay() delays tasks, and xTaskCreate() creates tasks, not mutexes.
Final Answer:
xSemaphoreCreateMutex() -> Option B
Quick Check:
Mutex with priority inheritance = xSemaphoreCreateMutex() [OK]
Hint: Mutex with priority inheritance uses xSemaphoreCreateMutex() [OK]
Common Mistakes:
Choosing xQueueCreate() for mutex
Confusing task creation with mutex creation
Using delay functions instead of mutex APIs
3. Given three tasks with priorities High (3), Medium (2), and Low (1). Low task holds a mutex needed by High task. What happens without priority inheritance?
medium
A. Medium task is blocked until High task finishes
B. Low task immediately releases the mutex
C. High task waits indefinitely while Medium task runs
D. High task preempts Low task and runs
Solution
Step 1: Understand priority inversion scenario
Low priority task holds mutex needed by High priority task, so High task blocks waiting.
Step 2: Effect without priority inheritance
Medium priority task runs, preventing Low task from running and releasing mutex, causing High task to wait indefinitely.
Final Answer:
High task waits indefinitely while Medium task runs -> Option C
Quick Check:
Priority inversion without inheritance = High task blocked [OK]
Hint: Without inheritance, medium task blocks low task, blocking high task [OK]
Common Mistakes:
Assuming low task releases mutex immediately
Thinking high task preempts low task despite mutex
Believing medium task is blocked
4. Identify the problem in this FreeRTOS code snippet causing priority inversion: