Bird
0
0

What is the flaw in this Resource Manager Task implementation?

medium📝 Debug Q7 of 15
FreeRTOS - Design Patterns for RTOS
What is the flaw in this Resource Manager Task implementation?
void ResourceManagerTask(void *pvParameters) {
  Request req;
  while(1) {
    if(xQueueReceive(queue, &req, portMAX_DELAY)) {
      // Process request
    }
    vTaskDelete(NULL);
  }
}
ACalling vTaskDelete(NULL) inside the infinite loop causes premature task deletion
BUsing portMAX_DELAY causes the task to never unblock
CThe queue receive call lacks a timeout parameter
DThe request variable is not initialized before use
Step-by-Step Solution
Solution:
  1. Step 1: Understand vTaskDelete(NULL)

    Calling vTaskDelete(NULL) deletes the currently running task.
  2. Step 2: Analyze loop behavior

    Since vTaskDelete(NULL) is inside the loop, the task deletes itself after first iteration.
  3. Final Answer:

    Task deletes itself prematurely -> Option A
  4. Quick Check:

    Deleting self inside loop stops task after one request [OK]
Quick Trick: vTaskDelete(NULL) stops the current task immediately [OK]
Common Mistakes:
  • Thinking portMAX_DELAY blocks forever incorrectly
  • Assuming queue receive needs timeout parameter
  • Ignoring task deletion effect

Want More Practice?

15+ quiz questions · All difficulty levels · Free

Free Signup - Practice All Questions
More FreeRTOS Quizzes