PTHREAD_M...IOCEILING(3P)

πŸ’… PTHREAD_M...IOCEILING(3P) β€” POSIX Programmer's Manual πŸ’…

okay bestie, come sit with me, we're reading a whole POSIX page together and honestly? it's giving ✨niche but important✨. this is pthread_mutexattr_getprioceiling and pthread_mutexattr_setprioceiling, from the POSIX Programmer's Manual. πŸŽ€


🌸 PROLOG 🌸

so like, real talk first: this page is part of the POSIX Programmer's Manual. the Linux implementation of this interface may differ (so if you're on Linux, go peek at the matching Linux man page for the actual tea β˜•), or the interface might not even be implemented on Linux at all. no cap. πŸ’€


πŸ¦‹ NAME πŸ¦‹

pthread_mutexattr_getprioceiling, pthread_mutexattr_setprioceiling β€” get and set the prioceiling attribute of the mutex attributes object (REALTIME THREADS). yes she's a realtime girlie πŸ‘‘


⭐ SYNOPSIS ⭐

#include <pthread.h>

int pthread_mutexattr_getprioceiling(const pthread_mutexattr_t
    *restrict attr, int *restrict prioceiling);
int pthread_mutexattr_setprioceiling(pthread_mutexattr_t *attr,
    int prioceiling);

πŸ’– DESCRIPTION πŸ’–

so the way this works: pthread_mutexattr_getprioceiling() and pthread_mutexattr_setprioceiling() shall, respectively, get and set the priority ceiling attribute of a mutex attributes object pointed to by attr β€” and that object was previously created by pthread_mutexattr_init(). that's the origin story, periodt.

the prioceiling attribute holds the priority ceiling of initialized mutexes. the values of prioceiling are within the maximum range of priorities defined by SCHED_FIFO. 🫢

and what does the prioceiling attribute actually mean? it defines the priority ceiling of initialized mutexes, which is the minimum priority level at which the critical section guarded by the mutex is executed. so to avoid priority inversion (the villain of this whole saga 😭), the priority ceiling of the mutex shall be set to a priority higher than or equal to the highest priority of all the threads that may lock that mutex. and again β€” the values of prioceiling are within the maximum range of priorities defined under the SCHED_FIFO scheduling policy.

⚠️ now the scary part, bestie: the behavior is undefined if the value specified by the attr argument to pthread_mutexattr_getprioceiling() or pthread_mutexattr_setprioceiling() does not refer to an initialized mutex attributes object. so like… init it first. fr fr. πŸ’…

🌈 RETURN VALUE 🌈

upon successful completion, both pthread_mutexattr_getprioceiling() and pthread_mutexattr_setprioceiling() shall return zero. otherwise, an error number shall be returned to indicate the error. iconic behavior, zero means slay, anything else means we have a situation 🚨


πŸ”₯ ERRORS πŸ”₯

these functions may fail if:

  • EINVAL β€” the value specified by prioceiling is invalid.
  • EPERM β€” the caller does not have the privilege to perform the operation. (no permission, no party πŸ™ˆ)

and listen β€” these functions shall not return an error code of [EINTR]. noted. ⭐

the following sections are informative.


πŸ“ EXAMPLES πŸ“

None. β€” yeah she said what she said. nothing here bestie, moving on πŸ’€


🧚 APPLICATION USAGE 🧚

None. β€” also nothing. two for two. 😭


πŸ’œ RATIONALE πŸ’œ

so the reasoning is: if an implementation detects that the value specified by the attr argument to pthread_mutexattr_getprioceiling() or pthread_mutexattr_setprioceiling() does not refer to an initialized mutex attributes object, it is recommended that the function should fail and report an [EINVAL] error. see? told you to init it. πŸ’…


πŸ‘‘ FUTURE DIRECTIONS πŸ‘‘

None. β€” the future is… empty of changes here. that's the vibe. 🌸


✨ SEE ALSO ✨

  • pthread_cond_destroy()
  • pthread_create()
  • pthread_mutex_destroy()

The Base Definitions volume of POSIX.1‐2017, <pthread.h>


Portions of this text are reprinted and reproduced in electronic form from IEEE Std 1003.1-2017, Standard for Information Technology -- Portable Operating System Interface (POSIX), The Open Group Base Specifications Issue 7, 2018 Edition, Copyright (C) 2018 by the Institute of Electrical and Electronics Engineers, Inc and The Open Group. In the event of any discrepancy between this version and the original IEEE and The Open Group Standard, the original IEEE and The Open Group Standard is the referee document. The original Standard can be obtained online at http://www.opengroup.org/unix/online.html .

Any typographical or formatting errors that appear in this page are most likely to have been introduced during the conversion of the source files to man page format. To report such errors, see https://www.kernel.org/doc/man-pages/reporting_bugs.html .


okay that's the whole page, you ate it, I'm so proud of you 🫢✨ this was brought to you by IEEE/The Open Group, 2017 β€” now go set your prioceiling responsibly, bestie πŸ’–

πŸ“¦ where this page comes from