Bird
0
0

You want to implement a graceful shutdown where multiple tasks stop safely before the scheduler stops. Which sequence is correct?

hard📝 Application Q15 of 15
FreeRTOS - Design Patterns for RTOS
You want to implement a graceful shutdown where multiple tasks stop safely before the scheduler stops. Which sequence is correct?
A) Set shutdown flag -> Wait for tasks to confirm stop -> Call vTaskEndScheduler()
B) Call vTaskEndScheduler() -> Set shutdown flag -> Tasks stop
C) Delete tasks immediately -> Set shutdown flag -> Stop scheduler
D) Stop scheduler -> Set shutdown flag -> Tasks stop
ASet shutdown flag -> Wait for tasks to confirm stop -> Call vTaskEndScheduler()
BCall vTaskEndScheduler() -> Set shutdown flag -> Tasks stop
CDelete tasks immediately -> Set shutdown flag -> Stop scheduler
DStop scheduler -> Set shutdown flag -> Tasks stop
Step-by-Step Solution
Solution:
  1. Step 1: Understand graceful shutdown steps

    First, signal tasks to stop by setting a shutdown flag or notification.
  2. Step 2: Wait for tasks to confirm they stopped

    Ensure tasks finish cleanup and confirm they stopped before stopping the scheduler.
  3. Step 3: Stop the scheduler safely

    Call vTaskEndScheduler() only after tasks have stopped to avoid abrupt termination.
  4. Final Answer:

    Set shutdown flag -> Wait for tasks to confirm stop -> Call vTaskEndScheduler() -> Option A
  5. Quick Check:

    Signal tasks -> wait -> stop scheduler = correct shutdown [OK]
Quick Trick: Signal tasks first, wait, then stop scheduler [OK]
Common Mistakes:
  • Stopping scheduler before tasks finish
  • Deleting tasks immediately without cleanup
  • Setting flag after scheduler stops

Want More Practice?

15+ quiz questions · All difficulty levels · Free

Free Signup - Practice All Questions
More FreeRTOS Quizzes