HP-UX Reference (11i v2 07/12) - 3 Library Functions N-Z (vol 7)

p
pthread_default_stacksize_np(3T) pthread_default_stacksize_np(3T)
(Pthread Library)
NAME
pthread_default_stacksize_np() - change the default stacksize.
SYNOPSIS
#include <pthread.h>
int pthread_default_stacksize_np(
size_t new_size,
size_t *old_size
);
PARAMETERS
new_size The new default stack size.
old_size Pointer to where the old default stack size is returned.
DESCRIPTION
The pthread_default_stacksize_np()
function allows an application to change the default value
for the stacksize attribute. This function must be called before any threads have been created. The new
default stack size is passed in the new_size parameter. If not
NULL, the previous default stack size is
returned in old_size.Ifnew_size is zero, this function can be used (at any time) to query the current
default stack size.
On HP-UX, threads with default stack sizes are cached after they terminate. The next time a thread is
created with a default stack size, a cached thread (and its stack) are reused. This can result in significant
performance improvements for pthread_create()
.
However, if the default stack size is not appropriate for an application, it cannot take advantage of this per-
formance enhancement. By using the
pthread_default_stacksize_np()
function, the threads
library will change the default stack size so that it matches the applications needs. This allows the applica-
tion to utilize the performance benefit of cached threads.
WARNING
If the environment variable
PTHREAD_DEFAULT_STACK_SIZE
is set with valid value for default stack
size, then it takes precedence over the invocation of the
pthread_default_stacksize_np()
inter-
face. However, it returns current default stack size in old_size. Also, the maximum default stack size value
that can be set through
PTHREAD_DEFAULT_STACK_SIZE
environment variable is restricted to 10 MB
and any value above the same will be rounded off to 10 MB. Care should be taken while setting the default
stack size limits as this could impact the maximum number of threads that can be created in a process.
RETURN VALUE
Upon successful completion,
pthread_default_stacksize_np()
returns zero. Otherwise, an error
number is returned to indicate the error (the
errno variable is not set).
ERRORS
If any of the following occur, the pthread_default_stacksize_np()
function returns the
corresponding error number:
[EINVAL] The value specified by new_size is less than
PTHREAD_STACK_MIN
.
[EPERM] The calling process has already created threads (this must be called before any
threads are created).
AUTHOR
pthread_default_stacksize_np() was developed by HP.
SEE ALSO
pthread_attr_getstacksize(3T), pthread_attr_setstacksize(3T).
STANDARDS CONFORMANCE
pthread_default_stacksize_np(): None.
214 Hewlett-Packard Company − 1 − HP-UX 11i Version 2: December 2007 Update