Quality RTOS & Embedded Software

 Real time embedded FreeRTOS RSS feed 
Quick Start Supported MCUs PDF Books Trace Tools Ecosystem TCP & FAT




Loading

Confused about prvInitialiseNewTask() function

Posted by ctc8631 on May 22, 2017

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 =)


Confused about prvInitialiseNewTask() function

Posted by rtel on May 26, 2017

This post came out of moderation - I think it has been answered already.


[ Back to the top ]    [ About FreeRTOS ]    [ Sitemap ]    [ ]




Copyright (C) Amazon Web Services, Inc. or its affiliates. All rights reserved.

Latest News

FreeRTOS kernel V10 is available for immediate download. Now MIT licensed.


FreeRTOS Partners

ARM Connected RTOS partner for all ARM microcontroller cores

IAR Partner

Microchip Premier RTOS Partner

RTOS partner of NXP for all NXP ARM microcontrollers

STMicro RTOS partner supporting ARM7, ARM Cortex-M3, ARM Cortex-M4 and ARM Cortex-M0

Texas Instruments MCU Developer Network RTOS partner for ARM and MSP430 microcontrollers

OpenRTOS and SafeRTOS