Bird
0
0

Given the code snippet:

medium📝 Predict Output Q4 of 15
FreeRTOS - Task Creation and Management
Given the code snippet:
void vTask(void *pvParameters) { int a[50]; while(1) { /* task code */ } }
xTaskCreate(vTask, "Task", 50, NULL, 1, NULL);
What is the likely problem with this stack size allocation?
AStack size is too small to hold the local array 'a'
BStack size is too large and wastes memory
CStack size matches the array size perfectly
DStack size should be specified in bytes, not words
Step-by-Step Solution
Solution:
  1. Step 1: Analyze local variable size

    The array 'a' has 50 integers; each integer is typically one word, so it needs 50 words minimum.
  2. Step 2: Consider additional stack usage

    Besides 'a', the task needs stack for function calls and other variables, so 50 words is too small.
  3. Final Answer:

    Stack size is too small to hold the local array 'a' -> Option A
  4. Quick Check:

    Stack size must cover all local data plus overhead [OK]
Quick Trick: Stack size must cover all local variables plus overhead [OK]
Common Mistakes:
  • Assuming stack size equals local array size is enough
  • Ignoring extra stack needed for function calls
  • Confusing words with bytes

Want More Practice?

15+ quiz questions · All difficulty levels · Free

Free Signup - Practice All Questions
More FreeRTOS Quizzes