---
name: "pthread_condattr_init"
section: "3"
platform: "freebsd"
package: "base"
version: "16.0-CURRENT-20261027-61c70dc16a79"
release: "FreeBSD 16.0-CURRENT (2026-10-27)"
platforms: ["linux", "freebsd"]
url: "https://new.carta.tech/pthread_condattr"
---

# pthread\_condattr\_init(3)

condition attribute operations

Part of [pthread\_condattr(3)](/pthread_condattr/3.md).

## NAME

**pthread\_condattr\_init**, **pthread\_condattr\_destroy**, **pthread\_condattr\_getclock**, **pthread\_condattr\_setclock**, **pthread\_condattr\_getpshared**, **pthread\_condattr\_setpshared** – condition attribute operations

## LIBRARY

POSIX Threads Library (libpthread, -lpthread)

## SYNOPSIS

**#include \<pthread.h\>**

*int*\

**pthread\_condattr\_init**(*pthread\_condattr\_t \*attr*);

*int*\

**pthread\_condattr\_destroy**(*pthread\_condattr\_t \*attr*);

*int*\

**pthread\_condattr\_getclock**(*pthread\_condattr\_t \* restrict attr*, *clockid\_t \* restrict clock\_id*);

*int*\

**pthread\_condattr\_setclock**(*pthread\_condattr\_t \*attr*, *clockid\_t clock\_id*);

*int*\

**pthread\_condattr\_getpshared**(*pthread\_condattr\_t \* restrict attr*, *int \* restrict pshared*);

*int*\

**pthread\_condattr\_setpshared**(*pthread\_condattr\_t \*attr*, *int pshared*);

## DESCRIPTION

Condition attribute objects are used to specify parameters to **pthread\_cond\_init**().

The **pthread\_condattr\_init**() function initializes a condition attribute object with the default attributes.

The **pthread\_condattr\_destroy**() function destroys a condition attribute object.

The **pthread\_condattr\_getclock**() function will put the value of the clock attribute from *attr* into the memory area pointed to by *clock\_id*. The **pthread\_condattr\_setclock**() function will set the clock attribute of *attr* to the value specified in *clock\_id*. The clock attribute affects the interpretation of *abstime* in [pthread\_cond\_timedwait(3)](/pthread_cond_timedwait/3.md) and may be set to CLOCK\_REALTIME (default), CLOCK\_TAI, or CLOCK\_MONOTONIC.

The **pthread\_condattr\_getpshared**() function will put the value of the process-shared attribute from *attr* into the memory area pointed to by *pshared*. The **pthread\_condattr\_setpshared**() function will set the process-shared attribute of *attr* to the value specified in *pshared*. The argument *pshared* may have one of the following values:

- PTHREAD\_PROCESS\_PRIVATE

  The condition variable it is attached to may only be accessed by threads in the same process as the one that created the object.

- PTHREAD\_PROCESS\_SHARED

  The condition variable it is attached to may be accessed by threads in processes other than the one that created the object.

See [libthr(3)](/libthr/3.md) for details of the implementation of shared condition variables, and their limitations.

## RETURN VALUES

If successful, these functions return 0. Otherwise, an error number is returned to indicate the error.

## ERRORS

The **pthread\_condattr\_init**() function will fail if:

- \[ENOMEM\]

  Out of memory.

The **pthread\_condattr\_destroy**() function will fail if:

- \[EINVAL\]

  Invalid value for *attr*.

The **pthread\_condattr\_setclock**() function will fail if:

- \[EINVAL\]

  The value specified in *clock\_id* is not one of the allowed values.

The **pthread\_condattr\_setpshared**() function will fail if:

- \[EINVAL\]

  The value specified in *pshared* is not one of the allowed values.

## SEE ALSO

[libthr(3)](/libthr/3.md), [pthread\_cond\_init(3)](/pthread_cond_init/3.md), [pthread\_cond\_timedwait(3)](/pthread_cond_timedwait/3.md)

## STANDARDS

The **pthread\_condattr\_init**() and **pthread\_condattr\_destroy**() functions conform to ISO/IEC 9945-1:1996 (“POSIX.1”)
