1 /* Copyright (C) 2002, 2003 Free Software Foundation, Inc.
2 This file is part of the GNU C Library.
3 Contributed by Ulrich Drepper <drepper@redhat.com>, 2002.
5 The GNU C Library is free software; you can redistribute it and/or
6 modify it under the terms of the GNU Lesser General Public
7 License as published by the Free Software Foundation; either
8 version 2.1 of the License, or (at your option) any later version.
10 The GNU C Library is distributed in the hope that it will be useful,
11 but WITHOUT ANY WARRANTY; without even the implied warranty of
12 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
13 Lesser General Public License for more details.
15 You should have received a copy of the GNU Lesser General Public
16 License along with the GNU C Library; if not, write to the Free
17 Software Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA
40 .globl pthread_barrier_wait
41 .type pthread_barrier_wait,@function
53 xaddl %eax, MUTEX(%ebx)
56 /* One less waiter. If this was the last one needed wake
61 /* There are more threads to come. */
65 movl CURR_EVENT(%ebx), %edx
68 /* Release the mutex. */
73 /* Wait for the remaining threads. The call will return immediately
74 if the CURR_EVENT memory has meanwhile been changed. */
75 7: movl %esi, %ecx /* movl $FUTEX_WAIT, %ecx */
76 8: movl $SYS_futex, %eax
79 /* Don't return on spurious wakeups. The syscall does not change
80 any register except %eax so there is no need to reload any of
85 cmpl %edx, CURR_EVENT(%ebx)
89 /* Note: %esi is still zero. */
90 movl %esi, %eax /* != PTHREAD_BARRIER_SERIAL_THREAD */
96 /* The necessary number of threads arrived. */
97 3: movl INIT_COUNT(%ebx), %eax
102 incl CURR_EVENT(%ebx)
105 /* Wake up all waiters. The count is a signed number in the kernel
106 so 0x7fffffff is the highest value. */
107 movl $0x7fffffff, %edx
108 movl $FUTEX_WAKE, %ecx
109 movl $SYS_futex, %eax
112 /* Release the mutex. */
117 5: orl $-1, %eax /* == PTHREAD_BARRIER_SERIAL_THREAD */
123 1: leal MUTEX(%ebx), %ecx
127 4: leal MUTEX(%ebx), %eax
128 call __lll_unlock_wake
131 6: leal MUTEX(%ebx), %eax
132 call __lll_unlock_wake
134 .size pthread_barrier_wait,.-pthread_barrier_wait