This is the mail archive of the glibc-bugs@sourceware.org mailing list for the glibc project.


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]
Other format: [Raw text]

[Bug nptl/16160] New: __lll_robust_trylock is not been implemented correctly in some architecture


http://sourceware.org/bugzilla/show_bug.cgi?id=16160

            Bug ID: 16160
           Summary: __lll_robust_trylock is not been implemented correctly
                    in some architecture
           Product: glibc
           Version: 2.21
            Status: NEW
          Severity: normal
          Priority: P2
         Component: nptl
          Assignee: unassigned at sourceware dot org
          Reporter: wang.deqiang1 at zte dot com.cn
                CC: drepper.fsp at gmail dot com

there's code in __pthread_mutex_trylock:

    case PTHREAD_MUTEX_ROBUST_RECURSIVE_NP:
    case PTHREAD_MUTEX_ROBUST_ERRORCHECK_NP:
    case PTHREAD_MUTEX_ROBUST_NORMAL_NP:
    case PTHREAD_MUTEX_ROBUST_ADAPTIVE_NP:
..................
    oldval = lll_robust_trylock (mutex->__data.__lock, id);
    if (oldval != 0 && (oldval & FUTEX_OWNER_DIED) == 0)
    {
      THREAD_SETMEM (THREAD_SELF, robust_head.list_op_pending, NULL);

      return EBUSY;
    }
    lll_robust_trylock should return the old value of mutex->__data.__lock, if
the old value has FUTEX_OWNER_DIED bit set, then __pthread_mutex_trylock should
goto the beginning of loop to handle the situation that previous owner is
deadãnot just return EBUSY.
     x86 and powerpc have the right implementation. but some
architectures(ARMãMIPS.....) implement lll_robust_trylock like this:
/*return old value is 0 or not, not the value*/
static inline int __attribute__((always_inline))
__lll_robust_trylock(int *futex, int id)
{
  return atomic_compare_and_exchange_val_acq (futex, id, 0) != 0;
}
#define lll_robust_trylock(lock, id) \
    then __pthread_mutex_trylock will return EBUSY when previous owner died
just like the mutex is holded by other threadã

-- 
You are receiving this mail because:
You are on the CC list for the bug.

Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]