rtel wrote on Thursday, March 27, 2008:
> Nice work!!!!
> I’m happy to see in this release some features we discussed in forum!
Not everything yet, but we are getting there.
> I appreciated trace macros in the core api!!
I’m just writing the documentation for those now and realise that some are not placed in optimal positions to get out the best information. I will make some minor adjustments for the next release but these will only be tiny.
> Just some questions:
> 1. I saw in task.c this code for stack highwatermark:
> #if ( INCLUDE_uxTaskGetStackHighWaterMark == 1 )
> unsigned portBASE_TYPE uxTaskGetStackHighWaterMark(
> xTaskHandle xTask )
> tskTCB *pxTCB;
> pxTCB = prvGetTCBFromHandle( xTask );
> return usTaskCheckFreeStackSpace( ( unsigned
> portCHAR * ) pxTCB->pxStack );
> This code can give information about the worst level reached
> by the stack.
> If you want only the current stack size, can we do something like:
> (pxTCB->pxTopOfStack - pxTCB->pxStack) to obtain the current
> used stack?
On the assumption that the stack is growing down (correct for nearly all architectures), pxStack will be the lowest address toward which the stack is growing, so I think it would be more like ( total stack size - ( pxTCB->pxTopOfStack - pxTCB->pxStack ) ) to give the actual current stack usage rather than the high water mark.
> 2. I didn’t use in the past ricursive mutex… so i hope we’’
> find some explanation
> in api documentation in website
That was there already. See http://www.freertos.org/xSemaphoreCreateRecursiveMutex.html and FreeRTOS/demo/common/recmutex.c.
> 3. what’s the purpose of portCriticalNestingInTCB ???
Ports that use a critical nesting count have to save and restore the critical nesting count as part of the task context. This means the save/restore asm code has to access the critical nesting variable and push/pop to/from the stack. As this is done in asm code it is different for each port. As an alternative I decided that the critical nesting count could actually be stored in the TCB, this way the saving and restoring of the critical nesting can be done in a portable way from C code rather than from asm code. The PowerPC port (being the newest) is the only port that uses this mechanism so far. It is RAM neutral in that you save a word of stack space, but loose a word in the TCB.