about summary refs log tree commit diff
path: root/nptl/tst-cond22.c
Commit message (Collapse)AuthorAgeFilesLines
* nptl: Extract <bits/atomic_wide_counter.h> from pthread_cond_common.cFlorian Weimer2021-11-171-4/+10
| | | | | | | | | | | | | And make it an installed header. This addresses a few aliasing violations (which do not seem to result in miscompilation due to the use of atomics), and also enables use of wide counters in other parts of the library. The debug output in nptl/tst-cond22 has been adjusted to print the 32-bit values instead because it avoids a big-endian/little-endian difference. Reviewed-by: Adhemerval Zanella <adhemerval.zanella@linaro.org>
* htl: Enable more testsSamuel Thibault2020-06-071-0/+162
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | * htl/Makefile: Remove rules adding libpthread.so and libpthread.a to link lines. * nptl/Makefile: Move rules adding libpthread.so and libpthread.a to link lines to... * sysdeps/pthread/Makefile: ... here. * nptl/eintr.c, tst-align.c tst-align3.c tst-atfork1.c tst-backtrace1.c tst-bad-schedattr.c tst-cancel-self-canceltype.c tst-cancel-self-cleanup.c tst-cancel-self-testcancel.c tst-cancel1.c tst-cancel10.c tst-cancel12.c tst-cancel14.c tst-cancel15.c tst-cancel18.c tst-cancel19.c tst-cancel2.c tst-cancel22.c tst-cancel23.c tst-cancel26.c tst-cancel27.c tst-cancel28.c tst-cancel3.c tst-cancel8.c tst-cancelx1.c tst-cancelx10.c tst-cancelx12.c tst-cancelx14.c tst-cancelx15.c tst-cancelx18.c tst-cancelx2.c tst-cancelx3.c tst-cancelx8.c tst-cleanup0.c tst-cleanup0.expect tst-cleanup1.c tst-cleanup2.c tst-cleanup3.c tst-cleanupx0.c tst-cleanupx0.expect tst-cleanupx1.c tst-cleanupx2.c tst-cleanupx3.c tst-clock1.c tst-create-detached.c tst-detach1.c tst-eintr2.c tst-eintr3.c tst-eintr4.c tst-eintr5.c tst-exec1.c tst-exec2.c tst-exec3.c tst-exit1.c tst-exit2.c tst-exit3.c tst-flock1.c tst-fork1.c tst-fork2.c tst-fork3.c tst-fork4.c tst-getpid3.c tst-kill1.c tst-kill2.c tst-kill3.c tst-kill4.c tst-kill5.c tst-kill6.c tst-locale1.c tst-locale2.c tst-memstream.c tst-popen1.c tst-raise1.c tst-sem5.c tst-setuid3.c tst-signal4.c tst-signal5.c tst-signal6.c tst-signal8.c tst-stack1.c tst-stdio1.c tst-stdio2.c tst-sysconf.c tst-tls1.c tst-tls2.c tst-tsd1.c tst-tsd2.c tst-tsd5.c tst-tsd6.c tst-umask1.c tst-unload.c tst-unwind-thread.c tst-vfork1.c tst-vfork1x.c tst-vfork2.c tst-vfork2x.c: Move tests to... * sysdeps/pthread: ... here. Rename tst-popen1.c -> tst-pt-popen1.c tst-align.c -> tst-pt-align.c tst-align3.c -> tst-pt-align3.c tst-sysconf.c -> tst-pt-sysconf.c tst-tls1.c -> tst-pt-tls1.c tst-tls2.c -> tst-pt-tls2.c tst-vfork1.c -> tst-pt-vfork1.c tst-vfork2.c -> tst-pt-vfork2.c to avoid conflicting with libio/tst-popen1.c, elf/tst-align.c, posix/tst-sysconf.c, elf/tst-tls1.c, elf/tst-tls2.c, posix/tst-vfork1.c, posix/tst-vfork2.c. * nptl/Makefile: Move corresponding tests references and special rules to... * sysdeps/pthread/Makefile: ... here. * sysdeps/pthread/tst-stack1.c (do_test): Do not clamp stack size to PTHREAD_STACK_MIN if not defined. Tested on linux-x86_64 and hurd-i386
* pthread: Move most cond tests from nptl to sysdeps/pthreadSamuel Thibault2020-02-091-162/+0
| | | | So they can be checked with htl too.
* New condvar implementation that provides stronger ordering guarantees.Torvald Riegel2016-12-311-8/+10
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | This is a new implementation for condition variables, required after http://austingroupbugs.net/view.php?id=609 to fix bug 13165. In essence, we need to be stricter in which waiters a signal or broadcast is required to wake up; this couldn't be solved using the old algorithm. ISO C++ made a similar clarification, so this also fixes a bug in current libstdc++, for example. We can't use the old algorithm anymore because futexes do not guarantee to wake in FIFO order. Thus, when we wake, we can't simply let any waiter grab a signal, but we need to ensure that one of the waiters happening before the signal is woken up. This is something the previous algorithm violated (see bug 13165). There's another issue specific to condvars: ABA issues on the underlying futexes. Unlike mutexes that have just three states, or semaphores that have no tokens or a limited number of them, the state of a condvar is the *order* of the waiters. A waiter on a semaphore can grab a token whenever one is available; a condvar waiter must only consume a signal if it is eligible to do so as determined by the relative order of the waiter and the signal. Therefore, this new algorithm maintains two groups of waiters: Those eligible to consume signals (G1), and those that have to wait until previous waiters have consumed signals (G2). Once G1 is empty, G2 becomes the new G1. 64b counters are used to avoid ABA issues. This condvar doesn't yet use a requeue optimization (ie, on a broadcast, waking just one thread and requeueing all others on the futex of the mutex supplied by the program). I don't think doing the requeue is necessarily the right approach (but I haven't done real measurements yet): * If a program expects to wake many threads at the same time and make that scalable, a condvar isn't great anyway because of how it requires waiters to operate mutually exclusive (due to the mutex usage). Thus, a thundering herd problem is a scalability problem with or without the optimization. Using something like a semaphore might be more appropriate in such a case. * The scalability problem is actually at the mutex side; the condvar could help (and it tries to with the requeue optimization), but it should be the mutex who decides how that is done, and whether it is done at all. * Forcing all but one waiter into the kernel-side wait queue of the mutex prevents/avoids the use of lock elision on the mutex. Thus, it prevents the only cure against the underlying scalability problem inherent to condvars. * If condvars use short critical sections (ie, hold the mutex just to check a binary flag or such), which they should do ideally, then forcing all those waiter to proceed serially with kernel-based hand-off (ie, futex ops in the mutex' contended state, via the futex wait queues) will be less efficient than just letting a scalable mutex implementation take care of it. Our current mutex impl doesn't employ spinning at all, but if critical sections are short, spinning can be much better. * Doing the requeue stuff requires all waiters to always drive the mutex into the contended state. This leads to each waiter having to call futex_wake after lock release, even if this wouldn't be necessary. [BZ #13165] * nptl/pthread_cond_broadcast.c (__pthread_cond_broadcast): Rewrite to use new algorithm. * nptl/pthread_cond_destroy.c (__pthread_cond_destroy): Likewise. * nptl/pthread_cond_init.c (__pthread_cond_init): Likewise. * nptl/pthread_cond_signal.c (__pthread_cond_signal): Likewise. * nptl/pthread_cond_wait.c (__pthread_cond_wait): Likewise. (__pthread_cond_timedwait): Move here from pthread_cond_timedwait.c. (__condvar_confirm_wakeup, __condvar_cancel_waiting, __condvar_cleanup_waiting, __condvar_dec_grefs, __pthread_cond_wait_common): New. (__condvar_cleanup): Remove. * npt/pthread_condattr_getclock.c (pthread_condattr_getclock): Adapt. * npt/pthread_condattr_setclock.c (pthread_condattr_setclock): Likewise. * npt/pthread_condattr_getpshared.c (pthread_condattr_getpshared): Likewise. * npt/pthread_condattr_init.c (pthread_condattr_init): Likewise. * nptl/tst-cond1.c: Add comment. * nptl/tst-cond20.c (do_test): Adapt. * nptl/tst-cond22.c (do_test): Likewise. * sysdeps/aarch64/nptl/bits/pthreadtypes.h (pthread_cond_t): Adapt structure. * sysdeps/arm/nptl/bits/pthreadtypes.h (pthread_cond_t): Likewise. * sysdeps/ia64/nptl/bits/pthreadtypes.h (pthread_cond_t): Likewise. * sysdeps/m68k/nptl/bits/pthreadtypes.h (pthread_cond_t): Likewise. * sysdeps/microblaze/nptl/bits/pthreadtypes.h (pthread_cond_t): Likewise. * sysdeps/mips/nptl/bits/pthreadtypes.h (pthread_cond_t): Likewise. * sysdeps/nios2/nptl/bits/pthreadtypes.h (pthread_cond_t): Likewise. * sysdeps/s390/nptl/bits/pthreadtypes.h (pthread_cond_t): Likewise. * sysdeps/sh/nptl/bits/pthreadtypes.h (pthread_cond_t): Likewise. * sysdeps/tile/nptl/bits/pthreadtypes.h (pthread_cond_t): Likewise. * sysdeps/unix/sysv/linux/alpha/bits/pthreadtypes.h (pthread_cond_t): Likewise. * sysdeps/unix/sysv/linux/powerpc/bits/pthreadtypes.h (pthread_cond_t): Likewise. * sysdeps/x86/bits/pthreadtypes.h (pthread_cond_t): Likewise. * sysdeps/nptl/internaltypes.h (COND_NWAITERS_SHIFT): Remove. (COND_CLOCK_BITS): Adapt. * sysdeps/nptl/pthread.h (PTHREAD_COND_INITIALIZER): Adapt. * nptl/pthreadP.h (__PTHREAD_COND_CLOCK_MONOTONIC_MASK, __PTHREAD_COND_SHARED_MASK): New. * nptl/nptl-printers.py (CLOCK_IDS): Remove. (ConditionVariablePrinter, ConditionVariableAttributesPrinter): Adapt. * nptl/nptl_lock_constants.pysym: Adapt. * nptl/test-cond-printers.py: Adapt. * sysdeps/unix/sysv/linux/hppa/internaltypes.h (cond_compat_clear, cond_compat_check_and_clear): Adapt. * sysdeps/unix/sysv/linux/hppa/pthread_cond_timedwait.c: Remove file ... * sysdeps/unix/sysv/linux/hppa/pthread_cond_wait.c (__pthread_cond_timedwait): ... and move here. * nptl/DESIGN-condvar.txt: Remove file. * nptl/lowlevelcond.sym: Likewise. * nptl/pthread_cond_timedwait.c: Likewise. * sysdeps/unix/sysv/linux/i386/i486/pthread_cond_broadcast.S: Likewise. * sysdeps/unix/sysv/linux/i386/i486/pthread_cond_signal.S: Likewise. * sysdeps/unix/sysv/linux/i386/i486/pthread_cond_timedwait.S: Likewise. * sysdeps/unix/sysv/linux/i386/i486/pthread_cond_wait.S: Likewise. * sysdeps/unix/sysv/linux/i386/i586/pthread_cond_broadcast.S: Likewise. * sysdeps/unix/sysv/linux/i386/i586/pthread_cond_signal.S: Likewise. * sysdeps/unix/sysv/linux/i386/i586/pthread_cond_timedwait.S: Likewise. * sysdeps/unix/sysv/linux/i386/i586/pthread_cond_wait.S: Likewise. * sysdeps/unix/sysv/linux/i386/i686/pthread_cond_broadcast.S: Likewise. * sysdeps/unix/sysv/linux/i386/i686/pthread_cond_signal.S: Likewise. * sysdeps/unix/sysv/linux/i386/i686/pthread_cond_timedwait.S: Likewise. * sysdeps/unix/sysv/linux/i386/i686/pthread_cond_wait.S: Likewise. * sysdeps/unix/sysv/linux/x86_64/pthread_cond_broadcast.S: Likewise. * sysdeps/unix/sysv/linux/x86_64/pthread_cond_signal.S: Likewise. * sysdeps/unix/sysv/linux/x86_64/pthread_cond_timedwait.S: Likewise. * sysdeps/unix/sysv/linux/x86_64/pthread_cond_wait.S: Likewise.
* Fix leading whitespaces.Ondrej Bilka2013-06-061-2/+2
|
* 2006-09-14 Jakub Jelinek <jakub@redhat.com> cvs/fedora-glibc-20060915T0943Ulrich Drepper2006-09-151-14/+13
| | | | | | | | | | | | | | | Steven Munroe <sjmunroe@us.ibm.com> * sysdeps/powerpc/dl-procinfo.c (_dl_powerpc_cap_flags): Add 4 new cap names to the beginning. Rename "cell" to "cellbe". (_dl_powerpc_platforms): New. * sysdeps/powerpc/dl-procinfo.h (_DL_HWCAP_FIRST): Decrease. (HWCAP_IMPORTANT): Remove power{4,5,5+} and cell. (_DL_PLATFORMS_COUNT, _DL_FIRST_PLATFORM): Define. (_DL_HWCAP_PLATFORM): Define to new mask. (_dl_platform_string, _dl_string_platform): New functions. * sysdeps/powerpc/sysdep.h (PPC_FEATURE_BOOKE, PPC_FEATURE_SMT, PPC_FEATURE_ICACHE_SNOOP, PPC_FEATURE_ARCH_2_05): Define.
* [BZ #2526, BZ #3138, BZ #3143]Ulrich Drepper2006-09-121-9/+16
| | | | | | | | | | | | | | | | | | | | | | | | 2006-09-12 Jakub Jelinek <jakub@redhat.com> [BZ #2526] * README.libm: Fix a thinko in sqrt algorithm description. [BZ #3143] * manual/string.texi (argz_delete): Fix prototype. Patch by <alpt@freaknet.org>. 2006-08-26 Joseph Myers <joseph@codesourcery.com> [BZ #3138] * io/test-lfs.c (do_prepare): Give name_len type size_t. * io/tst-fcntl.c (do_prepare): Likewise. * posix/tst-exec.c (do_prepare): Likewise. * posix/tst-preadwrite.c (do_prepare): Likewise. * posix/tst-spawn.c (do_prepare): Likewise. * posix/tst-truncate.c (do_prepare): Likewise. * rt/tst-aio.c (do_prepare): Likewise. * rt/tst-aio64.c (do_prepare): Likewise. * stdlib/test-canon2.c (do_prepare): Give test_dir_len type size_t.
* [BZ #1006]Ulrich Drepper2006-09-091-1/+2
| | | | | | | * sysdeps/sparc/sparc64/dl-machine.h (elf_machine_rela): Ensure relocation doesn't clobber any bits outside of the immediate field for R_SPARC_TLS_LE_HIX22, R_SPARC_WDISP30, R_SPARC_HI22 and R_SPARC_H44.
* [BZ #3123]Ulrich Drepper2006-09-081-0/+153
| | | | | | | | | | | | 2006-09-08 Ulrich Drepper <drepper@redhat.com> [BZ #3123] * sysdeps/pthread/pthread_cond_wait.c (__condvar_cleanup): Don't increment WAKEUP_SEQ if this would increase the value beyond TOTAL_SEQ. * sysdeps/unix/sysv/linux/i386/i486/pthread_cond_wait.c: Likewise. * sysdeps/unix/sysv/linux/i386/i486/pthread_cond_timedwait.c: Likewise. * sysdeps/unix/sysv/linux/x86_64/pthread_cond_wait.c: Likewise. * Makefile (tests): Add tst-cond22. * tst-cond22.c: New file.
* (CFLAGS-tst-align.c): Add -mpreferred-stack-boundary=4.Ulrich Drepper2004-12-221-160/+0
|
* 2.5-18.1Jakub Jelinek2007-07-121-0/+160