User-Managed Stack Attributes
If you want to allocate and manage a thread’s stack, the relevant attributes include the user stack address and user stack size.
The user stack address defines the lowest, or bottom address of the address space reserved, allocated, and managed by the user.
The user stack address is defined as a void* value.
The user stack size defines the memory space size of the user-allocated stack. It locates the top of the address space where the stack bottom is typically located (in those environments where stacks grow downward in memory).
The user stack size is defined in terms of some number of bytes using size_t values.
Using the feature test macro. The feature test macro for user stack support is RW_THR_HAS_USER_STACK. If this macro is not defined, attempts to query or set the user stack attributes always produce an exception. If it is defined, then the current environment has support for user stack attributes and allows you to get or set these attributes.
Member functions. The RWThreadAttribute member functions that define and manipulate the user stack attributes include:
canGetUserStack() — Indicates whether the user stack attributes are supported in the current environment and whether
getUserStackAddress() or
getUserStackSize() can currently return a legal value. Default values for user stack attributes do not exist, so this function returns
true only if the attributes have been set.
isUserStackSet() — Indicates whether the user stack attributes have been previously set by a call to
setUserStack(void*, size_t).
getUserStackAddress() — Returns the address value specified in the last call to
setUserStack(void*, size_t). If the current environment or circumstances do not allow interrogation of the user stack address, then attempts to use this function result in exceptions.
getUserStack() — Returns the stack size value specified in the last call to
setUserStack(void*, size_t). If the current environment or circumstances do not allow interrogation of the user stack size, then attempts to use this function result in exceptions.
canSetUserStack() — Indicates whether the user stack attribute is supported and can be set in the current environment.
setUserStack(void*, size_t) — Sets the user stack address and size to the values passed as arguments. If the current environment does not support these attributes or if the specified attribute values are outside their legal range, then the function produces an exception.
resetUserStack() — Restores the system-managed stack as the default stack allocation behavior for this thread attribute instance.
getMinStackSize() — Returns the minimum amount of stack space required to implement a thread that calls a null routine. The Threading package also insures that a system-managed stack is of sufficient size by adding this value to any value defined using
setStackReserveSize(size_t).
If the current environment or circumstances do not allow interrogation of the minimum stack size, then attempts to use this function result in exceptions. The availability of this function can be inferred by testing the result returned by either canGetStackReserveSize() or canGetUserStack().
Exceptions. Any attempt to read the default values for these attributes produces an RWTHRInternalError exception. These attributes have no default values.
For additional information on user stack management support, see the appropriate chapters in the Threads Module Platform Guide.