Follow+Star PublicNumber, don’t miss the wonderful content
Author | strongerHuang
WeChat Public Account | Embedded Column
xTaskCreate(LED_Task, "LED_Task", 128, NULL, 6, NULL);
If we want to elaborate on this question, there are many related knowledge points involved. Below are a few important related contents to answer this question.
Static and Dynamic Memory Allocation
Memory allocation is generally divided into: static and dynamic allocation.
1. Static Memory Allocation
Simply put, it is memory allocated at compile time. You can understand it as when the chip is powered on, a specified area (address) of memory is occupied.
There are generally a few situations, such as:
Startup allocation stack:
Stack_Size EQU 0x400
Defining a static variable is the easiest example to understand:
static int a;
Defining a global variable/array, etc.:
int char;
2. Dynamic Memory Allocation
void UART_Send(char *p){ char buf[10]; //......}
Sorting Out FreeRTOS Memory Allocation
1. Global Array (Stack)
The memory for FreeRTOS is allocated in the FreeRTOSConfig.h file as a global array, and the size of this memory is allocated by the user based on the situation, for example:
#define configTOTAL_HEAP_SIZE ((size_t)(10 * 1024))
2. Creating Tasks
FreeRTOS creates tasks, allocating stack size, for example: 128 “words”
xTaskCreate(LED_Task, "LED_Task", 128, NULL, 6, NULL);
Reminder: Here “word” is the unit, for example: uint32_t
3. Deleting Tasks
FreeRTOS deletes tasks, calling the “vPortFree()” function to release the corresponding memory.
Is FreeRTOS Dynamically Allocated Memory?
Having read this, can you answer the initial question?
The answer is: FreeRTOS is not dynamically allocated memory, it only simulates the way of dynamic allocation, and the actual memory is statically allocated.
Click “Read Original” to see more shares.
Leave a Comment
Your email address will not be published. Required fields are marked *