mirror of
https://sourceware.org/git/glibc.git
synced 2025-07-30 22:43:12 +03:00
Update.
* sysdeps/pthread/pthread_cond_wait.c (__pthread_cond_wait): Don't store mutex address if the current value is ~0l. * sysdeps/pthread/pthread_cond_timedwait.c (__pthread_cond_timedwait): Likewise. * sysdeps/pthread/pthread_cond_broadcast.c (__pthread_cond_broadcast): Don't use requeue for pshared condvars. * sysdeps/unix/sysv/linux/x86_64/pthread_cond_wait.S (__pthread_cond_wait): Don't store mutex address if the current value is ~0l. * sysdeps/unix/sysv/linux/x86_64/pthread_cond_timedwait.S (__pthread_cond_timedwait): Likewise. * sysdeps/unix/sysv/linux/x86_64/pthread_cond_broadcast.S (__pthread_cond_broadcast): Don't use requeue for pshared condvars. * pthread_cond_init.c (__pthread_cond_init): Initialize __mutex element with ~0l for pshared condvars, with NULL otherwise. * sysdeps/unix/sysv/linux/i386/i486/pthread_cond_wait.S (__pthread_cond_wait): Don't store mutex address if the current value is ~0l. * sysdeps/unix/sysv/linux/i386/i486/pthread_cond_timedwait.S (__pthread_cond_timedwait): Likewise. * sysdeps/unix/sysv/linux/i386/i486/pthread_cond_broadcast.S (__pthread_cond_broadcast): Don't use requeue for pshared condvars.
This commit is contained in:
@ -1,5 +1,34 @@
|
|||||||
2003-11-21 Ulrich Drepper <drepper@redhat.com>
|
2003-11-21 Ulrich Drepper <drepper@redhat.com>
|
||||||
|
|
||||||
|
* sysdeps/pthread/pthread_cond_wait.c (__pthread_cond_wait): Don't
|
||||||
|
store mutex address if the current value is ~0l.
|
||||||
|
* sysdeps/pthread/pthread_cond_timedwait.c
|
||||||
|
(__pthread_cond_timedwait): Likewise.
|
||||||
|
* sysdeps/pthread/pthread_cond_broadcast.c
|
||||||
|
(__pthread_cond_broadcast): Don't use requeue for pshared
|
||||||
|
condvars.
|
||||||
|
|
||||||
|
* sysdeps/unix/sysv/linux/x86_64/pthread_cond_wait.S
|
||||||
|
(__pthread_cond_wait): Don't store mutex address if the current
|
||||||
|
value is ~0l.
|
||||||
|
* sysdeps/unix/sysv/linux/x86_64/pthread_cond_timedwait.S
|
||||||
|
(__pthread_cond_timedwait): Likewise.
|
||||||
|
* sysdeps/unix/sysv/linux/x86_64/pthread_cond_broadcast.S
|
||||||
|
(__pthread_cond_broadcast): Don't use requeue for pshared
|
||||||
|
condvars.
|
||||||
|
|
||||||
|
* pthread_cond_init.c (__pthread_cond_init): Initialize __mutex
|
||||||
|
element with ~0l for pshared condvars, with NULL otherwise.
|
||||||
|
|
||||||
|
* sysdeps/unix/sysv/linux/i386/i486/pthread_cond_wait.S
|
||||||
|
(__pthread_cond_wait): Don't store mutex address if the current
|
||||||
|
value is ~0l.
|
||||||
|
* sysdeps/unix/sysv/linux/i386/i486/pthread_cond_timedwait.S
|
||||||
|
(__pthread_cond_timedwait): Likewise.
|
||||||
|
* sysdeps/unix/sysv/linux/i386/i486/pthread_cond_broadcast.S
|
||||||
|
(__pthread_cond_broadcast): Don't use requeue for pshared
|
||||||
|
condvars.
|
||||||
|
|
||||||
* Makefile: Add rules to build and run tst-cond12 and tst-cond13.
|
* Makefile: Add rules to build and run tst-cond12 and tst-cond13.
|
||||||
* tst-cond12.c: New file.
|
* tst-cond12.c: New file.
|
||||||
* tst-cond13.c: New file.
|
* tst-cond13.c: New file.
|
||||||
|
@ -36,6 +36,8 @@ __pthread_cond_init (cond, cond_attr)
|
|||||||
cond->__data.__total_seq = 0;
|
cond->__data.__total_seq = 0;
|
||||||
cond->__data.__wakeup_seq = 0;
|
cond->__data.__wakeup_seq = 0;
|
||||||
cond->__data.__woken_seq = 0;
|
cond->__data.__woken_seq = 0;
|
||||||
|
cond->__data.__mutex = (icond_attr == NULL || (icond_attr->value & 1) == 0
|
||||||
|
? NULL : (void *) ~0l);
|
||||||
|
|
||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
|
@ -54,6 +54,10 @@ __pthread_cond_broadcast (cond)
|
|||||||
# error "No valid byte order"
|
# error "No valid byte order"
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
|
/* Do not use requeue for pshared condvars. */
|
||||||
|
if (cond->__data.__mutex == (void *) ~0l)
|
||||||
|
goto wake_all;
|
||||||
|
|
||||||
/* Wake everybody. */
|
/* Wake everybody. */
|
||||||
pthread_mutex_t *mut = (pthread_mutex_t *) cond->__data.__mutex;
|
pthread_mutex_t *mut = (pthread_mutex_t *) cond->__data.__mutex;
|
||||||
if (__builtin_expect (lll_futex_requeue (futex, 1, INT_MAX,
|
if (__builtin_expect (lll_futex_requeue (futex, 1, INT_MAX,
|
||||||
@ -61,9 +65,8 @@ __pthread_cond_broadcast (cond)
|
|||||||
0))
|
0))
|
||||||
{
|
{
|
||||||
/* The requeue functionality is not available. */
|
/* The requeue functionality is not available. */
|
||||||
#ifndef __ASSUME_FUTEX_REQUEUE
|
wake_all:
|
||||||
lll_futex_wake (futex, INT_MAX);
|
lll_futex_wake (futex, INT_MAX);
|
||||||
#endif
|
|
||||||
}
|
}
|
||||||
|
|
||||||
/* That's all. */
|
/* That's all. */
|
||||||
|
@ -67,8 +67,10 @@ __pthread_cond_timedwait (cond, mutex, abstime)
|
|||||||
++cond->__data.__total_seq;
|
++cond->__data.__total_seq;
|
||||||
|
|
||||||
/* Remember the mutex we are using here. If there is already a
|
/* Remember the mutex we are using here. If there is already a
|
||||||
different address store this is a bad user bug. */
|
different address store this is a bad user bug. Do not store
|
||||||
cond->__data.__mutex = mutex;
|
anything for pshared condvars. */
|
||||||
|
if (cond->__data.__mutex != (void *) ~0l)
|
||||||
|
cond->__data.__mutex = mutex;
|
||||||
|
|
||||||
/* Prepare structure passed to cancellation handler. */
|
/* Prepare structure passed to cancellation handler. */
|
||||||
cbuffer.cond = cond;
|
cbuffer.cond = cond;
|
||||||
|
@ -93,8 +93,10 @@ __pthread_cond_wait (cond, mutex)
|
|||||||
++cond->__data.__total_seq;
|
++cond->__data.__total_seq;
|
||||||
|
|
||||||
/* Remember the mutex we are using here. If there is already a
|
/* Remember the mutex we are using here. If there is already a
|
||||||
different address store this is a bad user bug. */
|
different address store this is a bad user bug. Do not store
|
||||||
cond->__data.__mutex = mutex;
|
anything for pshared condvars. */
|
||||||
|
if (cond->__data.__mutex != (void *) ~0l)
|
||||||
|
cond->__data.__mutex = mutex;
|
||||||
|
|
||||||
/* Prepare structure passed to cancellation handler. */
|
/* Prepare structure passed to cancellation handler. */
|
||||||
cbuffer.cond = cond;
|
cbuffer.cond = cond;
|
||||||
|
@ -83,8 +83,12 @@ __pthread_cond_broadcast:
|
|||||||
subl $1, cond_lock-wakeup_seq(%ebx)
|
subl $1, cond_lock-wakeup_seq(%ebx)
|
||||||
jne 7f
|
jne 7f
|
||||||
|
|
||||||
|
/* Don't use requeue for pshared condvars. */
|
||||||
|
8: cmpl $-1, %edi
|
||||||
|
je 9f
|
||||||
|
|
||||||
/* Wake up all threads. */
|
/* Wake up all threads. */
|
||||||
8: movl $FUTEX_REQUEUE, %ecx
|
movl $FUTEX_REQUEUE, %ecx
|
||||||
movl $SYS_futex, %eax
|
movl $SYS_futex, %eax
|
||||||
movl $0x7fffffff, %esi
|
movl $0x7fffffff, %esi
|
||||||
movl $1, %edx
|
movl $1, %edx
|
||||||
@ -97,10 +101,9 @@ __pthread_cond_broadcast:
|
|||||||
#ifndef __ASSUME_FUTEX_REQUEUE
|
#ifndef __ASSUME_FUTEX_REQUEUE
|
||||||
cmpl $-EINVAL, %eax
|
cmpl $-EINVAL, %eax
|
||||||
je 9f
|
je 9f
|
||||||
10:
|
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
xorl %eax, %eax
|
10: xorl %eax, %eax
|
||||||
popl %edi
|
popl %edi
|
||||||
popl %esi
|
popl %esi
|
||||||
popl %ebx
|
popl %ebx
|
||||||
@ -138,14 +141,12 @@ __pthread_cond_broadcast:
|
|||||||
call __lll_mutex_unlock_wake
|
call __lll_mutex_unlock_wake
|
||||||
jmp 8b
|
jmp 8b
|
||||||
|
|
||||||
#ifndef __ASSUME_FUTEX_REQUEUE
|
|
||||||
9: /* The futex requeue functionality is not available. */
|
9: /* The futex requeue functionality is not available. */
|
||||||
movl $0x7fffffff, %edx
|
movl $0x7fffffff, %edx
|
||||||
movl $FUTEX_WAKE, %ecx
|
movl $FUTEX_WAKE, %ecx
|
||||||
movl $SYS_futex, %eax
|
movl $SYS_futex, %eax
|
||||||
ENTER_KERNEL
|
ENTER_KERNEL
|
||||||
jmp 10b
|
jmp 10b
|
||||||
#endif
|
|
||||||
.size __pthread_cond_broadcast, .-__pthread_cond_broadcast
|
.size __pthread_cond_broadcast, .-__pthread_cond_broadcast
|
||||||
versioned_symbol (libpthread, __pthread_cond_broadcast, pthread_cond_broadcast,
|
versioned_symbol (libpthread, __pthread_cond_broadcast, pthread_cond_broadcast,
|
||||||
GLIBC_2_3_2)
|
GLIBC_2_3_2)
|
||||||
|
@ -68,11 +68,13 @@ __pthread_cond_timedwait:
|
|||||||
|
|
||||||
/* Store the reference to the mutex. If there is already a
|
/* Store the reference to the mutex. If there is already a
|
||||||
different value in there this is a bad user bug. */
|
different value in there this is a bad user bug. */
|
||||||
2: movl 24(%esp), %eax
|
2: cmpl $-1, dep_mutex(%ebx)
|
||||||
|
movl 24(%esp), %eax
|
||||||
|
je 17f
|
||||||
movl %eax, dep_mutex(%ebx)
|
movl %eax, dep_mutex(%ebx)
|
||||||
|
|
||||||
/* Unlock the mutex. */
|
/* Unlock the mutex. */
|
||||||
xorl %edx, %edx
|
17: xorl %edx, %edx
|
||||||
call __pthread_mutex_unlock_usercnt
|
call __pthread_mutex_unlock_usercnt
|
||||||
|
|
||||||
testl %eax, %eax
|
testl %eax, %eax
|
||||||
|
@ -65,11 +65,13 @@ __pthread_cond_wait:
|
|||||||
|
|
||||||
/* Store the reference to the mutex. If there is already a
|
/* Store the reference to the mutex. If there is already a
|
||||||
different value in there this is a bad user bug. */
|
different value in there this is a bad user bug. */
|
||||||
2: movl 20(%esp), %eax
|
2: cmpl $-1, dep_mutex(%ebx)
|
||||||
|
movl 20(%esp), %eax
|
||||||
|
je 15f
|
||||||
movl %eax, dep_mutex(%ebx)
|
movl %eax, dep_mutex(%ebx)
|
||||||
|
|
||||||
/* Unlock the mutex. */
|
/* Unlock the mutex. */
|
||||||
xorl %edx, %edx
|
15: xorl %edx, %edx
|
||||||
call __pthread_mutex_unlock_usercnt
|
call __pthread_mutex_unlock_usercnt
|
||||||
|
|
||||||
testl %eax, %eax
|
testl %eax, %eax
|
||||||
|
@ -72,8 +72,11 @@ __pthread_cond_broadcast:
|
|||||||
decl cond_lock-wakeup_seq(%rdi)
|
decl cond_lock-wakeup_seq(%rdi)
|
||||||
jne 7f
|
jne 7f
|
||||||
|
|
||||||
|
8: cmpq $-1, %r8
|
||||||
|
je 9f
|
||||||
|
|
||||||
/* Wake up all threads. */
|
/* Wake up all threads. */
|
||||||
8: movq $FUTEX_REQUEUE, %rsi
|
movq $FUTEX_REQUEUE, %rsi
|
||||||
movq $SYS_futex, %rax
|
movq $SYS_futex, %rax
|
||||||
movl $1, %edx
|
movl $1, %edx
|
||||||
movq $0x7fffffff, %r10
|
movq $0x7fffffff, %r10
|
||||||
@ -82,10 +85,9 @@ __pthread_cond_broadcast:
|
|||||||
#ifndef __ASSUME_FUTEX_REQUEUE
|
#ifndef __ASSUME_FUTEX_REQUEUE
|
||||||
cmpq $-EINVAL, %rax
|
cmpq $-EINVAL, %rax
|
||||||
je 9f
|
je 9f
|
||||||
10:
|
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
xorl %eax, %eax
|
10: xorl %eax, %eax
|
||||||
retq
|
retq
|
||||||
|
|
||||||
.align 16
|
.align 16
|
||||||
@ -119,14 +121,12 @@ __pthread_cond_broadcast:
|
|||||||
subq $cond_lock-wakeup_seq, %rdi
|
subq $cond_lock-wakeup_seq, %rdi
|
||||||
jmp 8b
|
jmp 8b
|
||||||
|
|
||||||
#ifndef __ASSUME_FUTEX_REQUEUE
|
|
||||||
9: /* The futex requeue functionality is not available. */
|
9: /* The futex requeue functionality is not available. */
|
||||||
movq $0x7fffffff, %rdx
|
movq $0x7fffffff, %rdx
|
||||||
movq $FUTEX_WAKE, %rsi
|
movq $FUTEX_WAKE, %rsi
|
||||||
movq $SYS_futex, %rax
|
movq $SYS_futex, %rax
|
||||||
syscall
|
syscall
|
||||||
jmp 10b
|
jmp 10b
|
||||||
#endif
|
|
||||||
.size __pthread_cond_broadcast, .-__pthread_cond_broadcast
|
.size __pthread_cond_broadcast, .-__pthread_cond_broadcast
|
||||||
versioned_symbol (libpthread, __pthread_cond_broadcast, pthread_cond_broadcast,
|
versioned_symbol (libpthread, __pthread_cond_broadcast, pthread_cond_broadcast,
|
||||||
GLIBC_2_3_2)
|
GLIBC_2_3_2)
|
||||||
|
@ -71,15 +71,18 @@ __pthread_cond_timedwait:
|
|||||||
+--------------------------+
|
+--------------------------+
|
||||||
*/
|
*/
|
||||||
|
|
||||||
|
cmpq $-1, dep_mutex(%rdi)
|
||||||
|
|
||||||
/* Prepare structure passed to cancellation handler. */
|
/* Prepare structure passed to cancellation handler. */
|
||||||
movq %rdi, 8(%rsp)
|
movq %rdi, 8(%rsp)
|
||||||
movq %rsi, 16(%rsp)
|
movq %rsi, 16(%rsp)
|
||||||
movq %rdx, %r13
|
movq %rdx, %r13
|
||||||
|
|
||||||
|
je 22f
|
||||||
movq %rsi, dep_mutex(%rdi)
|
movq %rsi, dep_mutex(%rdi)
|
||||||
|
|
||||||
/* Get internal lock. */
|
/* Get internal lock. */
|
||||||
movl $1, %esi
|
22: movl $1, %esi
|
||||||
xorl %eax, %eax
|
xorl %eax, %eax
|
||||||
LOCK
|
LOCK
|
||||||
#if cond_lock == 0
|
#if cond_lock == 0
|
||||||
|
@ -117,14 +117,17 @@ __pthread_cond_wait:
|
|||||||
+--------------------------+
|
+--------------------------+
|
||||||
*/
|
*/
|
||||||
|
|
||||||
/* Prepare structure passed to cancellation handler. */
|
cmpq $-1, dep_mutex(%rdi)
|
||||||
|
|
||||||
|
/* Prepare structure passed to cancellation handler. */
|
||||||
movq %rdi, 8(%rsp)
|
movq %rdi, 8(%rsp)
|
||||||
movq %rsi, 16(%rsp)
|
movq %rsi, 16(%rsp)
|
||||||
|
|
||||||
|
je 15f
|
||||||
movq %rsi, dep_mutex(%rdi)
|
movq %rsi, dep_mutex(%rdi)
|
||||||
|
|
||||||
/* Get internal lock. */
|
/* Get internal lock. */
|
||||||
movl $1, %esi
|
15: movl $1, %esi
|
||||||
xorl %eax, %eax
|
xorl %eax, %eax
|
||||||
LOCK
|
LOCK
|
||||||
#if cond_lock == 0
|
#if cond_lock == 0
|
||||||
|
Reference in New Issue
Block a user