struct tskTaskControlBlock in tasks.c

hinashri wrote on Thursday, October 10, 2019:

I have a question about the first and second parameters (pxTopOfStack and xMPUSettings) of this structure. Inline comment for pxTopOfStack says that “THIS MUST BE THE FIRST MEMBER OF THE TCB STRUCT.” And similarly for xMPUSettings the inline comment says “THIS MUST BE THE SECOND MEMBER OF THE TCB STRUCT”. I would like to know the reason behind them being in the first and the second place in the structure.

rtel wrote on Friday, October 11, 2019:

The assembly code in the context switch obtains a pointer to the task
control block - from which it uses fixed offsets from the start of the
TCB to access members of the TCB. In the case of an offset being 0
(pxTopOfStack) it doesn’t need an offset at all. If you change the
order of structure members marked as ‘don’t move’ in the comments then
the scheduler will not work as the asm code will use the wrong offsets.

hinashri wrote on Friday, October 18, 2019:

Thanks Richard !


-----“Richard Barry” <rtel@users.sourceforge.net> wrote: -----
To: "[freertos:discussion] " <382005@discussion.freertos.p.re.sourceforge.net>
From: “Richard Barry” <rtel@users.sourceforge.net>
Date: 10/10/2019 05:37PM
Subject: [freertos:discussion] Re: struct tskTaskControlBlock in tasks.c

The assembly code in the context switch obtains a pointer to the task

control block - from which it uses fixed offsets from the start of the

TCB to access members of the TCB. In the case of an offset being 0

(pxTopOfStack) it doesn’t need an offset at all. If you change the

order of structure members marked as ‘don’t move’ in the comments then

the scheduler will not work as the asm code will use the wrong offsets.


struct tskTaskControlBlock in tasks.c [sourceforge.net]


Sent from sourceforge.net because you indicated interest in https://sourceforge.net/p/freertos/discussion/382005/ [sourceforge.net]

To unsubscribe from further messages, please visit https://sourceforge.net/auth/subscriptions/ [sourceforge.net]

</div>

</div>