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

# pthread\_barrierattr(3)

manipulate a barrier attribute object

## NAME

**pthread\_barrierattr\_destroy**, **pthread\_barrierattr\_getpshared**, **pthread\_barrierattr\_init**, **pthread\_barrierattr\_setpshared** – manipulate a barrier attribute object

## LIBRARY

POSIX Threads Library (libpthread, -lpthread)

## SYNOPSIS

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

*int*\

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

*int*\

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

*int*\

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

*int*\

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

## DESCRIPTION

The **pthread\_barrierattr\_init**() function will initialize *attr* with default attributes. The **pthread\_barrierattr\_destroy**() function will destroy *attr* and release any resources that may have been allocated on its behalf.

The **pthread\_barrierattr\_getpshared**() function will put the value of the process-shared attribute from *attr* into the memory area pointed to by *pshared*. The **pthread\_barrierattr\_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 barrier object 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 barrier object it is attached to may be accessed by threads in processes other than the one that created the object.

## RETURN VALUES

If successful, all these functions will return zero. Otherwise, an error number will be returned to indicate the error.

None of these functions will return EINTR.

## ERRORS

The **pthread\_barrierattr\_destroy**(), **pthread\_barrierattr\_getpshared**() and **pthread\_barrierattr\_setpshared**() functions may fail if:

- \[EINVAL\]

  The value specified by *attr* is invalid.

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

- \[ENOMEM\]

  Insufficient memory to initialize the barrier attribute object *attr*.

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

- \[EINVAL\]

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

## SEE ALSO

[pthread\_barrier\_destroy(3)](/pthread_barrier_destroy/3.md), [pthread\_barrier\_init(3)](/pthread_barrier_init/3.md), [pthread\_barrier\_wait(3)](/pthread_barrier_wait/3.md)

## HISTORY

The **pthread\_barrierattr\_\***() functions first appeared in library “libkse” in FreeBSD 5.2, and in library “libthr” in FreeBSD 5.3. Support for process-shared barriers appeared in FreeBSD 11.0.
