PTHREAD_BARRIERATTR(3)

πŸ“¦ version 15.1, in freebsd 14.5, freebsd 15.1, nixpkgs unstable

πŸ’… PTHREAD_BARRIERATTR(3) πŸ’…

okay bestie, this page comes from the Library Functions Manual, and it’s all about the barrier attribute besties. 🫢

🌸 NAME 🌸

pthread_barrierattr_destroy, pthread_barrierattr_getpshared, pthread_barrierattr_init, and pthread_barrierattr_setpshared β€” together these functions manipulate a barrier attribute object. periodt. πŸ’–

🫢 LIBRARY 🫢

POSIX Threads Library β€” that’s libpthread, -lpthread, no cap. ✨

✨ 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 πŸ’–

pthread_barrierattr_init() is the glow-up moment: it will initialize attr with default attributes. πŸŽ€

pthread_barrierattr_destroy() is the cleanup queen: it will destroy attr and release any resources that may have been allocated on its behalf. 🧚

pthread_barrierattr_getpshared() will put the value of the process-shared attribute from attr into the memory area pointed to by pshared. pthread_barrierattr_setpshared() will set the process-shared attribute of attr to the value specified in pshared. πŸ”₯

The argument pshared may have one of these values, and that’s literally the list:

  • 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. not me checking that twice, but there it is. πŸ’€

πŸ’€ 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 πŸ¦‹

πŸ‘‘ HISTORY πŸ‘‘

The pthread_barrierattr_*() functions first appeared in N:M Threading Library (libkse, -lkse) in FreeBSD 5.2, and in 1:1 Threading Library (libthr, -lthr) in FreeBSD 5.3. Support for process-shared barriers appeared in FreeBSD 11.0. iconic lore, honestly. 🌟


β€” xoxo, your Debian bestie πŸ’– August 17, 2018 Β· PTHREAD_BARRIERATTR(3) Β· mwah πŸ’…

πŸ“¦ where this page comes from