pthread_condattr_destroy or pthread_condattr_init Subroutine

Purpose

Initializes and destroys condition variable.

Library

Threads Library (libpthreads.a)

Syntax

#include <pthread.h>

int pthread_condattr_destroy (attr)
pthread_condattr_t *attr;

int pthread_condattr_init (attr)
pthread_condattr_t *attr;

Description

The function pthread_condattr_init initializes a condition variable attributes object attr with the default value for all of the attributes defined by the implementation. Attempting to initialize an already initialized condition variable attributes object results in undefined behavior.

After a condition variable attributes object has been used to initialize one or more condition variables, any function affecting the attributes object (including destruction) does not affect any previously initialized condition variables.

The pthread_condattr_destroy function destroys a condition variable attributes object; the object becomes, in effect, uninitialized. The pthread_condattr_destroy subroutine may set the object referenced by attr to an invalid value. A destroyed condition variable attributes object can be re-initialized using pthread_condattr_init; the results of otherwise referencing the object after it has been destroyed are undefined.

Parameter

Item Description
attr Specifies the condition attributes object to delete.

Return Values

If successful, the pthread_condattr_init and pthread_condattr_destroy functions return zero. Otherwise, an error number is returned to indicate the error.

Error Code

The pthread_condattr_init function will fail if:

Item Description
ENOMEM Insufficient memory exists to initialize the condition variable attributes object.

The pthread_condattr_destroy function may fail if:

Item Description
EINVAL The value specified by attr is invalid.

These functions will not return an error code of EINTR.