diff options
Diffstat (limited to 'nptl/sysdeps/pthread')
-rw-r--r-- | nptl/sysdeps/pthread/pthread_rwlock_rdlock.c | 8 | ||||
-rw-r--r-- | nptl/sysdeps/pthread/pthread_rwlock_timedrdlock.c | 9 | ||||
-rw-r--r-- | nptl/sysdeps/pthread/pthread_rwlock_timedwrlock.c | 6 | ||||
-rw-r--r-- | nptl/sysdeps/pthread/pthread_rwlock_unlock.c | 4 | ||||
-rw-r--r-- | nptl/sysdeps/pthread/pthread_rwlock_wrlock.c | 5 |
5 files changed, 16 insertions, 16 deletions
diff --git a/nptl/sysdeps/pthread/pthread_rwlock_rdlock.c b/nptl/sysdeps/pthread/pthread_rwlock_rdlock.c index b556ccfd1c..197af9c970 100644 --- a/nptl/sysdeps/pthread/pthread_rwlock_rdlock.c +++ b/nptl/sysdeps/pthread/pthread_rwlock_rdlock.c @@ -72,18 +72,16 @@ __pthread_rwlock_rdlock (rwlock) break; } + int waitval = rwlock->__data.__readers_wakeup; + /* Free the lock. */ lll_mutex_unlock (rwlock->__data.__lock); /* Wait for the writer to finish. */ - lll_futex_wait (&rwlock->__data.__readers_wakeup, 0); + lll_futex_wait (&rwlock->__data.__readers_wakeup, waitval); /* Get the lock. */ lll_mutex_lock (rwlock->__data.__lock); - - /* To start over again, remove the thread from the reader list. */ - if (--rwlock->__data.__nr_readers_queued == 0) - rwlock->__data.__readers_wakeup = 0; } /* We are done, free the lock. */ diff --git a/nptl/sysdeps/pthread/pthread_rwlock_timedrdlock.c b/nptl/sysdeps/pthread/pthread_rwlock_timedrdlock.c index 4f7b78dfd2..fb6382544e 100644 --- a/nptl/sysdeps/pthread/pthread_rwlock_timedrdlock.c +++ b/nptl/sysdeps/pthread/pthread_rwlock_timedrdlock.c @@ -105,19 +105,18 @@ pthread_rwlock_timedrdlock (rwlock, abstime) break; } + int waitval = rwlock->__data.__readers_wakeup; + /* Free the lock. */ lll_mutex_unlock (rwlock->__data.__lock); /* Wait for the writer to finish. */ - result = lll_futex_timed_wait (&rwlock->__data.__readers_wakeup, 0, &rt); + result = lll_futex_timed_wait (&rwlock->__data.__readers_wakeup, + waitval, &rt); /* Get the lock. */ lll_mutex_lock (rwlock->__data.__lock); - /* To start over again, remove the thread from the reader list. */ - if (--rwlock->__data.__nr_readers_queued == 0) - rwlock->__data.__readers_wakeup = 0; - /* Did the futex call time out? */ if (result == -ETIMEDOUT) { diff --git a/nptl/sysdeps/pthread/pthread_rwlock_timedwrlock.c b/nptl/sysdeps/pthread/pthread_rwlock_timedwrlock.c index 4c0dc38348..0715f835af 100644 --- a/nptl/sysdeps/pthread/pthread_rwlock_timedwrlock.c +++ b/nptl/sysdeps/pthread/pthread_rwlock_timedwrlock.c @@ -95,18 +95,20 @@ pthread_rwlock_timedwrlock (rwlock, abstime) break; } + int waitval = rwlock->__data.__writer_wakeup; + /* Free the lock. */ lll_mutex_unlock (rwlock->__data.__lock); /* Wait for the writer or reader(s) to finish. */ - result = lll_futex_timed_wait (&rwlock->__data.__writer_wakeup, 0, &rt); + result = lll_futex_timed_wait (&rwlock->__data.__writer_wakeup, + waitval, &rt); /* Get the lock. */ lll_mutex_lock (rwlock->__data.__lock); /* To start over again, remove the thread from the writer list. */ --rwlock->__data.__nr_writers_queued; - rwlock->__data.__writer_wakeup = 0; /* Did the futex call time out? */ if (result == -ETIMEDOUT) diff --git a/nptl/sysdeps/pthread/pthread_rwlock_unlock.c b/nptl/sysdeps/pthread/pthread_rwlock_unlock.c index 325007e5b3..6e0c92ba3f 100644 --- a/nptl/sysdeps/pthread/pthread_rwlock_unlock.c +++ b/nptl/sysdeps/pthread/pthread_rwlock_unlock.c @@ -35,12 +35,12 @@ int __pthread_rwlock_unlock (pthread_rwlock_t *rwlock) { if (rwlock->__data.__nr_writers_queued) { - rwlock->__data.__writer_wakeup = 1; + ++rwlock->__data.__writer_wakeup; lll_futex_wake(&rwlock->__data.__writer_wakeup, 1); } else { - rwlock->__data.__readers_wakeup = 1; + ++rwlock->__data.__readers_wakeup; lll_futex_wake(&rwlock->__data.__readers_wakeup, INT_MAX); } } diff --git a/nptl/sysdeps/pthread/pthread_rwlock_wrlock.c b/nptl/sysdeps/pthread/pthread_rwlock_wrlock.c index 024b6711a9..03c37a1933 100644 --- a/nptl/sysdeps/pthread/pthread_rwlock_wrlock.c +++ b/nptl/sysdeps/pthread/pthread_rwlock_wrlock.c @@ -63,18 +63,19 @@ __pthread_rwlock_wrlock (rwlock) break; } + int waitval = rwlock->__data.__writer_wakeup; + /* Free the lock. */ lll_mutex_unlock (rwlock->__data.__lock); /* Wait for the writer or reader(s) to finish. */ - lll_futex_wait (&rwlock->__data.__writer_wakeup, 0); + lll_futex_wait (&rwlock->__data.__writer_wakeup, waitval); /* Get the lock. */ lll_mutex_lock (rwlock->__data.__lock); /* To start over again, remove the thread from the writer list. */ --rwlock->__data.__nr_writers_queued; - rwlock->__data.__writer_wakeup = 0; } /* We are done, free the lock. */ |