Back to index

glibc  2.9
Defines | Functions
lowlevellock.h File Reference
#include <atomic.h>
This graph shows which files directly or indirectly include this file:

Go to the source code of this file.


#define lll_mutex_lock(futex)   __generic_mutex_lock (&(futex))
#define lll_mutex_unlock(futex)   __generic_mutex_unlock (&(futex))


static void __generic_mutex_lock (int *mutex)
static void __generic_mutex_unlock (int *mutex)

Define Documentation

#define lll_mutex_lock (   futex)    __generic_mutex_lock (&(futex))

Definition at line 83 of file lowlevellock.h.

#define lll_mutex_unlock (   futex)    __generic_mutex_unlock (&(futex))

Definition at line 84 of file lowlevellock.h.

Function Documentation

static void __generic_mutex_lock ( int mutex) [inline, static]

Definition at line 35 of file lowlevellock.h.

  unsigned int v;

  /* Bit 31 was clear, we got the mutex.  (this is the fastpath).  */
  if (atomic_bit_test_set (mutex, 31) == 0)

  atomic_increment (mutex);

  while (1)
      if (atomic_bit_test_set (mutex, 31) == 0)
         atomic_decrement (mutex);

      /* We have to wait now. First make sure the futex value we are
        monitoring is truly negative (i.e. locked). */
      v = *mutex;
      if (v >= 0)

      lll_futex_wait (mutex, v,
                    // XYZ check mutex flag
static void __generic_mutex_unlock ( int mutex) [inline, static]

Definition at line 67 of file lowlevellock.h.

  /* Adding 0x80000000 to the counter results in 0 if and only if
     there are not other interested threads - we can return (this is
     the fastpath).  */
  if (atomic_add_zero (mutex, 0x80000000))

  /* There are other threads waiting for this mutex, wake one of them
     up.  */
  lll_futex_wake (mutex, 1,
                // XYZ check mutex flag