pthread_condattr(3)

pthread_condattr3

Condition attribute operations

Usage

#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);

Library

POSIX Threads Library (libpthread, -lpthread)

Overview

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) 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) 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.

Releases

69 releases since FreeBSD 4.1-RELEASE; the text changed 43 times.

  1. 4.1–4.2
  2. 4.3
  3. 4.4
  4. 4.5–4.11
  5. 5.0
  6. 5.1
  7. 5.2–5.2.1
  8. 5.3–6.3
  9. 6.4
  10. 7.0
  11. 7.1
  12. 7.2
  13. 7.3
  14. 7.4
  15. 8.0
  16. 8.1
  17. 8.2
  18. 8.3
  19. 8.4
  20. 9.0
  21. 9.1
  22. 9.2
  23. 9.3
  24. 10.0
  25. 10.1
  26. 10.2
  27. 10.3
  28. 10.4
  29. 11.0
  30. 11.1
  31. 11.2
  32. 11.3
  33. 11.4
  34. 12.0
  35. 12.1
  36. 12.2
  37. 12.3
  38. 12.4
  39. 13.0
  40. 13.1–13.2
  41. 13.3–13.5
  42. 14.0
  43. 14.1–14.5
  44. 15.0–16.0

Standards

The pthread_condattr_init() and pthread_condattr_destroy() functions conform to ISO/IEC 9945-1:1996 (“POSIX.1”)

From base 16.0-CURRENT-20261027-61c70dc16a79 in FreeBSD 16.0-CURRENT (2026-10-27). Parsed by carta from the page's mdoc source.