Bird
0
0

Consider this simplified watchdog task code snippet in FreeRTOS:

medium📝 Predict Output Q13 of 15
FreeRTOS - Design Patterns for RTOS
Consider this simplified watchdog task code snippet in FreeRTOS:
void WatchdogTask(void *pvParameters) {
    for (;;) {
        if (xSemaphoreTake(watchdogSemaphore, pdMS_TO_TICKS(1000)) == pdFALSE) {
            // No reset signal received
            vTaskDelay(pdMS_TO_TICKS(500));
            // Take recovery action
        } else {
            // Reset signal received
            vTaskDelay(pdMS_TO_TICKS(100));
        }
    }
}

What happens if the monitored task never calls xSemaphoreGive(watchdogSemaphore)?
AThe watchdog task will detect no reset signal and take recovery action repeatedly
BThe watchdog task will keep waiting forever without action
CThe watchdog task will crash due to semaphore misuse
DThe watchdog task will reset the semaphore automatically
Step-by-Step Solution
Solution:
  1. Step 1: Analyze semaphore wait behavior

    The watchdog task waits 1000 ms for a semaphore signal. If none arrives, xSemaphoreTake returns pdFALSE.
  2. Step 2: Understand the consequence of no signal

    When no signal is received, the watchdog delays 500 ms and then takes recovery action repeatedly in the loop.
  3. Final Answer:

    The watchdog task will detect no reset signal and take recovery action repeatedly -> Option A
  4. Quick Check:

    No semaphore signal triggers recovery = A [OK]
Quick Trick: No semaphore signal means watchdog triggers recovery [OK]
Common Mistakes:
  • Assuming watchdog waits forever without action
  • Thinking semaphore misuse causes crash here
  • Believing semaphore resets automatically

Want More Practice?

15+ quiz questions · All difficulty levels · Free

Free Signup - Practice All Questions
More FreeRTOS Quizzes