Hello, I'm new freeRTOS learner, I'm trying to understand v9.0 source code about task.c,
When I want to create a new task, using xTaskCreate(), it will later call prvInitialiseNewTask(), there are some code I'm confused here,
if( portSTACK_GROWTH < 0 )
pxTopOfStack = pxNewTCB->pxStack + ( ulStackDepth - ( uint32t ) 1 );
pxTopOfStack = ( StackTypet * ) ( ( ( portPOINTERSIZETYPE ) pxTopOfStack ) & ( ~( ( portPOINTERSIZETYPE ) portBYTEALIGNMENTMASK ) ) );
I'm not sure why to calculate topStack need to minus 1,
I read pxPortInitialiseStack(), and found that everytime it need stack space, it will minus position first, then use space,
So I really not sure why to -1 when calculate topStack first time, and need alignment it later, did this waste space?
This post came out of moderation - I think it has been answered already.