Complete the code to get the current free heap size in FreeRTOS.
size_t freeHeap = [1]();The function xPortGetFreeHeapSize() returns the current free heap size in bytes.
Complete the code to print the minimum ever free heap size in FreeRTOS.
printf("Min free heap: %u bytes\n", [1]());
xPortGetMinimumEverFreeHeapSize() returns the smallest amount of free heap ever recorded, useful for checking memory usage peaks.
Fix the error in the code to correctly get the free heap size.
size_t freeHeap = [1]();The correct function to get free heap size is xPortGetFreeHeapSize(). Other options are invalid or do not exist.
Fill both blanks to create a dictionary of task names and their stack high water marks.
TaskStatus_t taskStatusArray[[1]]; for (int i = 0; i < [2]; i++) { printf("Task: %s, Stack high water mark: %u\n", taskStatusArray[i].pcTaskName, taskStatusArray[i].usStackHighWaterMark); }
uxTaskGetNumberOfTasks() returns the number of tasks, used to size the array and loop count.
Fill all three blanks to create a filtered dictionary of tasks with stack high water mark below a threshold.
for (int i = 0; i < [1]; i++) { if (taskStatusArray[i].usStackHighWaterMark [2] [3]) { printf("Low stack task: %s, Water mark: %u\n", taskStatusArray[i].pcTaskName, taskStatusArray[i].usStackHighWaterMark); } }
The loop runs over all tasks using uxTaskGetNumberOfTasks(). The condition checks if the stack high water mark is less than 100 bytes to find tasks with low stack.