Task Stacks: Neethu Anie Saji Roll No:13 S2Pg
Task Stacks: Neethu Anie Saji Roll No:13 S2Pg
OS_STK *pstk;
pstk = (OS_STK *)malloc(stack_size);
If (pstk != (OS_STK *)0) {
Create the task;
}
Fragmentation:
OS_STK TaskStack[TASK_STACK_SIZE];
OSTaskCreate(task, pdata, &TaskStack[0], prio);
OS_STK TaskStack[TASK_STACK_SIZE];
OSTaskCreate(task, pdata,
&TaskStack[TASK_STACK_SIZE-1], prio);
This requirement affects code portability.
If you need to port your code from a processor
architecture that supports a downward growing
stack to an upward growing stack ie,Supporting
stacks which grow in either direction.
OS_STK TaskStack[TASK_STACK_SIZE];
#if OS_STK_GROWTH == 0
OSTaskCreate(task, pdata, &TaskStack[0], prio);
#else
OSTaskCreate(task, pdata, &TaskStack[TASK_STACK_SIZE1], prio);
#endif
The size of the stack needed by your task
is application specific.
When sizing the stack, however, you
must account for
Nesting of all the functions called by your task,
The number of local variables that will be
allocated by all functions called by your task
and,
The stack requirements for all nested interrupt
service routines.
In addition, your stack must be able to
store all CPU registers.
THANK YOU