1
/* Copyright (c) 1998, 1999, 2000 Thorsten Kukuk, Germany
3
This file is part of ypbind-mt.
5
Author: Thorsten Kukuk <kukuk@suse.de>
7
The ypbind-mt are free software; you can redistribute it and/or
8
modify it under the terms of the GNU General Public License version 2
9
as published by the Free Software Foundation.
11
ypbind-mt is distributed in the hope that it will be useful,
12
but WITHOUT ANY WARRANTY; without even the implied warranty of
13
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
14
General Public License for more details.
16
You should have received a copy of the GNU General Public
17
License along with ypbind-mt; see the file COPYING. If not,
18
write to the Free Software Foundation, Inc., 59 Temple Place - Suite 330,
19
Boston, MA 02111-1307, USA. */
22
#include <pthread_np.h>
25
pthread_rdwr_init_np (pthread_rdwr_t *rdwrp)
30
pthread_mutex_init (&(rdwrp->mutex), NULL);
31
pthread_cond_init (&(rdwrp->lock_free), NULL);
36
pthread_rdwr_rlock_np (pthread_rdwr_t *rdwrp)
38
pthread_mutex_lock (&(rdwrp->mutex));
40
while (rdwrp->writers || rdwrp->wishwrite)
41
pthread_cond_wait (&(rdwrp->lock_free), &(rdwrp->mutex));
44
pthread_mutex_unlock (&(rdwrp->mutex));
49
pthread_rdwr_wlock_np (pthread_rdwr_t *rdwrp)
51
pthread_mutex_lock (&(rdwrp->mutex));
53
while (rdwrp->writers || rdwrp->readers)
54
pthread_cond_wait (&(rdwrp->lock_free), &(rdwrp->mutex));
57
pthread_mutex_unlock (&(rdwrp->mutex));
62
pthread_rdwr_runlock_np (pthread_rdwr_t *rdwrp)
66
pthread_mutex_lock (&(rdwrp->mutex));
67
if (rdwrp->readers == 0)
74
if (rdwrp->readers == 0)
75
pthread_cond_signal (&(rdwrp->lock_free));
78
pthread_mutex_unlock (&rdwrp->mutex);
83
pthread_rdwr_wunlock_np (pthread_rdwr_t *rdwrp)
87
pthread_mutex_lock (&(rdwrp->mutex));
88
if (rdwrp->writers == 0)
95
pthread_cond_broadcast (&(rdwrp->lock_free));
98
pthread_mutex_unlock (&(rdwrp->mutex));