[ Bottom of Page | Previous Page | Next Page | Contents | Index | Library Home |
Legal |
Search ]
Technical Reference: Base Operating System and Extensions, Volume 1
pthread_attr_setstackaddr Subroutine
Purpose
Sets the value of the stackaddr attribute of a thread
attributes object.
Library
Threads Library (libpthreads.a)
Syntax
#include <pthread.h>
int pthread_attr_setstackaddr (attr, stackaddr)
pthread_attr_t *attr;
void *stackaddr;
Description
The pthread_attr_setstackaddr subroutine
sets the value of the stackaddr attribute of the thread attributes object attr. This attribute specifies the stack address of a
thread created with this attributes object.
Note:
The pthread.h header file must be the
first included file of each source file using the threads library. Otherwise,
the -D_THREAD_SAFE compilation flag should be used,
or the cc_r compiler used. In this case, the flag is automatically set.
A Provision has been made in libpthreadsto create
guardpages for the user stack internally. This is used for debugging purposes
only. By default, it is turned off and can be invoked by exporting the following
environment variable:
AIXTHREAD_GUARDPAGES_FOR_USER_STACK=n (Where n is the decimal number of guard pages.)
Note:
Even if it is exported, guard pages will only be constructed
if both the stackaddr and stacksize attributes have been set by the caller
for the thread. Also, the guard pages and alignment pages will be created
out of the user's stack (which will reduce the stack size). If the new stack
size after creating guard pages is less than the minimum stack size (PTHREAD_STACK_MIN),
then the guard pages will not be constructed.
Parameters
|
attr |
Specifies the thread attributes object. |
|
stackaddr |
Specifies the stack address to set. It is a void pointer. The address
that needs to be passed is not the beginning of the malloc generated address
but the beginning of the stack. For example:
stackaddr = malloc(stacksize);
pthread_attr_setstackaddr(&thread, stackaddr + stacksize);
|
Return Values
Upon successful completion, 0 is returned. Otherwise,
an error code is returned.
Error Codes
The pthread_attr_setstackaddr subroutine
is unsuccessful if the following is true:
|
EINVAL |
The attr parameter is not valid. |
|
ENOSYS |
The stack address POSIX option is not implemented. |
Related Information
The pthread_attr_getstackaddr Subroutine, pthread_attr_init Subroutine, pthread.h file.
Advanced Attributes in AIX 5L Version 5.2 General Programming Concepts: Writing and Debugging Programs.
Threads Library Options in AIX 5L Version 5.2 General Programming Concepts: Writing and Debugging Programs.
[ Top of Page | Previous Page | Next Page | Contents | Index | Library Home |
Legal |
Search ]