PTHREAD_RWLOCKATTR_SETKIND_NP(3)
β¨ NAME β¨
okay bestie, gather round π this is the manual page for pthread_rwlockattr_setkind_np, pthread_rwlockattr_getkind_np β and they're here to set/get the read-write lock kind of the thread read-write lock attribute object. that's it, that's the whole job. π
π LIBRARY π
POSIX threads library β libpthread, -lpthread. yeah you gotta link it, no cap. π
π©· SYNOPSIS π©·
#include <pthread.h>
int pthread_rwlockattr_setkind_np(pthread_rwlockattr_t *attr,
int pref);
int pthread_rwlockattr_getkind_np(
const pthread_rwlockattr_t *restrict attr,
int *restrict pref);
Feature Test Macro Requirements for glibc (see feature_test_macros(7)):
pthread_rwlockattr_setkind_np(), pthread_rwlockattr_getkind_np():
_XOPEN_SOURCE >= 500 || _POSIX_C_SOURCE >= 200809L
bestie listen π these macros are the bouncers at the club. no matching<italic>feature test macro</italic>, no entry, and the function literally doesn't exist for you. pls define them before you#includeanything.
πΈ DESCRIPTION πΈ
so pthread_rwlockattr_setkind_np() sets the "lock kind" attribute of the read-write lock attribute object referred to by attr to the value you put in pref. lowkey simple. β¨
the argument pref may be set to one of these three icons only π:
PTHREAD_RWLOCK_PREFER_READER_NPβ the default, the main character, the one you get if you say nothing π. a thread may hold multiple read locks; that is, read locks are recursive. according to The Single Unix Specification, the behavior is unspecified when a reader tries to place a lock, and there is no write lock but writers are waiting π¬. giving preference to the reader, as is set byPTHREAD_RWLOCK_PREFER_READER_NP, implies that the reader will receive the requested lock, even if a writer is waiting. as long as there are readers, the writer will be starved. yes, starved. that writer is in the group chat typing and nobody's reading π.PTHREAD_RWLOCK_PREFER_WRITER_NPβ this is intended as the write lock analog ofPTHREAD_RWLOCK_PREFER_READER_NP. and now the plot twist: this is ignored by glibc π because the POSIX requirement to support recursive read locks would cause this option to create trivial deadlocks. so instead usePTHREAD_RWLOCK_PREFER_WRITER_NONRECURSIVE_NP, which ensures the application developer will not take recursive read locks thus avoiding deadlocks. it's giving "we love you but we're not doing what you asked" fr fr.PTHREAD_RWLOCK_PREFER_WRITER_NONRECURSIVE_NPβ setting the lock kind to this avoids writer starvation as long as any read locking is not done in a recursive fashion. the one that actually eats. π₯
and pthread_rwlockattr_getkind_np() returns the value of the lock kind attribute of the read-write lock attribute object referred to by attr in the pointer pref. it reads it back and hands it to you, no drama. π«Ά
β RETURN VALUE β
on success, these functions return 0. iconic. periodt.
given valid pointer arguments, pthread_rwlockattr_getkind_np() always succeeds. it literally cannot fail on you, bestie, it's that reliable π§.
on error, pthread_rwlockattr_setkind_np() returns a nonzero error number. so like, check it, don't be out here ignoring return values, that's not the vibe. π
π ERRORS π
EINVALβ pref specifies an unsupported value. you made up a lock kind, girl. it is not real. it is not valid. go pick one of the three. π
π STANDARDS π
GNU. hence the suffix _np in the names β "(nonportable)". it's nonportable on purpose, that's its whole brand π
. don't expect this energy to travel.
π HISTORY π
glibc 2.1. ancient. historic. still here, still slaying. π
π¦ SEE ALSO π¦
and that's the whole page bestie!! πβ¨ this legendary lore comes to you from Linux man-pages 6.20, dated 2026-02-08 β the pthread_rw..._setkind_np(3) era ππ«Ά go forth and set your lock kinds responsibly, mwah π
π¦ where this page comes from
- arch rolling: man-pages 6.20-1 Β· BSD-2-Clause AND BSD-3-Clause AND BSD-4.3TAHOE AND BSD-4-Clause-UC AND GPL-1.0-or-later AND GPL-2.0-only AND GPL-2.0-or-later AND GPL-3.0-or-later AND LGPL-3.0-linking-exception AND LGPL-3.0-or-later AND LicenseRef-Public-Domain AND LicenseRef-UltraPermissive AND Linux-man-pages-1-para AND Linux-man-pages-copyleft AND Linux-man-pages-copyleft-2-para AND Linux-man-pages-copyleft-var AND MIT AND Spencer-94
- nixpkgs unstable: man-pages 6.20
- π the page's license: Linux-man-pages-copyleft
- Copyright 2010, Novell, Inc
- π girlified by deepseek-ai/DeepSeek-V4.1-Flash on : a language model's rewrite of the original, under its terms