11.07.2015 Views

IAR PowerPac RTOS User Guide

IAR PowerPac RTOS User Guide

IAR PowerPac RTOS User Guide

SHOW MORE
SHOW LESS
  • No tags were found...

Create successful ePaper yourself

Turn your PDF publications into a flip-book with our unique Google optimized e-Paper software.

We recommend using OS_EnterIntStack() and OS_LeaveIntStack() even if there is currently no additionalbenefit for your specific CPU, because code that uses them might reduce stack size on another CPU or a new versionof <strong>IAR</strong> <strong>PowerPac</strong> <strong>RTOS</strong> with support for an interrupt stack for your CPU. For details about interrupt stacks, see theCPU & Compiler Specifics manual of <strong>IAR</strong> <strong>PowerPac</strong> <strong>RTOS</strong> documentation.Stacks API function overviewRoutineOS_GetStackSpace()Table 112: Stacks API overviewOS_GetStackSpace()DescriptionReturns the unused portion of a task stack.Prototypeint OS_GetStackSpace (OS_TCB* pTask);ParameterDescriptionpTaskTable 113: OS_GetStackSpace() parameter listReturn valueThe unused portion of the task stack in bytes.Additional InformationIn most cases, the stack size required by a task cannot be easily calculated, because it takes quite some time to calculatethe worst-case nesting and the calculation itself is difficult.However, the required stack size can be calculated using the function OS_GetStackSpace(), which returns thenumber of unused bytes on the stack. If there is a lot of space left, you can reduce the size of this stack and vice versa.This function is only available in the debug and stack check builds of <strong>IAR</strong> <strong>PowerPac</strong> <strong>RTOS</strong>, because only these buildsinitialize the stack space used for the tasks.ImportantThis routine does not reliably detect the amount of stack space left, because it can only detect modified bytes on thestack. Unfortunately, space used for register storage or local variables is not always modified. In most cases, thisroutine will detect the correct amount of stack bytes, but in case of doubt, be generous with your stack space or useother means to verify that the allocated stack space is sufficient.ExampleDescriptionReturns the unused portion of a task stack.The task who's stack space is to be checked.NULL means current task.void CheckSpace(void) {printf("Unused Stack[0] %d", OS_GetStackSpace(&TCB[0]);OS_Delay(1000);printf("Unused Stack[1] %d", OS_GetStackSpace(&TCB[1]);OS_Delay(1000);}98<strong>IAR</strong> <strong>PowerPac</strong> <strong>RTOS</strong>for ARM CoresPP<strong>RTOS</strong>-2

Hooray! Your file is uploaded and ready to be published.

Saved successfully!

Ooh no, something went wrong!