I'm currently working on freertos with stm32f4. After creating the project with cubemx with below configration.
Its seem RTOS has around 25k bytes for me to allocate stacks to threads. But somehow when i create thread with stack size 1000. It has only 20888 bytes left for total heap of RTOS. If i allocate 2000. It got 16888 left. It seems like it always consumes 4 times of stack size allocation. Really really confused about what is happening.
osThreadDef(Task_Embedded, Task_VATEmbedded, osPriorityNormal, 0, 1000);
VATEmbeddedTaskHandle = osThreadCreate(osThread(Task_Embedded), NULL);
osThreadId osThreadCreate (const osThreadDef_t *thread_def, void *argument)
{
TaskHandle_t handle;
if (xTaskCreate((TaskFunction_t)thread_def->pthread,(const portCHAR *)thread_def->name,
thread_def->stacksize, argument, makeFreeRtosPriority(thread_def->tpriority),
&handle) != pdPASS) {
return NULL;
}
return handle;
}