Bird
0
0

Given this watchdog task snippet:

medium📝 Debug Q14 of 15
FreeRTOS - Design Patterns for RTOS
Given this watchdog task snippet:
void WatchdogTask(void *pvParameters) {
    for (;;) {
        if (xSemaphoreTake(watchdogSemaphore, 0) == pdTRUE) {
            // Reset received
        } else {
            // No reset, take action
        }
        vTaskDelay(pdMS_TO_TICKS(1000));
    }
}

What is the main problem with this code?
AThe task deletes itself after one loop
BThe task delays too long after receiving a reset signal
CThe semaphore wait time is zero, so it never blocks to wait for reset signals
DThe semaphore is given incorrectly in the monitored task
Step-by-Step Solution
Solution:
  1. Step 1: Examine semaphore wait time parameter

    The call xSemaphoreTake(watchdogSemaphore, 0) means it does not wait and returns immediately.
  2. Step 2: Understand impact on watchdog behavior

    Because it never blocks, the watchdog may miss reset signals if they arrive after the check, causing false recovery actions.
  3. Final Answer:

    The semaphore wait time is zero, so it never blocks to wait for reset signals -> Option C
  4. Quick Check:

    Zero wait means no blocking = D [OK]
Quick Trick: Semaphore wait time zero means no blocking, causing missed signals [OK]
Common Mistakes:
  • Thinking delay length is the problem
  • Assuming semaphore is given incorrectly without evidence
  • Believing task deletes itself here

Want More Practice?

15+ quiz questions · All difficulty levels · Free

Free Signup - Practice All Questions
More FreeRTOS Quizzes