PTHREAD_RWLOCK_TIMEDRDLOCK(3)
π NAME
okay so this is the pthread_rwlock_timedrdlock(3) page from the Library Functions Manual, and itβs literally all about acquiring a read-write lock for reading β or giving up after a specified period. bestie, the timeout is the whole vibe here. β¨
π LIBRARY
POSIX Threads Library (libpthread, -lpthread). slay. π
πΈ SYNOPSIS
#include <pthread.h>
int
pthread_rwlock_timedrdlock(pthread_rwlock_t *restrict rwlock,
const struct timespec *restrict abs_timeout);
π¦ DESCRIPTION
So this function acquires a read lock on the read-write lock rwlock. iconic behavior. but hereβs the timed part: if the lock cannot be acquired without waiting for another thread to unlock the lock, this wait shall be terminated when abs_timeout expires. β°
A thread may hold multiple concurrent read locks. and listen β pthread_rwlock_unlock(3) must be called once for each lock acquired. no skipping, bestie. π«Ά
If the thread should be interrupted by a signal, the pthread_rwlock_timedrdlock() function will be automatically restarted after the thread returns from the signal handler. yes, it comes back. π
β οΈ okay important: the calling thread may deadlock if at the time the call is made it holds a write lock on rwlock. also, the results are undefined if this function is called with an uninitialized read-write lock. so please initialize your locks, i am begging. π
π IMPLEMENTATION NOTES
To prevent writer starvation, writers are favored over readers. periodt. writers get the priority here. π₯
π RETURN VALUES
If successful, the pthread_rwlock_timedrdlock() function will return zero. otherwise, an error number will be returned to indicate the error. π«
This function shall not return an error code of EINTR. not me being clear about it. π
π ERRORS
The pthread_rwlock_timedrdlock() function will fail if:
[ETIMEDOUT]β The lock could not be acquired before the specified timeout expired. too slow, timeβs up. β³
The pthread_rwlock_timedrdlock() function may fail if:
[EAGAIN]β The read lock could not be acquired because the maximum number of read locks forrwlockwould be exceeded. bestie, thatβs the cap. π[EDEADLK]β The calling thread already holds a write lock onrwlock. uh oh. π[EINVAL]β The value specified byrwlockdoes not refer to an initialized read-write lock object, or theabs_timeoutnanosecond value is less than zero or greater than or equal to 1 billion. check ur values, babes. β
π₯ SEE ALSO
pthread_rwlock_init(3), pthread_rwlock_timedwrlock(3), pthread_rwlock_unlock(3)
π STANDARDS
The pthread_rwlock_timedrdlock() function is expected to conform to ISO/IEC 9945-1:1996 (βPOSIX.1β). π
β HISTORY
The pthread_rwlock_timedrdlock() function first appeared in FreeBSD 5.2. a whole era. π¦
okay thatβs the whole page bestie π this oneβs from Debian, dated August 17, 2018, and the manual is PTHREAD_RWLOCK_TIMEDRDLOCK(3) β mwah π
π¦ where this page comes from
- freebsd 14.5: base 14.5
- freebsd 15.1: base 15.1
- nixpkgs unstable: source
- Copyright (c) 2004 Michael Telahun Makonnen
- π girlified by deepseek-ai/DeepSeek-V4.1-Flash-1017 on : a language model's rewrite of the original, under its terms