From bee2df0bb966087d7f57d935a4234ffe30c76196 Mon Sep 17 00:00:00 2001 From: Ulrich Drepper Date: Wed, 30 Aug 2006 19:11:05 +0000 Subject: * pthread_rwlock_trywrlock.c (__pthread_rwlock_trywrlock): Respect reader preference. * sysdeps/pthread/pthread_rwlock_timedwrlock.c (pthread_rwlock_timedwrlock): Likewise. * sysdeps/pthread/pthread_rwlock_wrlock.c (__pthread_rwlock_wrlock): Likewise. --- nptl/sysdeps/pthread/pthread_rwlock_timedwrlock.c | 6 ++++-- nptl/sysdeps/pthread/pthread_rwlock_wrlock.c | 6 ++++-- 2 files changed, 8 insertions(+), 4 deletions(-) (limited to 'nptl/sysdeps/pthread') diff --git a/nptl/sysdeps/pthread/pthread_rwlock_timedwrlock.c b/nptl/sysdeps/pthread/pthread_rwlock_timedwrlock.c index 97c0598f96..ab7bc7babb 100644 --- a/nptl/sysdeps/pthread/pthread_rwlock_timedwrlock.c +++ b/nptl/sysdeps/pthread/pthread_rwlock_timedwrlock.c @@ -1,4 +1,4 @@ -/* Copyright (C) 2003, 2004 Free Software Foundation, Inc. +/* Copyright (C) 2003, 2004, 2006 Free Software Foundation, Inc. This file is part of the GNU C Library. Contributed by Martin Schwidefsky , 2003. @@ -40,7 +40,9 @@ pthread_rwlock_timedwrlock (rwlock, abstime) int err; /* Get the rwlock if there is no writer and no reader. */ - if (rwlock->__data.__writer == 0 && rwlock->__data.__nr_readers == 0) + if (rwlock->__data.__writer == 0 && rwlock->__data.__nr_readers == 0 + && (rwlock->__data.__flags != 0 + || rwlock->__data.__nr_readers_queued == 0)) { /* Mark self as writer. */ rwlock->__data.__writer = THREAD_GETMEM (THREAD_SELF, tid); diff --git a/nptl/sysdeps/pthread/pthread_rwlock_wrlock.c b/nptl/sysdeps/pthread/pthread_rwlock_wrlock.c index 822aeed79c..4d967f2496 100644 --- a/nptl/sysdeps/pthread/pthread_rwlock_wrlock.c +++ b/nptl/sysdeps/pthread/pthread_rwlock_wrlock.c @@ -1,4 +1,4 @@ -/* Copyright (C) 2003 Free Software Foundation, Inc. +/* Copyright (C) 2003, 2006 Free Software Foundation, Inc. This file is part of the GNU C Library. Contributed by Martin Schwidefsky , 2003. @@ -37,7 +37,9 @@ __pthread_rwlock_wrlock (rwlock) while (1) { /* Get the rwlock if there is no writer and no reader. */ - if (rwlock->__data.__writer == 0 && rwlock->__data.__nr_readers == 0) + if (rwlock->__data.__writer == 0 && rwlock->__data.__nr_readers == 0 + && (rwlock->__data.__flags != 0 + || rwlock->__data.__nr_readers_queued == 0)) { /* Mark self as writer. */ rwlock->__data.__writer = THREAD_GETMEM (THREAD_SELF, tid); -- cgit v1.2.3