[Return to Bookshelf] [Contents] [Previous Section] [Next Section] [Index] [Help]


pthread_attr_setstacksize

Changes the stacksize attribute in the specified thread attributes object.

Syntax

pthread_attr_setstacksize(
                          attr,
                          stacksize );
 


Argument Data Type Access

attr opaque pthread_attr_t write stacksize size_t read


C Binding

#include 

int pthread_attr_setstacksize ( pthread_attr_t *attr, size_t stacksize);

Arguments

attr
Threads attributes object to be modified.
stacksize
New value for the stacksize attribute. The stacksize argument must be greater than or equal to PTHREAD_STACK_MIN. PTHREAD_STACK_MIN specifies the minimum size (in bytes) of stack needed for a thread.

Description

This routine sets the stacksize attribute in the attr object. Use this routine to adjust the size of the writable area of the stack for threads that will be created.

A thread's stack is fixed at the time of thread creation. Only the initial thread can dynamically extend its stack.

Many compilers do not check for stack overflow. Ensure that your thread stack is large enough for anything that you call from the thread.

Return Values

If an error condition occurs, this routine returns an integer value indicating the type of error. Possible return values are as follows:
Return        Description

0 Successful completion. [EINVAL] The value specified by attr is invalid, or the value specified by stacksize is less than {PTHREAD_STACK_MIN} or exceeds a system-imposed limit.


Associated Routines

   pthread_attr_init
   pthread_attr_getstacksize
   pthread_create



[Return to Bookshelf] [Contents] [Previous Section] [Next Section] [Index] [Help]