Zurück zu Willert.de

Application Note: Strauss Stack Size Configuration

Application Note: Strauss Stack Size Configuration

Postby eroemer » October 20th, 2011, 10:27 am

This application not is valid for Willert RXF Products Version 5.x.

Before you can inspect or specify various tasks, you need to understand the task usage in the RTOS adapters:
  • the bridge task is is the heartbeat of the Realtime eXecution Framework. The bridge task periodically wakes up and schedules the events for the (other) tasks in the RXF.
  • the main task is the task in which any object runs for which you did not specify in Rhapsody that its class is an active class:
    • by default, a class is not active. Each object created from this class runs in the main task.
    • for an object which is created via an active class, a new task is created.

In RTOS based frameworks there are multiple places where to configure different stack sizes. Generally, there are different types of stacks:

  • Stack used for the function main(), which is just used for initializing and starting the RTOS and creating the main task.
  • Stack of the main task, which is used for the main task running all sequential parts of the Rhapsody generated code. Its required stacksize depends on the RXF and code executed on behalf of non-active classes.
  • Stack for the bridge task. This stack can be relatively small because little code is executed in this task.
  • Stacks for user tasks which are the result of active classes. The stacksize for such a task can be configured individually at the Rhapsody model level or you may use a default stack size
  • Interrupt and target mode specific stacks

Stack Size for function main()

This stack setting is called “user / system mode stack size” and can be configured using USR_Stack_Size in the delivered example file Keil-ARM-Startup.s. It's default size is 64 bytes (0x40).


Main Task Stack Size

The stack size for the main task can be configured in WSTRTOS.h using the constant RTOS_MAIN_STK_SIZE. The default size is 512 bytes but the size required depends on your model: the code executed for non-active classes.


Bridge Task Stack Size

The bridge task is created using the os_tsk_create_ex() API where no stacksize can be specified. As a consequence, its stacksize relies on the default behaviour of the RTOS and you must configure the default task stack in your RTX_Config.c RL-ARM configuration file.

The RXF is delivered with a reference to Keil's RTX_Config.c file for a Philips microcontroller, located under <Keil>\ARM\Startup\Philips. If you have modified the file in its original place for other projects, it will also influence the Strauss GettingStarted sample project.

Best practice is to create a copy of the RTX_Config.c file for your microcontroller and either store it with your uVision project or set it up as a Rhapsody component file.
For details on adding files in the Rhapsody project, see

<your product>\Doc\Books\RXFDeployerGuide.pdf

The RTOS default stack size for RL-ARM can be set up using the OS_STKSIZE constant in RTX_Config.c. Its default value is 200 bytes.



Active Class Task Stack Size

Each task created for an active class uses the os_tsk_create_user_ex() API where a stacksize can be specified. This stacksize is taken from the generated C code from the Rhapsody model:
if you did not override a property for a stacksize, the value used is specified by the constant RTOS_DEFAULT_STACK in WSTRTOS.h.
if you did override this property, your new value is used.

Please note that there are two different ActiveStackSize properties: one is CG::Class::ActiveStackSize and the other is C_CG::Framework.ActiveStackSize.

According to Telelogic Development, the property CG::Class::ActiveStackSize affects active class constructor because stack size is defined while construction of active class. Framework properties are taken into account by the code generator only when class level properties are not defined.

Unfortunately, there are additional conditions when these properties affect code
generation. If all ActiveStackSize, ActiveMessageQueueSize, ActiveThreadPriority and
ActiveThreadName are empty in CG::Class properties, C_CG::Framework properties do not
affect code generation.
But if you change any of them then Framework properties
appear in generated code. CG::Class properties override values defined in the C_CG::Framework.

This means the easiest way for configuring individual stack sizes for your active objects is opening their properties dialog. Use the stack size property located under CG::Class::ActiveStackSize to set the stack size to your needs. In the generated code you should now see a call to RiCTask_Init() where one parameter matches your set up stack size.


Interrupt And Target Mode Specific Stacks

CPU and RTOS specific other stack sizes might need to be set up. For ARM processors and the Keil compiler, you can also setup stack sizes for different CPU operating modes:
  • Undefined Mode
  • Supervisor Mode
  • Abort Mode
  • Fast Interrupt Mode
  • Interrupt Mode

Please consult your target and compiler documentation regarding these target specific stack configurations. A good source for more information is also the knowledge base on http://www.keil.com. The default settings for these stack sizes are used in the example Keil-ARM-Startup.s.
User avatar
eroemer
 
Posts: 9
Joined: October 14th, 2011, 10:16 am
Location: Bremen
Company: Willert Software Tools GmbH

Return to Application Notes

Who is online

Users browsing this forum: No registered users and 0 guests