PTHREAD_RWLOCK_UNLOCK(3)
π PTHREAD_RWLOCK_UNLOCK(3) β like, the read/write lock release era π
Okay bestie, so this one's from the Library Functions Manual (POSIX threads girlies, stand up), and it's literally the "let it go" of the pthread world. Buckle in. β¨
πΈ NAME πΈ
pthread_rwlock_unlock β release a read/write lock. That's it, that's the whole vibe. You grabbed a lock, now you're putting it back. Iconic behavior. π
π¦ LIBRARY π¦
POSIX Threads Library, aka libpthread, aka -lpthread. Link her and she slays. π₯
β¨ SYNOPSIS β¨
#include <pthread.h>
int
pthread_rwlock_unlock(pthread_rwlock_t *lock);
Yes, that's the whole signature. Short. Sweet. Main character energy. π
π DESCRIPTION π
So, pthread_rwlock_unlock() is the function you call to release the read/write lock that you previously snagged with pthread_rwlock_rdlock(), pthread_rwlock_wrlock(), pthread_rwlock_tryrdlock(), or pthread_rwlock_trywrlock(). π«Ά
Like, no cap β it's the cleanup crew. You got the lock through any of those four paths, this is the one that hands it back. All four roads lead to the same unlock. Periodt. β
π RETURN VALUES π
If everything's gucci, pthread_rwlock_unlock() returns zero. π₯³
Otherwise, it'll hand you back an error number to let you know something went sideways. Not the vibe, but okay. π
β οΈ Okay so this part is important, bestie: the results are undefined if lock is not held by the calling thread. Like, undefined. As in, don't do it. Not a drill. π
π ERRORS π
pthread_rwlock_unlock() may fail if:
[EINVAL]β the value specified bylockis invalid. It's giving "that's not a real lock, girl." π[EPERM]β the current thread does not own the read/write lock. You're trying to unlock something that isn't yours. Not your lock, not your problem, and also an error. π€
π SEE ALSO π
pthread_rwlock_rdlock(3)β the read-lock bestiepthread_rwlock_wrlock(3)β the write-lock bestie
π§ STANDARDS π§
pthread_rwlock_unlock() is expected to conform to Version 2 of the Single UNIX Specification (that's βSUSv2β to the friends it doesn't have). Lowkey a legend. π
π HISTORY π
The pthread_rwlock_unlock() function first appeared in FreeBSD 3.0. Ancient in tech years, still serving. β
Alright, that's the whole page, bestie β go forth and unlock responsibly. π β¨
Signed, sealed, delivered: this little love letter lives in the Debian edition of the manual, dated August 4, 1998 β yes, she's a 90s baby and she ate. ππ₯
π¦ where this page comes from
- freebsd 14.5: base 14.5
- freebsd 15.1: base 15.1
- nixpkgs unstable: source
- Copyright (c) 1998 Alex Nash
- π girlified by deepseek-ai/DeepSeek-V4.1-Flash-1017 on : a language model's rewrite of the original, under its terms