PTHREAD...CEILING(3POSIX)
π PTHREAD...CEILING β the POSIX girlies' guide to mutex priority ceilings β¨
okay so bestie, before we even get into it: this page lives in the POSIX Programmer's Manual, okay? like, it's the POSIX manual. and real talk β the Linux implementation of this interface may differ, so pls go check the corresponding Linux manual page for the actual Linux tea π«. or honestly the interface might not even be implemented on Linux at all. no cap. so vibe check first, always.
β¨ NAME β¨
pthread_mutex_getprioceiling, pthread_mutex_setprioceiling β get and set the priority ceiling of a mutex (and yes this is a REALTIME THREADS situation, we're in our realtime era π)
π SYNOPSIS π
#include <pthread.h>
int pthread_mutex_getprioceiling(const pthread_mutex_t *restrict mutex,
int *restrict prioceiling);
int pthread_mutex_setprioceiling(pthread_mutex_t *restrict mutex,
int prioceiling, int *restrict old_ceiling);
π¦ DESCRIPTION π¦
so pthread_mutex_getprioceiling() is the lil reader β it shall return the current priority ceiling of the mutex. that's it, that's the whole job, she's just peeking π.
now pthread_mutex_setprioceiling() is the main character here. she shall attempt to lock the mutex as if by a call to pthread_mutex_lock(), except β and this is the lil plot twist β the process of locking the mutex need not adhere to the priority protect protocol. like she's doing her own thing, respectfully.
once she's acquired the mutex, she shall change the mutex's priority ceiling and then release the mutex as if by a call to pthread_mutex_unlock(). so it's a lock β glow-up β unlock situation, iconic behavior honestly π
.
and when that change is successful? the previous value of the priority ceiling shall be returned in old_ceiling. so you get the receipts of what it used to be π§Ύ.
real talk though: if pthread_mutex_setprioceiling() fails, the mutex priority ceiling shall not be changed. nothing happens, we stay as we were, no chaos.
πΈ RETURN VALUE πΈ
if it works? both pthread_mutex_getprioceiling() and pthread_mutex_setprioceiling() shall return zero β slay π. otherwise, an error number shall be returned to indicate the error. so no silent failing bestie, she will tell you.
π₯ ERRORS π₯
these functions shall fail if:
EINVALβ the protocol attribute of mutex isPTHREAD_PRIO_NONE. she said no protocol, she said none, periodt.EPERMβ the implementation requires appropriate privileges to perform the operation and the caller does not have appropriate privileges. like sorry babe you don't have the clearance for this room π.
and the pthread_mutex_setprioceiling() function shall fail if:
EAGAINβ the mutex could not be acquired because the maximum number of recursive locks for mutex has been exceeded. too many locks, girl, we're at capacity π.EDEADLKβ the mutex type isPTHREAD_MUTEX_ERRORCHECKand the current thread already owns the mutex. you already have it!! you're holding it!! ma'am!!EINVALβ the mutex was created with the protocol attribute having the valuePTHREAD_PRIO_PROTECTand the calling thread's priority is higher than the mutex's current priority ceiling, and the implementation adheres to the priority protect protocol in the process of locking the mutex. so you're literally too powerful for this mutex, and the protocol is like "nope π".ENOTRECOVERABLEβ the mutex is a robust mutex and the state protected by the mutex is not recoverable. it's giving unsalvageable, we can't fix this one π.EOWNERDEADβ the mutex is a robust mutex and the process containing the previous owning thread terminated while holding the mutex lock. the mutex lock shall be acquired by the calling thread, and it's up to the new owner to make the state consistent (seepthread_mutex_lock()). so you inherited this mess, bestie, and now it's your responsibility to clean it up π«Ά.
the pthread_mutex_setprioceiling() function may fail if:
EDEADLKβ a deadlock condition was detected. yikes π¨.EINVALβ the priority requested by prioceiling is out of range. that number's not valid babe, put it back.EOWNERDEADβ the mutex is a robust mutex and the previous owning thread terminated while holding the mutex lock. the mutex lock shall be acquired by the calling thread and it's up to the new owner to make the state consistent (seepthread_mutex_lock()). yeah it's the same drama as above, she's listed twice, she's just that girl β¨.
also super important: these functions shall not return an error code of [EINTR]. not gonna happen, don't even ask.
and btw, everything from here down? the following sections are informative. so like, they're context, not the law π.
β EXAMPLES β
None. (we're keeping it mysterious, iykyk π)
π APPLICATION USAGE π
None. (no notes, perfect as she is π)
π RATIONALE π
None. (the reasoning is lost to time, we simply accept it β¨)
π§ FUTURE DIRECTIONS π§
None. (she stays exactly like this forever, no cap)
π SEE ALSO π
pthread_mutex_destroy()pthread_mutex_lock()pthread_mutex_timedlock()
and from The Base Definitions volume of POSIX.1β2017: <pthread.h> π¦
π COPYRIGHT π
okay so legally speaking, bestie, i have to tell you this exactly:
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 .
and that's the whole page, bestie π this one came from IEEE/The Open Group, dated 2017, and she answers to the name PTHREAD...CEILING(3POSIX). go forth and ceiling your mutexes responsibly, mwah π«Άβ¨
π¦ where this page comes from
- debian bookworm: manpages-posix-dev 2017a-2 Β· Other
- debian trixie: manpages-posix-dev 2017a-2 Β· Other
- ubuntu jammy: manpages-posix-dev 2017a-2 Β· Other
- ubuntu noble: manpages-posix-dev 2017a-2 Β· Other
- ubuntu resolute: manpages-posix-dev 2017a-2build1 Β· Other
- ubuntu stonking: manpages-posix-dev 2017a-2.1 Β· Other
- π girlified by deepseek-ai/DeepSeek-V4.1-Flash on : a language model's rewrite of the original, under its terms