Loading...
Searching...
No Matches
pthread_rwlock.h
Go to the documentation of this file.
1/*
2 * SPDX-FileCopyrightText: 2014 René Kijewski <rene.kijewski@fu-berlin.de>
3 * SPDX-License-Identifier: LGPL-2.1-only
4 */
5
6#pragma once
7
15
16#include "priority_queue.h"
17#include "thread.h"
18
19#include <errno.h>
20#include <stdbool.h>
21
22#ifdef __cplusplus
23extern "C" {
24#endif
25
54
64
74
87
96
106
115int pthread_rwlock_timedrdlock(pthread_rwlock_t *rwlock, const struct timespec *abstime);
116
125
135
144int pthread_rwlock_timedwrlock(pthread_rwlock_t *rwlock, const struct timespec *abstime);
145
156
163
170
171#ifdef __cplusplus
172}
173#endif
174
struct _thread thread_t
forward declaration for thread_t, defined in thread.h
Definition sched.h:156
A simple priority queue.
struct priority_queue_node priority_queue_node_t
data type for priority queue nodes
int pthread_rwlock_trywrlock(pthread_rwlock_t *rwlock)
Try to lock a reader/writer lock for writing.
int pthread_rwlock_init(pthread_rwlock_t *rwlock, const pthread_rwlockattr_t *attr)
Initialize a reader/writer lock.
int pthread_rwlock_timedwrlock(pthread_rwlock_t *rwlock, const struct timespec *abstime)
Try to acquire a write lock in a given timeframe.
int pthread_rwlock_wrlock(pthread_rwlock_t *rwlock)
Lock a reader/writer lock for writing.
int pthread_rwlock_destroy(pthread_rwlock_t *rwlock)
Destroy a reader/writer lock.
int pthread_rwlock_unlock(pthread_rwlock_t *rwlock)
Unlock the 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_tryrdlock(pthread_rwlock_t *rwlock)
Try to lock a reader/writer lock for reader.
bool __pthread_rwlock_blocked_writingly(const pthread_rwlock_t *rwlock)
Internal function to determine of the lock can be acquired for writing.
int pthread_rwlock_rdlock(pthread_rwlock_t *rwlock)
Lock a reader/writer lock for reading.
int pthread_rwlock_timedrdlock(pthread_rwlock_t *rwlock, const struct timespec *abstime)
Try to acquire a read lock in a given timeframe.
Internal structure that stores one waiting thread.
thread_t * thread
waiting thread
bool is_writer
false: reader; true: writer
priority_queue_node_t qnode
Node to store in pthread_rwlock_t::queue.
bool continue_
This is not a spurious wakeup.
Mutex structure.
Definition mutex.h:36
data type for priority queues
A fair reader writer lock.
int readers
The current amount of reader inside the critical section.
mutex_t mutex
Provides mutual exclusion on reading and writing on the structure.
priority_queue_t queue
Queue of waiting threads.
Attributes for a new reader/writer lock.