diff options
author | Samuel Thibault <samuel.thibault@ens-lyon.org> | 2020-02-10 23:06:33 +0100 |
---|---|---|
committer | Samuel Thibault <samuel.thibault@ens-lyon.org> | 2020-02-11 00:32:44 +0100 |
commit | 8ba6ad703cb38ec57cdb473650ac289e5f8496d5 (patch) | |
tree | 843104571af29b6872721b6477d3b2e2444a3e96 /sysdeps/mach | |
parent | cd7965bd970b0a298e734acc9dafae0a5db5f712 (diff) | |
download | glibc-8ba6ad703cb38ec57cdb473650ac289e5f8496d5.tar glibc-8ba6ad703cb38ec57cdb473650ac289e5f8496d5.tar.gz glibc-8ba6ad703cb38ec57cdb473650ac289e5f8496d5.tar.bz2 glibc-8ba6ad703cb38ec57cdb473650ac289e5f8496d5.zip |
hurd: Add __pthread_spin_wait and use it
900778283ac3 ("htl: make pthread_spin_lock really spin") made
pthread_spin_lock really spin and not block, but the current users of
__pthread_spin_lock were assuming that it blocks, i.e. they use it as a
lightweight mutex fitting in just one int.
__pthread_spin_wait provides that support back.
Diffstat (limited to 'sysdeps/mach')
-rw-r--r-- | sysdeps/mach/htl/bits/spin-lock-inline.h | 9 | ||||
-rw-r--r-- | sysdeps/mach/hurd/htl/pt-hurd-cond-timedwait.c | 6 |
2 files changed, 12 insertions, 3 deletions
diff --git a/sysdeps/mach/htl/bits/spin-lock-inline.h b/sysdeps/mach/htl/bits/spin-lock-inline.h index 556bdd4c28..006b6fd5f2 100644 --- a/sysdeps/mach/htl/bits/spin-lock-inline.h +++ b/sysdeps/mach/htl/bits/spin-lock-inline.h @@ -71,6 +71,15 @@ __pthread_spin_lock (__pthread_spinlock_t *__lock) return 0; } +__PT_SPIN_INLINE int __pthread_spin_wait (__pthread_spinlock_t *__lock); + +__PT_SPIN_INLINE int +__pthread_spin_wait (__pthread_spinlock_t *__lock) +{ + __spin_lock ((__spin_lock_t *) __lock); + return 0; +} + __PT_SPIN_INLINE int __pthread_spin_unlock (__pthread_spinlock_t *__lock); __PT_SPIN_INLINE int diff --git a/sysdeps/mach/hurd/htl/pt-hurd-cond-timedwait.c b/sysdeps/mach/hurd/htl/pt-hurd-cond-timedwait.c index 12dd8634d4..939ed568ba 100644 --- a/sysdeps/mach/hurd/htl/pt-hurd-cond-timedwait.c +++ b/sysdeps/mach/hurd/htl/pt-hurd-cond-timedwait.c @@ -56,7 +56,7 @@ __pthread_hurd_cond_timedwait_internal (pthread_cond_t *cond, { int unblock; - __pthread_spin_lock (&cond->__lock); + __pthread_spin_wait (&cond->__lock); /* The thread only needs to be awaken if it's blocking or about to block. If it was already unblocked, it's not queued any more. */ unblock = self->prevp != NULL; @@ -81,7 +81,7 @@ __pthread_hurd_cond_timedwait_internal (pthread_cond_t *cond, the condition variable's lock. */ __spin_lock (&ss->lock); - __pthread_spin_lock (&cond->__lock); + __pthread_spin_wait (&cond->__lock); cancel = ss->cancel; if (cancel) /* We were cancelled before doing anything. Don't block at all. */ @@ -123,7 +123,7 @@ __pthread_hurd_cond_timedwait_internal (pthread_cond_t *cond, /* As it was done when enqueueing, prevent hurd_thread_cancel from suspending us while the condition lock is held. */ __spin_lock (&ss->lock); - __pthread_spin_lock (&cond->__lock); + __pthread_spin_wait (&cond->__lock); if (self->prevp == NULL) /* Another thread removed us from the list of waiters, which means a wakeup message has been sent. It was either consumed while |