Go to the documentation of this file.
17 #ifndef PTHREAD_RWLOCK_H
18 #define PTHREAD_RWLOCK_H
bool is_writer
false: reader; true: writer
Internal structure that stores one waiting thread.
int pthread_rwlock_tryrdlock(pthread_rwlock_t *rwlock)
Try to lock a reader/writer lock for reader.
int pthread_rwlock_unlock(pthread_rwlock_t *rwlock)
Unlock the reader/writer lock.
int pthread_rwlock_timedrdlock(pthread_rwlock_t *rwlock, const struct timespec *abstime)
Try to acquire a read lock in a given timeframe.
int pthread_rwlock_rdlock(pthread_rwlock_t *rwlock)
Lock a reader/writer lock for reading.
priority_queue_t queue
Queue of waiting threads.
mutex_t mutex
Provides mutual exclusion on reading and writing on the structure.
int readers
The current amount of reader inside the critical section.
thread_t * thread
waiting thread
int pthread_rwlock_trywrlock(pthread_rwlock_t *rwlock)
Try to lock a reader/writer lock for writing.
thread_t holds thread's context data.
A fair reader writer lock.
Attributes for a new reader/writer lock.
bool __pthread_rwlock_blocked_readingly(const pthread_rwlock_t *rwlock)
Internal function to determine of the lock can be acquired for reading.
int pthread_rwlock_timedwrlock(pthread_rwlock_t *rwlock, const struct timespec *abstime)
Try to acquire a write lock in a given timeframe.
data type for priority queue nodes
int pthread_rwlock_init(pthread_rwlock_t *rwlock, const pthread_rwlockattr_t *attr)
Initialize a reader/writer lock.
bool continue_
This is not a spurious wakeup.
int pthread_rwlock_destroy(pthread_rwlock_t *rwlock)
Destroy a reader/writer lock.
data type for priority queues
bool __pthread_rwlock_blocked_writingly(const pthread_rwlock_t *rwlock)
Internal function to determine of the lock can be acquired for writing.
priority_queue_node_t qnode
Node to store in pthread_rwlock_t::queue.
int pthread_rwlock_wrlock(pthread_rwlock_t *rwlock)
Lock a reader/writer lock for writing.