I have a task running on freeRTOS and I am checking how much application stack is unused in this application. What I see is, the available stack memory decreases after some time and stays at that value for a long time. The task has a while(1) loop and should use the same amount of stack but, I do not understand why the stack gets used up after some iterations of the loop. This is what my task looks like:
void Task A(void *arg)
{
Initialize_some_variables;
while(1)
{
print(uxTaskGetStackHighWaterMark( NULL ));
sem_wait(some_sem);
xQueueReceive(some_q);
process_q_data();
send_response_over_uart();
print(uxTaskGetStackHighWaterMark( NULL ));
}
}
My stack should have the same free words as it would from the first iteration of the while loop. but, I see that after some time the free word count returned by GetStackHighWaterMark reduces and I am not able to account for that.
sbrkis or is it measured by summing all malloced blocks (I doubt that the latter)? - KamilCuk