pthread_attr_destroy

Synopsis

#include <pthread.h>

int pthread_attr_destroy(pthread_attr_t *attr);

int pthread_attr_init(pthread_attr_t *attr);

Status

Implemented

Conformance

IEEE Std 1003.1-2017

Description

The pthread_attr_destroy() function shall destroy a thread attributes object. An implementation may cause pthread_attr_destroy() to set attr to an implementation-defined invalid value. A destroyed attr attributes object can be reinitialized using pthread_attr_init(); the results of otherwise referencing the object after it has been destroyed are undefined.

The pthread_attr_init() function shall initialize a thread attributes object attr with the default value for all the individual attributes used by a given implementation. In Phoenix-RTOS the default values are:

  • detachstate - PTHREAD_CREATE_JOINABLE,

  • inheritsched - PTHREAD_EXPLICIT_SCHED,

  • schedpolicy - SCHED_RR,

  • schedparam - the default priority of Phoenix-RTOS threads (see Scheduling priorities),

  • contentionscope - PTHREAD_SCOPE_SYSTEM,

  • stackaddr - NULL (the stack is allocated by pthread_create()),

  • stacksize - PTHREAD_STACK_MIN rounded up to a multiple of the page size,

  • guardsize - 0.

The resulting attributes 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(). Results are undefined if pthread_attr_init() is called specifying an already initialized attr attributes object.

The behavior is undefined if the value specified by the attr argument to pthread_attr_destroy() does not refer to an initialized thread attributes object.

Return value

Upon successful completion, pthread_attr_destroy() and pthread_attr_init() shall return a value of 0; otherwise, an error number shall be returned to indicate the error.

Errors

The pthread_attr_init() function shall fail if:

  • ENOMEM - Insufficient memory exists to initialize the thread attributes object.

These functions shall not return an error code of EINTR.

POSIX deviations

No POSIX deviations discovered.