0
0
FreeRTOSprogramming~10 mins

pvPortMalloc and vPortFree in FreeRTOS - Interactive Code Practice

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

Complete the code to allocate memory dynamically using FreeRTOS.

FreeRTOS
void *ptr = [1](100);
Drag options to blanks, or click blank then click option'
AvPortFree
Bmalloc
CpvPortMalloc
Dfree
Attempts:
3 left
💡 Hint
Common Mistakes
Using standard malloc instead of pvPortMalloc.
Confusing allocation with freeing functions.
2fill in blank
medium

Complete the code to free the allocated memory using FreeRTOS.

FreeRTOS
void *ptr = pvPortMalloc(50);
[1](ptr);
Drag options to blanks, or click blank then click option'
AvPortFree
Bmalloc
Cfree
DpvPortMalloc
Attempts:
3 left
💡 Hint
Common Mistakes
Using free instead of vPortFree.
Calling pvPortMalloc instead of freeing memory.
3fill in blank
hard

Fix the error in the code to correctly allocate and free memory in FreeRTOS.

FreeRTOS
char *buffer = [1](256);
// Use buffer
vPortFree(buffer);
Drag options to blanks, or click blank then click option'
ApvPortMalloc
Bmalloc
CvPortFree
Dcalloc
Attempts:
3 left
💡 Hint
Common Mistakes
Mixing standard malloc/free with FreeRTOS memory functions.
Not using vPortFree to free pvPortMalloc memory.
4fill in blank
hard

Fill both blanks to create a buffer, check allocation success, and free it properly.

FreeRTOS
char *buf = [1](128);
if (buf == [2]) {
    // handle error
}
vPortFree(buf);
Drag options to blanks, or click blank then click option'
ApvPortMalloc
BNULL
Cmalloc
D0
Attempts:
3 left
💡 Hint
Common Mistakes
Checking against 0 instead of NULL.
Using malloc instead of pvPortMalloc.
5fill in blank
hard

Fill all three blanks to allocate memory, check success, and free it correctly in FreeRTOS.

FreeRTOS
void *mem = [1](size);
if (mem == [2]) {
    return -1;
}
[3](mem);
Drag options to blanks, or click blank then click option'
Amalloc
BNULL
CvPortFree
DpvPortMalloc
Attempts:
3 left
💡 Hint
Common Mistakes
Using standard malloc/free instead of FreeRTOS functions.
Not checking for NULL after allocation.