PTHREAD_RWLOCK_UNLOCK(3)

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

πŸ’… 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 by lock is 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 🌈


🧚 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