0
0
FreeRTOSprogramming~20 mins

vTaskList() for task status dump in FreeRTOS - Practice Problems & Coding Challenges

Choose your learning style9 modes available
Challenge - 5 Problems
🎖️
FreeRTOS Task Status Master
Get all challenges correct to earn this badge!
Test your skills under time pressure!
Predict Output
intermediate
2:00remaining
What is the output of vTaskList() buffer content?

Given a FreeRTOS system with three tasks named TaskA, TaskB, and TaskC, each with different states, what will the vTaskList() output buffer contain?

Assume the following states: TaskA is Running, TaskB is Ready, and TaskC is Blocked.

FreeRTOS
char buffer[512];
vTaskList(buffer);
printf("%s", buffer);
A
TaskA       R       1       100     0
TaskB       B       2       80      0
TaskC       R       3       60      0
B
TaskA       Running 1       100     0
TaskB       Ready   2       80      0
TaskC       Blocked 3       60      0
C
TaskA       R       1       100     0
TaskB       R       2       80      0
TaskC       R       3       60      0
D
TaskA       X       1       100     0
TaskB       R       2       80      0
TaskC       B       3       60      0
Attempts:
2 left
💡 Hint

Remember that vTaskList() uses single-letter codes for task states: X=Running, R=Ready, B=Blocked, S=Suspended, D=Deleted.

🧠 Conceptual
intermediate
1:30remaining
What does the 'Stack High Water Mark' value represent in vTaskList() output?

In the output of vTaskList(), there is a column showing the 'Stack High Water Mark' for each task. What does this value represent?

AThe minimum amount of free stack space remaining since the task started.
BThe maximum amount of stack space the task has used since it started.
CThe current amount of free stack space available to the task.
DThe total stack size allocated to the task.
Attempts:
2 left
💡 Hint

Think about what 'high water mark' usually means in memory usage.

🔧 Debug
advanced
2:00remaining
Why does vTaskList() output show incorrect task states?

A developer calls vTaskList() but notices that all tasks show the state 'R' (Ready) even though some tasks are blocked or suspended. What is the most likely cause?

AThe developer called <code>vTaskList()</code> from an interrupt context instead of a task context.
BThe buffer passed to <code>vTaskList()</code> is too small to hold the output.
CThe tasks were created with the same priority, causing state confusion.
DThe developer did not call <code>vTaskStartScheduler()</code> before calling <code>vTaskList()</code>.
Attempts:
2 left
💡 Hint

Consider where vTaskList() is safe to call from.

📝 Syntax
advanced
1:30remaining
Which code snippet correctly calls vTaskList() to print task status?

Choose the correct code snippet that declares a buffer and calls vTaskList() to print the task list to standard output.

A
char buffer[512];
vTaskList(&amp;buffer);
printf("%s\n", buffer);
B
char *buffer;
vTaskList(buffer);
printf("%s\n", buffer);
C
char buffer[512];
vTaskList(buffer);
printf("%s\n", buffer);
D
char buffer[512];
vTaskList(buffer, 512);
printf("%s\n", buffer);
Attempts:
2 left
💡 Hint

Check the function signature of vTaskList() and how buffers are passed in C.

🚀 Application
expert
2:30remaining
How to use vTaskList() output to detect stack overflow in a running system?

You want to monitor your FreeRTOS system for stack overflows by periodically checking the vTaskList() output. Which approach is best to detect a stack overflow early?

ACheck if any task's state is 'B' (Blocked), which means the task is stuck and may have overflowed stack.
BCheck if any task's 'Stack High Water Mark' value is zero or very low, indicating the stack is almost full.
CCheck if the number of tasks reported by <code>vTaskList()</code> is less than expected, indicating a crash.
DCheck if the task priorities have changed unexpectedly in the output.
Attempts:
2 left
💡 Hint

Think about what the stack high water mark tells you about stack usage.