0
0
FreeRTOSprogramming~10 mins

Why memory management prevents runtime crashes in FreeRTOS - Test Your Understanding

Choose your learning style9 modes available
Practice - 5 Tasks
Answer the questions below
1fill in blank
easy

Complete the code to allocate memory safely in FreeRTOS.

FreeRTOS
void *ptr = pvPortMalloc([1]);
Drag options to blanks, or click blank then click option'
Asize
BNULL
C0
Dfree
Attempts:
3 left
💡 Hint
Common Mistakes
Passing NULL or zero causes no memory to be allocated.
2fill in blank
medium

Complete the code to check if memory allocation was successful.

FreeRTOS
if (ptr == [1]) {
    // handle error
}
Drag options to blanks, or click blank then click option'
Aptr
B0
CNULL
Dsize
Attempts:
3 left
💡 Hint
Common Mistakes
Checking against zero or the pointer itself instead of NULL.
3fill in blank
hard

Fix the error in the code to free allocated memory correctly.

FreeRTOS
vPortFree([1]);
Drag options to blanks, or click blank then click option'
Aptr
Bsize
Cfree
DNULL
Attempts:
3 left
💡 Hint
Common Mistakes
Passing NULL or size instead of the pointer.
4fill in blank
hard

Fill both blanks to create a safe memory allocation and check.

FreeRTOS
void *ptr = pvPortMalloc([1]);
if (ptr == [2]) {
    // handle error
}
Drag options to blanks, or click blank then click option'
Asize
BNULL
C0
Dptr
Attempts:
3 left
💡 Hint
Common Mistakes
Using zero or ptr instead of size and NULL.
5fill in blank
hard

Fill all three blanks to allocate, check, and free memory safely.

FreeRTOS
void *ptr = pvPortMalloc([1]);
if (ptr == [2]) {
    // handle error
} else {
    vPortFree([3]);
}
Drag options to blanks, or click blank then click option'
Asize
BNULL
Cptr
Dfree
Attempts:
3 left
💡 Hint
Common Mistakes
Mixing up variables or forgetting to check for NULL.