What is a common cause of priority inversion in RTOS?
Priority inversion happens when a low-priority task holds a resource needed by a higher-priority task, causing the high-priority task to wait and potentially miss deadlines.
Click to reveal answer
beginner
How can deadlocks occur in an RTOS environment?
Deadlocks occur when two or more tasks wait indefinitely for resources held by each other, creating a cycle of dependencies that stops all involved tasks.
Click to reveal answer
intermediate
What debugging strategy helps identify stack overflow in FreeRTOS tasks?
Using FreeRTOS's stack overflow hook function allows detection when a task exceeds its stack size, helping to catch stack overflow bugs early.
Click to reveal answer
intermediate
Why is using trace tools important in debugging RTOS applications?
Trace tools record task switches, interrupts, and events in real-time, helping developers understand system behavior and find timing or synchronization bugs.
Click to reveal answer
beginner
What is a common symptom of race conditions in RTOS tasks?
Race conditions cause unpredictable behavior like corrupted data or crashes because multiple tasks access shared data without proper synchronization.
Click to reveal answer
Which of the following is a typical cause of deadlock in RTOS?
AA task with too high priority
BA task running out of stack space
CA task that never yields
DTwo tasks waiting on each other's resources
✗ Incorrect
Deadlock happens when tasks wait on each other’s resources, creating a cycle that stops progress.
What does FreeRTOS's stack overflow hook function do?
ADetects when a task uses more stack than allocated
BPrevents priority inversion automatically
CLogs all task switches
DResets the system on error
✗ Incorrect
The stack overflow hook is called when a task exceeds its stack size, helping catch stack overflow bugs.
Priority inversion can be avoided by:
AIncreasing all task priorities
BUsing priority inheritance protocols
CDisabling interrupts
DUsing larger stack sizes
✗ Incorrect
Priority inheritance temporarily raises the priority of the low-priority task holding a resource to avoid blocking high-priority tasks.
Which tool helps visualize task execution and timing in FreeRTOS?
ATracealyzer
BGDB
CValgrind
DWireshark
✗ Incorrect
Tracealyzer is a trace tool that shows task switches and timing, useful for debugging RTOS behavior.
Race conditions occur when:
AThe scheduler is disabled
BA task runs out of stack
CMultiple tasks access shared data without synchronization
DA task has too low priority
✗ Incorrect
Race conditions happen when tasks access shared data at the same time without proper locks or synchronization.
Explain what causes priority inversion in an RTOS and how it can be mitigated.
Think about tasks waiting for resources and how priorities can change temporarily.
You got /3 concepts.
Describe common debugging strategies to find and fix deadlocks in FreeRTOS applications.
Consider how tasks wait for resources and how to detect cycles.
You got /4 concepts.
Practice
(1/5)
1. Which of the following is a common cause of deadlocks in FreeRTOS applications?
easy
A. Not enabling the FreeRTOS scheduler
B. Using too much heap memory for dynamic allocation
C. Incorrect task priority assignment causing starvation
D. Two tasks waiting indefinitely for each other's resource
Solution
Step 1: Understand deadlock concept in RTOS
Deadlock happens when two or more tasks wait forever for resources held by each other.
Step 2: Identify the scenario causing deadlock
Two tasks waiting indefinitely for each other's resource is the classic deadlock cause.
Final Answer:
Two tasks waiting indefinitely for each other's resource -> Option D
Quick Check:
Deadlock = Mutual waiting [OK]
Hint: Deadlock means tasks wait forever for each other's resource [OK]
Common Mistakes:
Confusing deadlock with priority inversion
Thinking heap size causes deadlock
Assuming scheduler not started causes deadlock
2. Which FreeRTOS API call correctly creates a task?
easy
A. xTaskCreate(TaskFunction, "Task1", 1000, NULL, 2, NULL);
B. vTaskCreate(TaskFunction, "Task1", 1000, NULL, 2, NULL);
C. xTaskCreate(TaskFunction, 1000, "Task1", NULL, 2, NULL);
D. xTaskCreate(TaskFunction, "Task1", NULL, 1000, 2, NULL);
Solution
Step 1: Recall FreeRTOS task creation syntax
The correct syntax is xTaskCreate(TaskFunction, "Name", stackSize, parameters, priority, taskHandle).
Step 2: Match options with correct parameter order
xTaskCreate(TaskFunction, "Task1", 1000, NULL, 2, NULL); matches the correct order and types.
Final Answer:
xTaskCreate(TaskFunction, "Task1", 1000, NULL, 2, NULL); -> Option A
What is the likely effect if xSemaphoreGive(xMutex); is accidentally omitted?
medium
A. The mutex will be automatically released after timeout
B. The task will run normally without issues
C. Other tasks waiting for the mutex will block indefinitely
D. The system will reset due to stack overflow
Solution
Step 1: Understand semaphore usage in FreeRTOS
Mutex must be given back after taking it to allow other tasks to access the resource.
Step 2: Analyze effect of missing xSemaphoreGive
If xSemaphoreGive is omitted, the mutex stays taken, blocking other tasks indefinitely.
Final Answer:
Other tasks waiting for the mutex will block indefinitely -> Option C
Quick Check:
Missing give = Blocked tasks [OK]
Hint: Always pair xSemaphoreTake with xSemaphoreGive [OK]
Common Mistakes:
Assuming mutex auto-releases
Confusing blocking with stack overflow
Ignoring semaphore usage rules
4. You observe that a FreeRTOS task sometimes stops running unexpectedly. Which debugging strategy is best to identify if a stack overflow caused this?
medium
A. Enable configCHECK_FOR_STACK_OVERFLOW and use configASSERT
B. Increase task priority to highest level
C. Disable all interrupts temporarily
D. Use vTaskDelay to slow down the task
Solution
Step 1: Identify debugging features for stack overflow
FreeRTOS provides configCHECK_FOR_STACK_OVERFLOW and configASSERT to detect stack overflow at runtime.
Step 2: Choose the best debugging method
Enabling these features helps catch stack overflow errors causing task failure.
Final Answer:
Enable configCHECK_FOR_STACK_OVERFLOW and use configASSERT -> Option A
Hint: Use FreeRTOS built-in stack overflow checks [OK]
Common Mistakes:
Thinking priority change fixes stack overflow
Disabling interrupts hides bugs
Using delay does not detect stack issues
5. In a FreeRTOS system, priority inversion occurs when a low priority task holds a resource needed by a high priority task. Which strategy helps to solve this problem?
hard
A. Increase the stack size of the low priority task
B. Use priority inheritance protocol on mutexes
C. Disable preemption in the scheduler
D. Use vTaskDelay in the high priority task
Solution
Step 1: Understand priority inversion problem
Priority inversion happens when a low priority task blocks a high priority task by holding a resource.
Step 2: Identify solution using FreeRTOS features
Priority inheritance protocol temporarily raises the low priority task's priority to prevent inversion.
Final Answer:
Use priority inheritance protocol on mutexes -> Option B