Bird
0
0

In FreeRTOS, two tasks are deadlocked because each is waiting to acquire a mutex held by the other. What is the best approach to detect and resolve this deadlock?

hard📝 Application Q8 of 15
FreeRTOS - Debugging and Monitoring
In FreeRTOS, two tasks are deadlocked because each is waiting to acquire a mutex held by the other. What is the best approach to detect and resolve this deadlock?
ADisable mutexes and use global variables for synchronization instead
BUse vTaskSuspend() on one task to break the deadlock manually
CIncrease the priority of both tasks to force mutex release
DImplement a watchdog timer that resets the system if tasks do not progress within a timeout
Step-by-Step Solution
Solution:
  1. Step 1: Understand Deadlock Scenario

    Two tasks waiting indefinitely on each other's mutex causes a deadlock, halting system progress.
  2. Step 2: Use Watchdog Timer

    A watchdog timer can detect system stalls caused by deadlocks and trigger a system reset or recovery mechanism.
  3. Step 3: Avoid Manual Suspension or Priority Changes

    Manually suspending tasks or changing priorities does not reliably resolve deadlocks and can introduce new issues.
  4. Step 4: Avoid Disabling Mutexes

    Mutexes are essential for synchronization; removing them risks data corruption.
  5. Final Answer:

    Implement a watchdog timer that resets the system if tasks do not progress within a timeout -> Option D
  6. Quick Check:

    Watchdog timers detect deadlocks by monitoring system responsiveness [OK]
Quick Trick: Use watchdog timers to detect and recover from deadlocks [OK]
Common Mistakes:
  • Suspending tasks manually to fix deadlocks
  • Relying on priority changes to resolve deadlocks
  • Removing mutexes instead of proper synchronization

Want More Practice?

15+ quiz questions · All difficulty levels · Free

Free Signup - Practice All Questions
More FreeRTOS Quizzes