Back to index

glibc  2.9
Functions
pspinlock.c File Reference
#include <errno.h>
#include <pthread.h>
#include "internals.h"

Go to the source code of this file.

Functions

int __pthread_spin_lock (pthread_spinlock_t *lock)
 weak_alias (__pthread_spin_lock, pthread_spin_lock)
 weak_alias (__pthread_spin_trylock, pthread_spin_trylock)
 weak_alias (__pthread_spin_unlock, pthread_spin_unlock)
 weak_alias (__pthread_spin_init, pthread_spin_init)

Function Documentation

int __pthread_spin_lock ( pthread_spinlock_t *  lock)

Definition at line 25 of file pspinlock.c.

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

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

  return 0;
}

Definition at line 34 of file pspinlock.c.

{
  volatile unsigned int *a = __ldcw_align (lock);

  return __ldcw (a) ? 0 : EBUSY;
}

Definition at line 44 of file pspinlock.c.

{
  volatile unsigned int *a = __ldcw_align (lock);
  int tmp = 1;
  /* This should be a memory barrier to newer compilers */
  __asm__ __volatile__ ("stw,ma %1,0(%0)"
                        : : "r" (a), "r" (tmp) : "memory");           
  return 0;
}

Here is the call graph for this function:

Definition at line 57 of file pspinlock.c.

{
  /* We can ignore the `pshared' parameter.  Since we are busy-waiting
     all processes which can access the memory location `lock' points
     to can use the spinlock.  */
  volatile unsigned int *a = __ldcw_align (lock);
  int tmp = 1;
  /* This should be a memory barrier to newer compilers */
  __asm__ __volatile__ ("stw,ma %1,0(%0)"
                        : : "r" (a), "r" (tmp) : "memory");           
  return 0;
}

Here is the call graph for this function:

Definition at line 73 of file pspinlock.c.

{
  /* Nothing to do.  */
  return 0;
}