diff options
author | Ulrich Drepper <drepper@redhat.com> | 2004-03-24 06:36:06 +0000 |
---|---|---|
committer | Ulrich Drepper <drepper@redhat.com> | 2004-03-24 06:36:06 +0000 |
commit | 2c0b891afe29dd28d0e6d75e0da8681db7fd100d (patch) | |
tree | 06fead8fc58acefbe9a9ebe353f0d596e73522ad /nptl/sysdeps/unix/sysv/linux/x86_64 | |
parent | 565699e492f741bc4563c73046f457924c6f708a (diff) | |
download | glibc-2c0b891afe29dd28d0e6d75e0da8681db7fd100d.tar glibc-2c0b891afe29dd28d0e6d75e0da8681db7fd100d.tar.gz glibc-2c0b891afe29dd28d0e6d75e0da8681db7fd100d.tar.bz2 glibc-2c0b891afe29dd28d0e6d75e0da8681db7fd100d.zip |
Update.
* sysdeps/unix/sysv/linux/smp.h: New file.
* sysdeps/unix/sysv/linux/sh/smp.h: New file.
* init.c: Define __is_smp.
(__pthread_initialize_minimal_internal): Call is_smp_system to
initialize __is_smp.
* pthreadP.h: Declare __is_smp.
Define MAX_ADAPTIVE_COUNT is necessary.
* pthread_mutex_init.c: Add comment regarding __spins field.
* pthread_mutex_lock.c: Implement adaptive mutex type.
* pthread_mutex_timedlock.c: Likewise.
* sysdeps/unix/sysv/linux/pthread_mutex_cond_lock.c: Likewise.
* sysdeps/unix/sysv/linux/alpha/bits/pthreadtypes.h (pthread_mutex_t):
Add __spins field.
* sysdeps/unix/sysv/linux/i386/bits/pthreadtypes.h: Likewise.
* sysdeps/unix/sysv/linux/ia64/bits/pthreadtypes.h: Likewise.
* sysdeps/unix/sysv/linux/powerpc/bits/pthreadtypes.h: Likewise.
* sysdeps/unix/sysv/linux/sh/bits/pthreadtypes.h: Likewise.
* sysdeps/unix/sysv/linux/s390/bits/pthreadtypes.h: Likewise.
* sysdeps/unix/sysv/linux/sparc/bits/pthreadtypes.h: Likewise.
* sysdeps/unix/sysv/linux/x86_64/bits/pthreadtypes.h: Likewise.
* sysdeps/unix/sysv/linux/alpha/bits/pthreadtypes.h: Define
lll_mutex_cond_trylock.
* sysdeps/unix/sysv/linux/powerpc/bits/pthreadtypes.h: Likewise.
* sysdeps/unix/sysv/linux/sh/bits/pthreadtypes.h: Likewise.
* sysdeps/unix/sysv/linux/s390/bits/pthreadtypes.h: Likewise.
* sysdeps/unix/sysv/linux/sparc/bits/pthreadtypes.h: Likewise.
* sysdeps/unix/sysv/linux/i386/bits/pthreadtypes.h: Likewise.
Define BUSY_WAIT_NOP.
* sysdeps/unix/sysv/linux/ia64/bits/pthreadtypes.h: Likewise.
* sysdeps/unix/sysv/linux/x86_64/bits/pthreadtypes.h: Likewise.
* tst-mutex5.c: Add support for testing adaptive mutexes.
* tst-mutex7.c: Likewise.
* tst-mutex5a.c: New file.
* tst-mutex7a.c: New file.
* Makefile (tests): Add tst-mutex5a and tst-mutex7a.
Diffstat (limited to 'nptl/sysdeps/unix/sysv/linux/x86_64')
-rw-r--r-- | nptl/sysdeps/unix/sysv/linux/x86_64/bits/pthreadtypes.h | 3 | ||||
-rw-r--r-- | nptl/sysdeps/unix/sysv/linux/x86_64/lowlevellock.h | 25 |
2 files changed, 24 insertions, 4 deletions
diff --git a/nptl/sysdeps/unix/sysv/linux/x86_64/bits/pthreadtypes.h b/nptl/sysdeps/unix/sysv/linux/x86_64/bits/pthreadtypes.h index 3f151d04ed..1b4820eb0c 100644 --- a/nptl/sysdeps/unix/sysv/linux/x86_64/bits/pthreadtypes.h +++ b/nptl/sysdeps/unix/sysv/linux/x86_64/bits/pthreadtypes.h @@ -1,4 +1,4 @@ -/* Copyright (C) 2002, 2003 Free Software Foundation, Inc. +/* Copyright (C) 2002, 2003, 2004 Free Software Foundation, Inc. This file is part of the GNU C Library. Contributed by Ulrich Drepper <drepper@redhat.com>, 2002. @@ -56,6 +56,7 @@ typedef union /* KIND must stay at this position in the structure to maintain binary compatibility. */ int __kind; + int __spins; } __data; char __size[__SIZEOF_PTHREAD_MUTEX_T]; long int __align; diff --git a/nptl/sysdeps/unix/sysv/linux/x86_64/lowlevellock.h b/nptl/sysdeps/unix/sysv/linux/x86_64/lowlevellock.h index 156d1f7c64..ca8d568038 100644 --- a/nptl/sysdeps/unix/sysv/linux/x86_64/lowlevellock.h +++ b/nptl/sysdeps/unix/sysv/linux/x86_64/lowlevellock.h @@ -1,4 +1,4 @@ -/* Copyright (C) 2002, 2003 Free Software Foundation, Inc. +/* Copyright (C) 2002, 2003, 2004 Free Software Foundation, Inc. This file is part of the GNU C Library. Contributed by Ulrich Drepper <drepper@redhat.com>, 2002. @@ -40,6 +40,10 @@ /* Initializer for compatibility lock. */ #define LLL_MUTEX_LOCK_INITIALIZER (0) #define LLL_MUTEX_LOCK_INITIALIZER_LOCKED (1) +#define LLL_MUTEX_LOCK_INITIALIZER_WAITERS (2) + +/* Delay in spinlock loop. */ +#define BUSY_WAIT_NOP asm ("rep; nop") #define lll_futex_wait(futex, val) \ @@ -77,9 +81,14 @@ extern int __lll_mutex_timedlock_wait (int *__futex, int __val, extern int __lll_mutex_unlock_wait (int *__futex) attribute_hidden; +/* NB: in the lll_mutex_trylock macro we simply return the value in %eax + after the cmpxchg instruction. In case the operation succeded this + value is zero. In case the operation failed, the cmpxchg instruction + has loaded the current value of the memory work which is guaranteed + to be nonzero. */ #define lll_mutex_trylock(futex) \ - ({ unsigned char ret; \ - __asm __volatile (LOCK_INSTR "cmpxchgl %2, %1; setne %0" \ + ({ int ret; \ + __asm __volatile (LOCK_INSTR "cmpxchgl %2, %1" \ : "=a" (ret), "=m" (futex) \ : "r" (LLL_MUTEX_LOCK_INITIALIZER_LOCKED), "m" (futex),\ "0" (LLL_MUTEX_LOCK_INITIALIZER) \ @@ -87,6 +96,16 @@ extern int __lll_mutex_unlock_wait (int *__futex) attribute_hidden; ret; }) +#define lll_mutex_cond_trylock(futex) \ + ({ int ret; \ + __asm __volatile (LOCK_INSTR "cmpxchgl %2, %1" \ + : "=a" (ret), "=m" (futex) \ + : "r" (LLL_MUTEX_LOCK_INITIALIZER_WAITERS), \ + "m" (futex), "0" (LLL_MUTEX_LOCK_INITIALIZER) \ + : "memory"); \ + ret; }) + + #define lll_mutex_lock(futex) \ (void) ({ int ignore1, ignore2, ignore3; \ __asm __volatile (LOCK_INSTR "cmpxchgl %0, %2\n\t" \ |