* [PATCH] Fix pthread_rwlock_{,timed}rdlock on arches other than i?86, x86_64 and sh
@ 2004-08-09 15:23 Jakub Jelinek
2004-08-13 5:34 ` Ulrich Drepper
0 siblings, 1 reply; 2+ messages in thread
From: Jakub Jelinek @ 2004-08-09 15:23 UTC (permalink / raw)
To: Ulrich Drepper, Roland McGrath; +Cc: Glibc hackers
Hi!
The .S sources are ok and decrement __nr_readers_queued after reacquiring
the lock. pthread_*wrlock in both .c and .S decrements __nr_writers_queued,
just this was apparently missing.
The consequence of this bug seems to be for a long time performance issue
(entering kernel on unlock if there are no readers nor writers waiting for
the lock) and after 2^32-1 pthread_rwlock_*rdlock calls on one lock also
a correctness issue (all following pthread_rwlock_*rdlock calls would
fail with EAGAIN).
2004-08-09 Jakub Jelinek <jakub@redhat.com>
* DESIGN-rwlock.txt: Add decreasing of nr_readers_queued to
pthread_rwlock_rdlock.
* sysdeps/pthread/pthread_rwlock_rdlock (__pthread_rwlock_rdlock):
Decrease __nr_readers_queued after reacquiring lock.
* sysdeps/pthread/pthread_rwlock_timedrdlock
(pthread_rwlock_timedrdlock): Likewise.
Reported by Bob Cook <bobcook47@hotmail.com>.
--- libc/nptl/DESIGN-rwlock.txt.jj 2003-02-27 11:29:02.000000000 +0100
+++ libc/nptl/DESIGN-rwlock.txt 2004-08-09 16:50:00.433166066 +0200
@@ -48,6 +48,7 @@ pthread_rwlock_rdlock(pthread_rwlock_t *
futex_wait(&rwlock->readers_wakeup, val)
lll_lock(rwlock->lock);
+ rwlock->nr_readers_queued--;
}
rwlock->readers++;
lll_unlock(rwlock->lock);
--- libc/nptl/sysdeps/pthread/pthread_rwlock_timedrdlock.c.jj 2004-07-12 17:50:23.000000000 +0200
+++ libc/nptl/sysdeps/pthread/pthread_rwlock_timedrdlock.c 2004-08-09 16:56:14.542720134 +0200
@@ -119,6 +119,8 @@ pthread_rwlock_timedrdlock (rwlock, abst
/* Get the lock. */
lll_mutex_lock (rwlock->__data.__lock);
+ --rwlock->__data.__nr_readers_queued;
+
/* Did the futex call time out? */
if (err == -ETIMEDOUT)
{
--- libc/nptl/sysdeps/pthread/pthread_rwlock_rdlock.c.jj 2003-06-05 21:31:15.000000000 +0200
+++ libc/nptl/sysdeps/pthread/pthread_rwlock_rdlock.c 2004-08-09 16:55:43.543141419 +0200
@@ -1,4 +1,4 @@
-/* Copyright (C) 2003 Free Software Foundation, Inc.
+/* Copyright (C) 2003, 2004 Free Software Foundation, Inc.
This file is part of the GNU C Library.
Contributed by Martin Schwidefsky <schwidefsky@de.ibm.com>, 2003.
@@ -81,6 +81,8 @@ __pthread_rwlock_rdlock (rwlock)
/* Get the lock. */
lll_mutex_lock (rwlock->__data.__lock);
+
+ --rwlock->__data.__nr_readers_queued;
}
/* We are done, free the lock. */
Jakub
^ permalink raw reply [flat|nested] 2+ messages in thread
* Re: [PATCH] Fix pthread_rwlock_{,timed}rdlock on arches other than i?86, x86_64 and sh
2004-08-09 15:23 [PATCH] Fix pthread_rwlock_{,timed}rdlock on arches other than i?86, x86_64 and sh Jakub Jelinek
@ 2004-08-13 5:34 ` Ulrich Drepper
0 siblings, 0 replies; 2+ messages in thread
From: Ulrich Drepper @ 2004-08-13 5:34 UTC (permalink / raw)
To: Jakub Jelinek; +Cc: Roland McGrath, Glibc hackers
Applied.
--
⧠Ulrich Drepper ⧠Red Hat, Inc. ⧠444 Castro St ⧠Mountain View, CA â
^ permalink raw reply [flat|nested] 2+ messages in thread
end of thread, other threads:[~2004-08-13 5:34 UTC | newest]
Thread overview: 2+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2004-08-09 15:23 [PATCH] Fix pthread_rwlock_{,timed}rdlock on arches other than i?86, x86_64 and sh Jakub Jelinek
2004-08-13 5:34 ` Ulrich Drepper
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).