blob: f39117e743ee75c20a420f8ecfec1d336adb8d42 (
plain) (
blame)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
|
#include "pthread_impl.h"
int pthread_rwlock_unlock(pthread_rwlock_t *rw)
{
struct pthread *self = pthread_self();
if (rw->__owner == self->tid) {
rw->__owner = 0;
a_store(&rw->__wrlock, 0);
if (rw->__waiters)
__wake(&rw->__wrlock, -1, 0);
return 0;
}
a_dec(&rw->__readers);
if (rw->__waiters && !rw->__readers)
__wake(&rw->__readers, 1, 0);
return 0;
}
|