Back to index

glibc  2.9
Functions
pthread_spin_lock.c File Reference
#include <atomic.h>
#include "pthreadP.h"

Go to the source code of this file.

Functions

int pthread_spin_lock (pthread_spinlock_t *lock)

Function Documentation

int pthread_spin_lock ( pthread_spinlock_t *  lock)

Definition at line 23 of file pthread_spin_lock.c.

{
#if 0
  volatile unsigned int *addr = __ldcw_align (lock);

  while (__ldcw (addr) == 0)
    while (*addr == 0) ;

  return 0;
#endif

  while (atomic_compare_and_exchange_val_acq(lock, 1, 0) == 1)
    while (*lock == 1);
  
  return 0;
}