[ Next Article | Previous Article | Book Contents | Library Home | Legal | Search ]
Base Operating System and Extensions Technical Reference, Volume 1

pthread_attr_init Subroutine

Purpose

Creates a thread attributes object and initializes it with default values.

Library

Threads Library (libpthreads.a)

Syntax

#include <pthread.h>
int pthread_attr_init (attr)
pthread_attr_t *attr;

Description

The pthread_attr_init subroutine creates a new thread attributes object attr. The new thread attributes object is initialized with the following default values:

Always initialized
Attribute Default value
Detachstate PTHREAD_CREATE_JOINABLE

Always Initialized
Attribute Default value
Contention-scope PTHREAD_SCOPE_PROCESS the default ensures compatibility with implementations that do not support this POSIX option.
Inheritsched PTHREAD_INHERITSCHED
Schedparam A sched_param structure which sched_prio field is set to 1, the least favored priority.
Schedpolicy SCHED_OTHER

Always Initialized
Attribute Default value
Stacksize PTHREAD_STACK_MIN
Guardsize PAGESIZE

The resulting attribute object (possibly modified by setting individual attribute values), when used by pthread_create, defines the attributes of the thread created. A single attributes object can be used in multiple simultaneous calls to pthread_create.

Parameters

attr Specifies the thread attributes object to be created.

Return Values

Upon successful completion, the new thread attributes object is filled with default values and returned via the attr parameter, and 0 is returned. Otherwise, an error code is returned.

Error Codes

The pthread_attr_init subroutine is unsuccessful if the following is true:

EINVAL The attr parameter is not valid.
ENOMEM There is not sufficient memory to create the thread attribute object.

This function will not return an error code of [EINTR].

Implementation Specifics

This subroutine is part of the Base Operating System (BOS) Runtime.

Related Information

The pthread_attr_setdetachstate subroutine, pthread_attr_setstackaddr subroutine, pthread_attr_setstacksize subroutine, pthread_create subroutine, pthread_attr_destroy and pthread_attr_setguardsize subroutine.

The pthread.h file.

Creating Threads in AIX Version 4.3 General Programming Concepts: Writing and Debugging Programs.

Threads Library Options and Threads Library Quick Reference in AIX Version 4.3 General Programming Concepts: Writing and Debugging Programs.


[ Next Article | Previous Article | Book Contents | Library Home | Legal | Search ]