Differences between v4.5.0 TCB and v4.4.0

jwestmoreland wrote on Tuesday, October 09, 2007:

Richard,

I looked at http://www.freertos.org/History.txt but didn’t see any mention of the TCB changes from v4.4.0 to v4.5.0 - can
you please elaborate on the changes:

v4.4.0:

/*
* Task control block.  A task control block (TCB) is allocated to each task,
* and stores the context of the task.
*/
typedef struct tskTaskControlBlock
{
    volatile portSTACK_TYPE    *pxTopOfStack;        /*< Points to the location of the last item placed on the tasks stack.  THIS MUST BE THE FIRST MEMBER OF THE STRUCT. */
    unsigned portBASE_TYPE    uxTCBNumber;        /*< This is used for tracing the scheduler and making debugging easier only. */
    xListItem                xGenericListItem;    /*< List item used to place the TCB in ready and blocked queues. */
    xListItem                xEventListItem;        /*< List item used to place the TCB in event lists. */
    unsigned portBASE_TYPE    uxPriority;            /*< The priority of the task where 0 is the lowest priority. */
    portSTACK_TYPE            *pxStack;            /*< Points to the start of the stack. */
    signed portCHAR            pcTaskName[ configMAX_TASK_NAME_LEN ];/*< Descriptive name given to the task when created.  Facilitates debugging only. */
    unsigned portSHORT        usStackDepth;        /*< Total depth of the stack (when empty).  This is defined as the number of variables the stack can hold, not the number of bytes. */
} tskTCB;

/*lint -e956 */

tskTCB * volatile data pxCurrentTCB = NULL;       

v4.5.0:

/*
* Task control block.  A task control block (TCB) is allocated to each task,
* and stores the context of the task.
*/
typedef struct tskTaskControlBlock
{
    volatile portSTACK_TYPE    *pxTopOfStack;        /*< Points to the location of the last item placed on the tasks stack.  THIS MUST BE THE FIRST MEMBER OF THE STRUCT. */
    xListItem                xGenericListItem;    /*< List item used to place the TCB in ready and blocked queues. */
    xListItem                xEventListItem;        /*< List item used to place the TCB in event lists. */
    unsigned portBASE_TYPE    uxPriority;            /*< The priority of the task where 0 is the lowest priority. */
    portSTACK_TYPE            *pxStack;            /*< Points to the start of the stack. */
    signed portCHAR            pcTaskName[ configMAX_TASK_NAME_LEN ];/*< Descriptive name given to the task when created.  Facilitates debugging only. */

    #if ( configUSE_TRACE_FACILITY == 1 )
        unsigned portBASE_TYPE    uxTCBNumber;        /*< This is used for tracing the scheduler and making debugging easier only. */
    #endif   
       
    #if ( configUSE_MUTEXES == 1 )
        unsigned portBASE_TYPE uxBasePriority;
    #endif
       
} tskTCB;

/*lint -e956 */

tskTCB * volatile pxCurrentTCB = NULL;                   

Thanks,
John W.

rtel wrote on Tuesday, October 09, 2007:

There were only a couple of minor changes.

The uxBasePriority member was introduced for the priority inheritance mechanism.  This is only used if mutexes are compiled in.

Adding this member could potentially increase the size of the TCB, depending on the configuration, so I optionally allowed another member to be excluded to lessen the impact.  The uxTCBNumber member has no use other than debugging/tracing, so I excluded this is the trace facility was not compiled in.

Regards.

jwestmoreland wrote on Tuesday, October 09, 2007:

Richard,

What about usStackDepth - can you explain why that was removed.

Also - can you point to the files for the following:

+ Optimised the GCC and IAR port layer code - specifically the context
      switch code.

I’d like to take a look at the part that detects whether a context switch is needed or not - maybe that is part of this
optimization.

Thanks,
John

rtel wrote on Tuesday, October 09, 2007:

>What about usStackDepth - can you explain why that was removed

This was obsolete.  It was only used in one place, and at that location the depth was available as a function parameter, so it was not needed.

>+ Optimised the GCC and IAR port layer code - specifically the context 
>switch code.

That comment is missing some vital information.  It should say "Optimised the GCC and IAR port layer code for the Cortex M3 ports".  The change does not effect any other ports as it is within the M3 specific assembly code.

Regards.

jwestmoreland wrote on Wednesday, October 10, 2007:

Richard,

Thanks - I’m going to take a look at the M3 assembly since I’m curious as to what you have done.

Thanks Again,
John