int
pthread_barrier_wait (pthread_barrier_t *barrier)
{
- __pthread_spin_lock (&barrier->__lock);
+ __pthread_spin_wait (&barrier->__lock);
if (--barrier->__pending == 0)
{
barrier->__pending = barrier->__count;
{
struct __pthread *wakeup;
- __pthread_spin_lock (&cond->__lock);
+ __pthread_spin_wait (&cond->__lock);
while ((wakeup = cond->__queue))
{
__pthread_dequeue (wakeup);
/* Wake it up without spin held, so it may have a chance to really
preempt us */
__pthread_wakeup (wakeup);
- __pthread_spin_lock (&cond->__lock);
+ __pthread_spin_wait (&cond->__lock);
}
__pthread_spin_unlock (&cond->__lock);
{
int ret = 0;
- __pthread_spin_lock (&cond->__lock);
+ __pthread_spin_wait (&cond->__lock);
if (cond->__queue)
ret = EBUSY;
__pthread_spin_unlock (&cond->__lock);
{
struct __pthread *wakeup;
- __pthread_spin_lock (&cond->__lock);
+ __pthread_spin_wait (&cond->__lock);
wakeup = cond->__queue;
if (wakeup != NULL)
__pthread_dequeue (wakeup);
pthread_cond_t *cond = ctx->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 = wakeup->prevp != NULL;
the cancellation hook to simplify the cancellation procedure, i.e.
if the thread is queued, it can be cancelled, otherwise it is
already unblocked, progressing on the return path. */
- __pthread_spin_lock (&cond->__lock);
+ __pthread_spin_wait (&cond->__lock);
__pthread_enqueue (&cond->__queue, self);
if (cond->__attr != NULL)
clock_id = cond->__attr->__clock;
__pthread_block (self);
}
- __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
atomic_full_barrier ();
if (once_control->__run == 0)
{
- __pthread_spin_lock (&once_control->__lock);
+ __pthread_spin_wait (&once_control->__lock);
if (once_control->__run == 0)
{
int drain;
struct __pthread *self;
- __pthread_spin_lock (&rwlock->__lock);
+ __pthread_spin_wait (&rwlock->__lock);
if (__pthread_spin_trylock (&rwlock->__held) == 0)
/* Successfully acquired the lock. */
{
__pthread_block (self);
}
- __pthread_spin_lock (&rwlock->__lock);
+ __pthread_spin_wait (&rwlock->__lock);
if (self->prevp == NULL)
/* Another thread removed us from the queue, which means a wakeup message
has been sent. It was either consumed while we were blocking, or
int drain;
struct __pthread *self;
- __pthread_spin_lock (&rwlock->__lock);
+ __pthread_spin_wait (&rwlock->__lock);
if (__pthread_spin_trylock (&rwlock->__held) == 0)
/* Successfully acquired the lock. */
{
__pthread_block (self);
}
- __pthread_spin_lock (&rwlock->__lock);
+ __pthread_spin_wait (&rwlock->__lock);
if (self->prevp == NULL)
/* Another thread removed us from the queue, which means a wakeup message
has been sent. It was either consumed while we were blocking, or
int
pthread_rwlock_tryrdlock (struct __pthread_rwlock *rwlock)
{
- __pthread_spin_lock (&rwlock->__lock);
+ __pthread_spin_wait (&rwlock->__lock);
if (__pthread_spin_trylock (&rwlock->__held) == 0)
/* Successfully acquired the lock. */
{
int
pthread_rwlock_trywrlock (struct __pthread_rwlock *rwlock)
{
- __pthread_spin_lock (&rwlock->__lock);
+ __pthread_spin_wait (&rwlock->__lock);
if (__pthread_spin_trylock (&rwlock->__held) == 0)
/* Successfully acquired the lock. */
{
{
struct __pthread *wakeup;
- __pthread_spin_lock (&rwlock->__lock);
+ __pthread_spin_wait (&rwlock->__lock);
assert (__pthread_spin_trylock (&rwlock->__held) == EBUSY);
int
__sem_getvalue (sem_t *restrict sem, int *restrict value)
{
- __pthread_spin_lock (&sem->__lock);
+ __pthread_spin_wait (&sem->__lock);
*value = sem->__value;
__pthread_spin_unlock (&sem->__lock);
{
struct __pthread *wakeup;
- __pthread_spin_lock (&sem->__lock);
+ __pthread_spin_wait (&sem->__lock);
if (sem->__value > 0)
/* Do a quick up. */
{
struct __pthread *self;
clockid_t clock_id = CLOCK_REALTIME;
- __pthread_spin_lock (&sem->__lock);
+ __pthread_spin_wait (&sem->__lock);
if (sem->__value > 0)
/* Successful down. */
{
else
err = __pthread_block_intr (self);
- __pthread_spin_lock (&sem->__lock);
+ __pthread_spin_wait (&sem->__lock);
if (self->prevp == NULL)
/* Another thread removed us from the queue, which means a wakeup message
has been sent. It was either consumed while we were blocking, or
int
__sem_trywait (sem_t *sem)
{
- __pthread_spin_lock (&sem->__lock);
+ __pthread_spin_wait (&sem->__lock);
if (sem->__value > 0)
/* Successful down. */
{
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
{
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;
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. */
/* 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