The function pthread_attr_init lets us create an attributes object for threads.
1 int
2 pthread_attr_init (
3 pthread_attr_t *attr);
This function initializes the attributes object attr to the default values. Upon successful completion, the function returns a 0, otherwise it returns an error code.
The attributes object may be destroyed using the function pthread_attr_destroy.
1 int
2 pthread_attr_destroy (
3 pthread_attr_t *attr);
The call returns a 0 on successful removal of the attributes object attr.
Individual properties associated with the attributes object can be changed using the following functions:
pthread_attr_setdetachstate,
pthread_attr_setguardsize_np, pthread_attr_setstacksize,
pthread_attr_setinheritsched, pthread_attr_setschedpolicy, and pthread_attr_setschedparam.
These functions can be used to set the detach state in a thread attributes object, the stack guard size, the stack size, whether scheduling policy is inherited from the creating thread, the scheduling policy (in case it is not inherited), and scheduling parameters, respectively.
For most parallel programs, default thread properties are generally adequate.