Why uxTaskGetStackHighWaterMark can be higher than main task stack size?

Ragtime
Posts: 2
Joined: Wed Sep 09, 2020 9:37 am

Why uxTaskGetStackHighWaterMark can be higher than main task stack size?

Postby Ragtime » Tue Mar 09, 2021 2:59 pm

Hi,

does anyone know why the return value of `uxTaskGetStackHighWaterMark()` for main task can be higher than the "Main task stack size" set in sdkconfig?

In my `sdkconfig`:
Common ESP-related -> Main task stack size: 20000

Here is my `main.c`:
  1. #include <stdio.h>
  2. #include "freertos/FreeRTOS.h"
  3. #include "freertos/task.h"
  4. #include "esp_system.h"
  5. #include "esp_spi_flash.h"
  6.  
  7.  
  8.  
  9. void app_main()
  10. {
  11.     printf("stackHWM: %d\n", uxTaskGetStackHighWaterMark(NULL)); // in console: stackHWM: 20024
  12.  
  13. }
I expect the stackHighWaterMark to be no more than 20000, but it's actually 24 bytes higher than that.

The value is even higher if the "Optimization Level" is set to `Debug (-Og)`.

idf version: 4.0


Ragtime
Posts: 2
Joined: Wed Sep 09, 2020 9:37 am

Re: Why uxTaskGetStackHighWaterMark can be higher than main task stack size?

Postby Ragtime » Tue Mar 09, 2021 7:13 pm

Great! Thank you!

Who is online

Users browsing this forum: Google [Bot] and 96 guests