This is the mail archive of the libc-hacker@sources.redhat.com mailing list for the glibc project.
Note that libc-hacker is a closed list. You may look at the archives of this list, but subscription and posting are not open.
Index Nav: | [Date Index] [Subject Index] [Author Index] [Thread Index] | |
---|---|---|
Message Nav: | [Date Prev] [Date Next] | [Thread Prev] [Thread Next] |
Other format: | [Raw text] |
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
Index Nav: | [Date Index] [Subject Index] [Author Index] [Thread Index] | |
---|---|---|
Message Nav: | [Date Prev] [Date Next] | [Thread Prev] [Thread Next] |