The stack high water mark is the minimum amount of free stack space left during the lifetime of a task. It helps identify how much stack a task actually uses.
Click to reveal answer
beginner
Which FreeRTOS API function returns the stack high water mark for a task?
uxTaskGetStackHighWaterMark() returns the minimum amount of stack space that has remained for a task since it started.
Click to reveal answer
intermediate
Why is monitoring the stack high water mark important in embedded systems?
It helps prevent stack overflow by showing if a task's stack size is too small, which can cause crashes or unpredictable behavior.
Click to reveal answer
intermediate
How can you interpret a very low stack high water mark value?
A low value means the task used almost all its allocated stack, so you might need to increase the stack size to avoid overflow.
Click to reveal answer
beginner
What is a practical way to check the stack high water mark during runtime?
Call uxTaskGetStackHighWaterMark() inside the task or from a monitoring task and log or display the value for analysis.
Click to reveal answer
What does uxTaskGetStackHighWaterMark() return?
ATask priority level
BMaximum stack size allocated to task
CMinimum free stack space left since task start
DCurrent CPU usage of the task
✗ Incorrect
uxTaskGetStackHighWaterMark() returns the smallest amount of free stack space that has been available to the task since it started.
Why should you monitor the stack high water mark in FreeRTOS?
ATo detect potential stack overflow risks
BTo measure task execution time
CTo check memory leaks
DTo adjust task priority
✗ Incorrect
Monitoring the stack high water mark helps detect if a task's stack is too small and might overflow.
If a task's stack high water mark is very high, what does it mean?
AThe task uses very little stack space
BThe task is about to overflow its stack
CThe task has crashed
DThe task priority is too low
✗ Incorrect
A high stack high water mark means a lot of stack space remained unused, so the task uses little stack.
When is the best time to check the stack high water mark?
AOnly before starting the task
BOnly during task creation
CAfter the system shuts down
DDuring runtime, periodically or on demand
✗ Incorrect
Checking during runtime helps monitor stack usage dynamically and catch issues early.
What could happen if a task's stack overflows?
ATask runs faster
BSystem crashes or unpredictable behavior
CTask priority increases automatically
DStack size reduces automatically
✗ Incorrect
Stack overflow can corrupt memory and cause crashes or erratic system behavior.
Explain what the stack high water mark is and why it is useful in FreeRTOS.
Think about how much stack space a task actually uses versus what was allocated.
You got /3 concepts.
Describe how you would use uxTaskGetStackHighWaterMark() to improve system reliability.
Consider monitoring and reacting to stack usage data.
You got /3 concepts.
Practice
(1/5)
1.
What does the stack high water mark indicate in FreeRTOS?
easy
A. The total stack size allocated to a task
B. The minimum amount of free stack space a task has had
C. The maximum CPU usage of a task
D. The number of tasks currently running
Solution
Step 1: Understand stack high water mark meaning
The stack high water mark shows the smallest amount of unused stack space a task has had since it started.
Step 2: Compare with other options
Other options describe CPU usage, total stack size, or task count, which are unrelated to stack high water mark.
Final Answer:
The minimum amount of free stack space a task has had -> Option B
Quick Check:
Stack high water mark = minimum free stack space [OK]
Hint: Remember: 'high water mark' means lowest free stack left [OK]
Common Mistakes:
Confusing stack size with stack usage
Thinking it measures CPU or task count
Assuming it shows maximum stack used
2.
Which is the correct way to get the stack high water mark of the current task in FreeRTOS?
?
easy
A. uxTaskGetStackHighWaterMark(NULL);
B. uxTaskGetStackHighWaterMark(currentTask);
C. getStackHighWaterMark(NULL);
D. uxGetStackHighWaterMark();
Solution
Step 1: Recall function signature
The FreeRTOS function to get stack high water mark is uxTaskGetStackHighWaterMark, which takes a task handle or NULL for current task.
Step 2: Identify correct usage
Passing NULL gets the current task's high water mark. Other options use wrong function names or parameters.
Final Answer:
uxTaskGetStackHighWaterMark(NULL); -> Option A
Quick Check:
Use NULL for current task in uxTaskGetStackHighWaterMark [OK]
Hint: Use NULL to refer to current task handle [OK]
Common Mistakes:
Using wrong function names
Passing invalid parameters instead of NULL
Assuming no parameter needed
3.
Given the following code snippet, what will be the output if the task's minimum free stack space was 50 words?
UBaseType_t highWaterMark = uxTaskGetStackHighWaterMark(NULL);
printf("High water mark: %u\n", highWaterMark);