Bird
0
0

What happens if taskEXIT_CRITICAL() is called without a matching taskENTER_CRITICAL() in FreeRTOS?

medium📝 Predict Output Q5 of 15
FreeRTOS - Interrupt Management
What happens if taskEXIT_CRITICAL() is called without a matching taskENTER_CRITICAL() in FreeRTOS?
AInterrupts may be enabled prematurely causing race conditions
BThe system will enter an infinite loop
CNothing happens, it is safe to call anytime
DThe task will be suspended automatically
Step-by-Step Solution
Solution:
  1. Step 1: Understand critical section nesting

    taskENTER_CRITICAL() and taskEXIT_CRITICAL() must be balanced to manage interrupt state correctly.
  2. Step 2: Effect of unmatched exit

    Calling exit without enter may enable interrupts too early, risking race conditions.
  3. Final Answer:

    Interrupts may be enabled prematurely causing race conditions -> Option A
  4. Quick Check:

    Unmatched exit causes premature interrupt enable = True [OK]
Quick Trick: Always balance taskENTER_CRITICAL() with taskEXIT_CRITICAL() [OK]
Common Mistakes:
  • Assuming no effect if exit called alone
  • Thinking system hangs on unmatched exit
  • Believing task suspension occurs automatically

Want More Practice?

15+ quiz questions · All difficulty levels · Free

Free Signup - Practice All Questions
More FreeRTOS Quizzes