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


pthread_attr_setstacksize

Changes the stacksize attribute of thread creation.

Syntax

pthread_attr_setstacksize(
                          attr,
                          stacksize );
 


Argument Data Type Access

attr opaque pthread_attr_t read stacksize longword read


C Binding

int
pthread_attr_setstacksize (
pthread_attr_t *attr,
long stacksize);

Arguments

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

Description

This routine sets the minimum size (in bytes) of the stack needed for a thread created using the attributes object specified by the attr argument. Use this routine to adjust the size of the writable area of the stack. The default stacksize value is available by calling pthread_attr_getstacksize on a newly created attributes object.

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

Most 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 -1 and sets errno to the corresponding error value. Possible return values are as follows:
Return  Error         Description

0 Successful completion. -1 [EINVAL] The value specified by attr is invalid.



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