Challenge - 5 Problems
Memory Mastery in FreeRTOS
Get all challenges correct to earn this badge!
Test your skills under time pressure!
🧠 Conceptual
intermediate2:00remaining
Why does FreeRTOS use memory management?
In FreeRTOS, why is memory management important to prevent runtime crashes?
Attempts:
2 left
💡 Hint
Think about what happens if two tasks write to the same memory without control.
✗ Incorrect
Memory management in FreeRTOS prevents tasks from overwriting each other's data. This avoids data corruption and runtime crashes.
❓ Predict Output
intermediate2:00remaining
What happens if a task uses more memory than allocated?
Consider this FreeRTOS task code snippet that allocates a fixed stack size. What is the likely outcome if the task uses more stack than allocated?
FreeRTOS
void vTaskFunction(void *pvParameters) {
char buffer[50];
for (int i = 0; i < 100; i++) {
buffer[i] = 'A'; // writing beyond buffer size
}
vTaskDelete(NULL);
}Attempts:
2 left
💡 Hint
What happens when you write outside an array in C?
✗ Incorrect
Writing beyond the allocated stack size overwrites adjacent memory, causing crashes or corrupting data.
🔧 Debug
advanced2:00remaining
Identify the cause of a runtime crash in FreeRTOS
This FreeRTOS code causes a runtime crash. What is the main memory-related cause?
FreeRTOS
void vTask1(void *pvParameters) {
int *ptr = pvPortMalloc(sizeof(int) * 10);
for (int i = 0; i <= 10; i++) {
ptr[i] = i; // writing one element beyond allocated memory
}
vPortFree(ptr);
vTaskDelete(NULL);
}Attempts:
2 left
💡 Hint
Check the loop boundary and allocated size carefully.
✗ Incorrect
Writing beyond allocated memory corrupts the heap, causing runtime crashes.
📝 Syntax
advanced2:00remaining
Which FreeRTOS memory allocation code is correct?
Which option correctly allocates and frees memory in FreeRTOS without causing runtime errors?
Attempts:
2 left
💡 Hint
Check allocation size and matching free function.
✗ Incorrect
Option D correctly allocates memory with pvPortMalloc and frees it with vPortFree after checking for NULL.
🚀 Application
expert2:00remaining
How does FreeRTOS memory management prevent stack overflow crashes?
FreeRTOS allows setting stack overflow checking. How does this feature help prevent runtime crashes?
Attempts:
2 left
💡 Hint
Think about how detecting problems early helps prevent crashes.
✗ Incorrect
Stack overflow checking detects when a task exceeds its stack and calls a handler to prevent crashes.