probably FreeRTOS bug found!

nobody wrote on Thursday, December 21, 2006:

i have probably found a bug in tasks.c:

instead of this line in xTaskCreate():
pxTopOfStack = pxNewTCB->pxStack + ( pxNewTCB->usStackDepth - 1 );

the following line has to be written:
pxTopOfStack = pxNewTCB->pxStack + ( usStackDepth - 1 );

am i right??

nobody wrote on Thursday, December 21, 2006:

No -

In prvInitialiseTCBVariables():

pxTCB->usStackDepth = usStackDepth;

Therefore:

pxTopOfStack = pxNewTCB->pxStack + ( pxNewTCB->usStackDepth - 1 );
and
pxTopOfStack = pxNewTCB->pxStack + ( usStackDepth - 1 );

are the same.

Is your pxNewTCB->usStackDepth varaible getting corrupt?

Step through the code following the assignment to see where the corruption occurs.  Sounds like you might have a linker configuration error.

nobody wrote on Thursday, December 21, 2006:

"Sounds like you might have a linker configuration error.  "
what could I have done wrong at the linker settings?
I use the H8S2398 CPU with 8k RAM

the sections I use are:
.vects 0x00000000
.text  0x00000400
.bss   0x00FFDC00
.stack 0x00FFFBF0

is this wrong?
with the original code it worked for stack sizes until 255, if I use 256
pxNewTCB->usStackDepth gets a value of 0x10000

with my modification it works.
???

imajeff wrote on Tuesday, December 26, 2006:

I have sometimes noticed where the choice of code seems to fail to optimize for size nor speed. So why (pxNewTCB->usStackDepth - 1) instead of (usStackDepth - 1) When obviously the latter would excecute better? Shoot, is this RTOS, or is this MS?