# 26.16. Task Stack Allocator Configuration¶

This section describes configuration options related to the task stack allocator. RTEMS allows the application or BSP to define its own allocation and deallocation methods for task stacks. This can be used to place task stacks in special areas of memory or to utilize a Memory Management Unit so that stack overflows are detected in hardware.

CONSTANT:

CONFIGURE_TASK_STACK_ALLOCATOR

OPTION TYPE:

This configuration option is an initializer define.

DEFAULT VALUE:

The default value is _Workspace_Allocate, which indicates that task stacks will be allocated from the RTEMS Workspace.

DESCRIPTION:

The value of this configuration option initializes the stack allocator allocate handler.

NOTES:

A correctly configured system shall configure the following to be consistent:

CONSTRAINTS:

The value of the configuration option shall be defined to a valid function pointer of the type void *( *allocate )( size_t ).

CONSTANT:

CONFIGURE_TASK_STACK_ALLOCATOR_AVOIDS_WORK_SPACE

OPTION TYPE:

This configuration option is a boolean feature define.

DEFAULT CONFIGURATION:

If this configuration option is undefined, then the described feature is not enabled.

DESCRIPTION:

In case this configuration option is defined, then the system is informed that the task stack allocator does not use the RTEMS Workspace.

NOTES:

This configuration option may be used if a custom task stack allocator is configured, see CONFIGURE_TASK_STACK_ALLOCATOR.

CONSTANT:

CONFIGURE_TASK_STACK_ALLOCATOR_FOR_IDLE

OPTION TYPE:

This configuration option is an initializer define.

DEFAULT VALUE:

By default, the IDLE task storage area will be allocated from the RTEMS Workspace.

DESCRIPTION:

The value of this configuration option is the address for the stack allocator allocate handler used to allocate the task storage area of each IDLE task.

NOTES:

This configuration option is independent of the other thread stack allocator configuration options. It is assumed that any memory allocated for the task storage area of an IDLE task will not be from the RTEMS Workspace.

The IDLE task stack allocator may increase the size of the allocated memory area to account for the actually allocated memory area.

The

• CONFIGURE_TASK_STACK_ALLOCATOR_FOR_IDLE

configuration options are mutually exclusive.

CONSTRAINTS:

The following constraints apply to this configuration option:

• The value of the configuration option shall be defined to a valid function pointer of the type void *( *allocate )( uint32_t, size_t * ).

• The IDLE task stack allocator shall return a pointer to the allocated memory area or terminate the system with a fatal error if the allocation request cannot be satisfied.

• The IDLE task stack allocator may increase the size of the allocated memory area.

CONSTANT:

CONFIGURE_TASK_STACK_ALLOCATOR_INIT

OPTION TYPE:

This configuration option is an initializer define.

DEFAULT VALUE:

The default value is NULL.

DESCRIPTION:

The value of this configuration option initializes the stack allocator initialization handler.

NOTES:

A correctly configured system shall configure the following to be consistent:

CONSTRAINTS:

The value of the configuration option shall be defined to a valid function pointer of the type void ( *initialize )( size_t ) or to NULL.

CONSTANT:

CONFIGURE_TASK_STACK_DEALLOCATOR

OPTION TYPE:

This configuration option is an initializer define.

DEFAULT VALUE:

The default value is _Workspace_Free, which indicates that task stacks will be allocated from the RTEMS Workspace.

DESCRIPTION:

The value of this configuration option initializes the stack allocator deallocate handler.

NOTES:

A correctly configured system shall configure the following to be consistent:

CONSTRAINTS:

The value of the configuration option shall be defined to a valid function pointer of the type void ( *deallocate )( void * ).

CONSTANT:

CONFIGURE_TASK_STACK_FROM_ALLOCATOR

OPTION TYPE:

This configuration option is an initializer define.

DEFAULT VALUE:

The default value is a macro which supports the system heap allocator.

DESCRIPTION:

The value of this configuration option is used to calculate the task stack space size.

NOTES:

This configuration option may be used if a custom task stack allocator is configured, see CONFIGURE_TASK_STACK_ALLOCATOR.

CONSTRAINTS:

The value of the configuration option shall be defined to a macro which accepts exactly one parameter and returns an unsigned integer. The parameter will be an allocation size and the macro shall return this size plus the overhead of the allocator to manage an allocation request for this size.