FreeRTOS Support Archive
The FreeRTOS support forum is used to obtain active support directly from Real
Time Engineers Ltd. In return for using our top quality software and services for
free, we request you play fair and do your bit to help others too! Sign up
to receive notifications of new support topics then help where you can.
This is a read only archive of threads posted to the FreeRTOS support forum.
The archive is updated every week, so will not always contain the very latest posts.
Use these archive pages to search previous posts. Use the Live FreeRTOS Forum
link to reply to a post, or start a new support thread.
[FreeRTOS Home] [Live FreeRTOS Forum] [FAQ] [Archive Top] [May 2017 Threads]
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?
thanks =)
This post came out of moderation - I think it has been answered already.
Copyright (C) Amazon Web Services, Inc. or its affiliates. All rights reserved.