pthread_attr_init Subroutine Purpose Creates a thread attributes object and initializes it with default values. Library Threads Library (libpthreads.a) Syntax #include 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_DETACHED | ------------------------------------------------------------------------------------------------------------------ ------------------------------------------------------------------------------------------------------------------ |Initialized if _POSIX_THREAD_PRIORITY_SCHEDULING is defined | |---------------------------------------------------------------------|------------------------------------------| |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 | ------------------------------------------------------------------------------------------------------------------ ------------------------------------------------------------------------------------------------------------------ |Initialized if _POSIX_THREAD_ATTR_STACKSIZE is defined | |---------------------------------------------------------------------|------------------------------------------| |Attribute |Default value | |---------------------------------------------------------------------|------------------------------------------| |Stacksize |PTHREAD_STACK_MIN | ------------------------------------------------------------------------------------------------------------------ The default values for the thread attributes can also be retrieved form the pthread.h header file. The following symbolic constants are defined: DEFAULT_DETACHSTATE Specifies the default value for the detachstate attribute. DEFAULT_SCOPE Specifies the default value for the contention-scope attribute. DEFAULT_INHERIT Specifies the default value for the inheritsched attribute. DEFAULT_PRIO Specifies the default value for the sched_prio field of the schedparam attribute. DEFAULT_SCHED Specifies the default value for the schedpolicy attribute. Note: The pthread.h header file must be the first included file of each source file using the threads library. 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. Implementation Specifics This subroutine is part of the Base Operating System (BOS) Runtime. The priority scheduling and stack size POSIX options are implemented in AIX. Related Information The pthread_attr_setdetachstate subroutine, pthread_attr_setinheritsched subroutine, pthread_attr_setschedparam subroutine, pthread_attr_setschedpolicy subroutine, pthread_attr_setscope subroutine, pthread_attr_setstackaddr subroutine, pthread_attr_setstacksize subroutine, pthread_create subroutine, pthread_attr_destroy subroutine. Creating Threads. Threads Library Options and Threads Library Quick Reference.