Up to [cvs.NetBSD.org] / src / lib / libpthread
Request diff between arbitrary revisions
Keyword substitution: kv
Default branch: MAIN
pthread: Nix trailing whitespace.
libpthread: Move namespacing include to top of .c files. Stuff like libc's namespace.h, or atomic_op_namespace.h, which does namespacing tricks like `#define atomic_cas_uint _atomic_cas_uint', has to go at the top of each .c file. If it goes in the middle, it might be too late to affect the declarations, and result in compile errors. I tripped over this by including <sys/atomic.h> in mips <machine/lock.h>. (Maybe we should create a new pthread_namespace.h file for the purpose, but this'll do for now.)
Sync with the following revisions (requested by skrll in ticket #1196): gnu/dist/gdb removed gnu/usr.bin/gdb53 removed distrib/cats/instkernel/Makefile 1.14.6.1 gnu/dist/gdb6/bfd/config.bfd 1.3.6.1 gnu/dist/gdb6/bfd/elfxx-sparc.c 1.1.1.2.6.1 gnu/dist/gdb6/bfd/elfxx-sparc.h 1.1.1.2.6.1 gnu/dist/gdb6/gdb/Makefile.in 1.2.2.1.2.2 gnu/dist/gdb6/gdb/alpha-tdep.c 1.1.1.2.6.1 gnu/dist/gdb6/gdb/alpha-tdep.h 1.1.1.2.6.1 gnu/dist/gdb6/gdb/alphabsd-nat.c 1.1.1.2.6.2 gnu/dist/gdb6/gdb/alphabsd-nat.h 1.1.2.1 gnu/dist/gdb6/gdb/alphabsd-tdep.c 1.1.1.2.6.1 gnu/dist/gdb6/gdb/alphabsd-tdep.h 1.1.1.2.6.1 gnu/dist/gdb6/gdb/alphanbsd-nat.c 1.1.2.1 gnu/dist/gdb6/gdb/alphanbsd-tdep.c 1.1.1.2.6.1 gnu/dist/gdb6/gdb/amd64-nat.c 1.1.1.2.6.1 gnu/dist/gdb6/gdb/amd64bsd-nat.c 1.1.1.2.6.1 gnu/dist/gdb6/gdb/amd64nbsd-nat.c 1.1.1.2.6.3 gnu/dist/gdb6/gdb/amd64nbsd-tdep.c 1.1.1.2.6.1 gnu/dist/gdb6/gdb/arm-tdep.h 1.1.1.2.6.1 gnu/dist/gdb6/gdb/armbsd-tdep.c 1.1.2.1 gnu/dist/gdb6/gdb/armnbsd-nat.c 1.1.1.2.6.2 gnu/dist/gdb6/gdb/armnbsd-tdep.c 1.1.1.2.6.1 gnu/dist/gdb6/gdb/configure 1.1.1.2.6.1 gnu/dist/gdb6/gdb/configure.ac 1.1.1.2.6.1 gnu/dist/gdb6/gdb/i386bsd-nat.c 1.1.1.2.6.1 gnu/dist/gdb6/gdb/i386nbsd-tdep.c 1.1.1.2.6.1 gnu/dist/gdb6/gdb/m68kbsd-nat.c 1.1.1.2.6.2 gnu/dist/gdb6/gdb/mipsnbsd-nat.c 1.1.1.2.6.2 gnu/dist/gdb6/gdb/nbsd-thread.c 1.1.2.3 gnu/dist/gdb6/gdb/ppcnbsd-nat.c 1.1.1.2.6.2 gnu/dist/gdb6/gdb/ppcnbsd-tdep.c 1.3.6.1 gnu/dist/gdb6/gdb/sh-tdep.c 1.1.1.2.6.1 gnu/dist/gdb6/gdb/shnbsd-nat.c 1.1.1.2.6.3 gnu/dist/gdb6/gdb/shnbsd-tdep.c 1.1.1.2.6.4 gnu/dist/gdb6/gdb/shnbsd-tdep.h 1.1.1.2.6.1 gnu/dist/gdb6/gdb/sparc-nat.c 1.1.1.2.6.1 gnu/dist/gdb6/gdb/sparc64nbsd-nat.c 1.1.1.2.6.2 gnu/dist/gdb6/gdb/sparcnbsd-nat.c 1.1.1.2.6.2 gnu/dist/gdb6/gdb/tramp-frame.h 1.1.1.2.6.1 gnu/dist/gdb6/gdb/vaxbsd-nat.c 1.1.1.2.6.2 gnu/dist/gdb6/gdb/config/alpha/nbsd.mh 1.1.1.2.6.1 gnu/dist/gdb6/gdb/config/arm/nbsd.mt 1.1.1.1.6.1 gnu/dist/gdb6/gdb/config/arm/nbsdelf.mh 1.1.1.1.6.1 gnu/dist/gdb6/gdb/config/i386/nbsd64.mh 1.1.1.1.6.1 gnu/dist/gdb6/gdb/config/m68k/nbsdelf.mh 1.1.1.1.6.1 gnu/dist/gdb6/gdb/config/mips/nbsd.mh 1.1.1.1.6.1 gnu/dist/gdb6/gdb/config/powerpc/nbsd.mh 1.1.1.2.6.1 gnu/dist/gdb6/gdb/config/sh/nbsd.mh 1.1.1.1.6.2 gnu/dist/gdb6/gdb/config/sh/tm-nbsd.h 1.1.1.1.6.1 gnu/dist/gdb6/gdb/config/sparc/nbsd64.mh 1.1.1.1.6.1 gnu/dist/gdb6/gdb/config/sparc/nbsdelf.mh 1.1.1.1.6.1 gnu/dist/gdb6/gdb/config/vax/nbsdelf.mh 1.1.1.1.6.1 gnu/dist/gdb6/opcodes/configure 1.1.1.2.6.1 gnu/dist/gdb6/opcodes/configure.in 1.1.1.2.6.1 gnu/usr.bin/Makefile 1.126.4.1 gnu/usr.bin/gdb6/arch/alpha/config.h 1.3.4.1 gnu/usr.bin/gdb6/arch/alpha/defs.mk 1.2.6.1 gnu/usr.bin/gdb6/arch/alpha/init.c 1.2.6.1 gnu/usr.bin/gdb6/arch/alpha/nm.h 1.2.6.1 gnu/usr.bin/gdb6/arch/arm/defs.mk 1.2.6.2 gnu/usr.bin/gdb6/arch/arm/init.c 1.1.6.1 gnu/usr.bin/gdb6/arch/armeb/config.h 1.1.6.2 gnu/usr.bin/gdb6/arch/armeb/defs.mk 1.1.6.3 gnu/usr.bin/gdb6/arch/armeb/init.c 1.1.6.2 gnu/usr.bin/gdb6/arch/armeb/tm.h 1.1.6.2 gnu/usr.bin/gdb6/arch/armeb/version.c 1.1.6.2 gnu/usr.bin/gdb6/arch/i386/defs.mk 1.4.4.1 gnu/usr.bin/gdb6/arch/i386/init.c 1.3.6.1 gnu/usr.bin/gdb6/arch/m68000/config.h 1.1.6.2 gnu/usr.bin/gdb6/arch/m68000/defs.mk 1.1.6.2 gnu/usr.bin/gdb6/arch/m68000/init.c 1.1.6.2 gnu/usr.bin/gdb6/arch/m68000/tm.h 1.1.6.2 gnu/usr.bin/gdb6/arch/m68000/version.c 1.1.6.2 gnu/usr.bin/gdb6/arch/m68k/defs.mk 1.1.4.1 gnu/usr.bin/gdb6/arch/m68k/init.c 1.1.4.1 gnu/usr.bin/gdb6/arch/mipseb/config.h 1.3.4.1 gnu/usr.bin/gdb6/arch/mipseb/defs.mk 1.2.6.2 gnu/usr.bin/gdb6/arch/mipseb/init.c 1.2.6.2 gnu/usr.bin/gdb6/arch/mipsel/config.h 1.2.6.3 gnu/usr.bin/gdb6/arch/mipsel/defs.mk 1.2.6.3 gnu/usr.bin/gdb6/arch/mipsel/init.c 1.2.6.3 gnu/usr.bin/gdb6/arch/mipsel/tm.h 1.2.6.2 gnu/usr.bin/gdb6/arch/mipsel/version.c 1.2.6.2 gnu/usr.bin/gdb6/arch/powerpc/defs.mk 1.3.6.1 gnu/usr.bin/gdb6/arch/powerpc/init.c 1.3.6.1 gnu/usr.bin/gdb6/arch/sh3eb/config.h 1.2.2.2 gnu/usr.bin/gdb6/arch/sh3eb/defs.mk 1.2.8.3 gnu/usr.bin/gdb6/arch/sh3eb/init.c 1.1.8.3 gnu/usr.bin/gdb6/arch/sh3eb/nm.h 1.1.8.2 gnu/usr.bin/gdb6/arch/sh3eb/tm.h 1.1.8.2 gnu/usr.bin/gdb6/arch/sh3eb/version.c 1.1.8.2 gnu/usr.bin/gdb6/arch/sh3el/config.h 1.2.2.2 gnu/usr.bin/gdb6/arch/sh3el/defs.mk 1.2.8.3 gnu/usr.bin/gdb6/arch/sh3el/init.c 1.1.8.3 gnu/usr.bin/gdb6/arch/sh3el/nm.h 1.1.8.2 gnu/usr.bin/gdb6/arch/sh3el/tm.h 1.1.8.2 gnu/usr.bin/gdb6/arch/sh3el/version.c 1.1.8.2 gnu/usr.bin/gdb6/arch/sparc/defs.mk 1.2.6.1 gnu/usr.bin/gdb6/arch/sparc/init.c 1.1.6.1 gnu/usr.bin/gdb6/arch/sparc64/defs.mk 1.2.6.1 gnu/usr.bin/gdb6/arch/sparc64/init.c 1.1.6.1 gnu/usr.bin/gdb6/arch/vax/config.h 1.1.6.2 gnu/usr.bin/gdb6/arch/vax/defs.mk 1.1.6.2 gnu/usr.bin/gdb6/arch/vax/init.c 1.1.6.2 gnu/usr.bin/gdb6/arch/vax/tm.h 1.1.6.2 gnu/usr.bin/gdb6/arch/vax/version.c 1.1.6.2 gnu/usr.bin/gdb6/arch/x86_64/defs.mk 1.2.6.1 gnu/usr.bin/gdb6/arch/x86_64/init.c 1.1.6.1 gnu/usr.bin/gdb6/bfd/arch/armeb/bfd.h 1.1.6.2 gnu/usr.bin/gdb6/bfd/arch/armeb/bfdver.h 1.1.6.2 gnu/usr.bin/gdb6/bfd/arch/armeb/config.h 1.1.6.2 gnu/usr.bin/gdb6/bfd/arch/armeb/defs.mk 1.1.6.2 gnu/usr.bin/gdb6/bfd/arch/m68000/bfd.h 1.1.6.2 gnu/usr.bin/gdb6/bfd/arch/m68000/bfdver.h 1.1.6.2 gnu/usr.bin/gdb6/bfd/arch/m68000/config.h 1.1.6.2 gnu/usr.bin/gdb6/bfd/arch/m68000/defs.mk 1.1.6.2 gnu/usr.bin/gdb6/bfd/arch/mipsel/bfd.h 1.1.6.2 gnu/usr.bin/gdb6/bfd/arch/mipsel/bfdver.h 1.1.6.2 gnu/usr.bin/gdb6/bfd/arch/mipsel/config.h 1.1.6.2 gnu/usr.bin/gdb6/bfd/arch/mipsel/defs.mk 1.1.6.2 gnu/usr.bin/gdb6/bfd/arch/sh3eb/bfd.h 1.1.8.3 gnu/usr.bin/gdb6/bfd/arch/sh3eb/bfdver.h 1.1.8.2 gnu/usr.bin/gdb6/bfd/arch/sh3eb/config.h 1.1.8.2 gnu/usr.bin/gdb6/bfd/arch/sh3eb/defs.mk 1.1.8.3 gnu/usr.bin/gdb6/bfd/arch/sh3el/bfd.h 1.1.8.3 gnu/usr.bin/gdb6/bfd/arch/sh3el/bfdver.h 1.1.8.2 gnu/usr.bin/gdb6/bfd/arch/sh3el/config.h 1.1.8.2 gnu/usr.bin/gdb6/bfd/arch/sh3el/defs.mk 1.1.8.3 gnu/usr.bin/gdb6/bfd/arch/vax/bfd.h 1.1.6.2 gnu/usr.bin/gdb6/bfd/arch/vax/bfdver.h 1.1.6.2 gnu/usr.bin/gdb6/bfd/arch/vax/config.h 1.1.6.2 gnu/usr.bin/gdb6/bfd/arch/vax/defs.mk 1.1.6.2 gnu/usr.bin/gdb6/gdb/Makefile 1.5.2.1.2.2 gnu/usr.bin/gdb6/gdbtui/Makefile 1.2.6.1 gnu/usr.bin/gdb6/libiberty/arch/armeb/config.h 1.1.6.2 gnu/usr.bin/gdb6/libiberty/arch/armeb/defs.mk 1.1.6.2 gnu/usr.bin/gdb6/libiberty/arch/m68000/config.h 1.1.6.2 gnu/usr.bin/gdb6/libiberty/arch/m68000/defs.mk 1.1.6.2 gnu/usr.bin/gdb6/libiberty/arch/mipsel/config.h 1.1.6.2 gnu/usr.bin/gdb6/libiberty/arch/mipsel/defs.mk 1.1.6.2 gnu/usr.bin/gdb6/libiberty/arch/sh3eb/config.h 1.1.8.2 gnu/usr.bin/gdb6/libiberty/arch/sh3eb/defs.mk 1.1.8.2 gnu/usr.bin/gdb6/libiberty/arch/sh3el/config.h 1.1.8.2 gnu/usr.bin/gdb6/libiberty/arch/sh3el/defs.mk 1.1.8.2 gnu/usr.bin/gdb6/libiberty/arch/vax/config.h 1.1.6.2 gnu/usr.bin/gdb6/libiberty/arch/vax/defs.mk 1.1.6.2 gnu/usr.bin/gdb6/opcodes/arch/armeb/config.h 1.1.6.2 gnu/usr.bin/gdb6/opcodes/arch/armeb/defs.mk 1.1.6.2 gnu/usr.bin/gdb6/opcodes/arch/m68000/config.h 1.1.6.2 gnu/usr.bin/gdb6/opcodes/arch/m68000/defs.mk 1.1.6.2 gnu/usr.bin/gdb6/opcodes/arch/mipsel/config.h 1.1.6.2 gnu/usr.bin/gdb6/opcodes/arch/mipsel/defs.mk 1.1.6.2 gnu/usr.bin/gdb6/opcodes/arch/sh3eb/config.h 1.1.8.2 gnu/usr.bin/gdb6/opcodes/arch/sh3eb/defs.mk 1.1.8.3 gnu/usr.bin/gdb6/opcodes/arch/sh3el/config.h 1.1.8.2 gnu/usr.bin/gdb6/opcodes/arch/sh3el/defs.mk 1.1.8.3 gnu/usr.bin/gdb6/opcodes/arch/vax/config.h 1.1.6.2 gnu/usr.bin/gdb6/opcodes/arch/vax/defs.mk 1.1.6.2 gnu/usr.bin/gdb6/readline/arch/armeb/config.h 1.1.6.2 gnu/usr.bin/gdb6/readline/arch/armeb/defs.mk 1.1.6.2 gnu/usr.bin/gdb6/readline/arch/m68000/config.h 1.1.6.2 gnu/usr.bin/gdb6/readline/arch/m68000/defs.mk 1.1.6.2 gnu/usr.bin/gdb6/readline/arch/mipsel/config.h 1.1.6.2 gnu/usr.bin/gdb6/readline/arch/mipsel/defs.mk 1.1.6.2 gnu/usr.bin/gdb6/readline/arch/sh3eb/config.h 1.1.8.2 gnu/usr.bin/gdb6/readline/arch/sh3eb/defs.mk 1.1.8.2 gnu/usr.bin/gdb6/readline/arch/sh3el/config.h 1.1.8.2 gnu/usr.bin/gdb6/readline/arch/sh3el/defs.mk 1.1.8.2 gnu/usr.bin/gdb6/readline/arch/vax/config.h 1.1.6.2 gnu/usr.bin/gdb6/readline/arch/vax/defs.mk 1.1.6.2 gnu/usr.bin/gdb6/sim/arch/mipseb/cconfig.h 1.1.2.1 gnu/usr.bin/gdb6/sim/arch/mipseb/config.h 1.1.2.1 gnu/usr.bin/gdb6/sim/arch/mipseb/defs.mk 1.1.2.1 gnu/usr.bin/gdb6/sim/arch/mipsel/cconfig.h 1.1.2.1 gnu/usr.bin/gdb6/sim/arch/mipsel/config.h 1.1.2.1 gnu/usr.bin/gdb6/sim/arch/mipsel/defs.mk 1.1.2.1 lib/libkvm/kvm_sparc64.c 1.10.18.2 lib/libpthread/pthread.c 1.48.6.4 lib/libpthread/pthread_barrier.c 1.6.18.1 lib/libpthread/pthread_cond.c 1.18.12.2 lib/libpthread/pthread_debug.h 1.8.18.1 lib/libpthread/pthread_int.h 1.34.4.5 lib/libpthread/pthread_lock.c 1.14.6.1 lib/libpthread/pthread_mutex.c 1.22.4.2 lib/libpthread/pthread_run.c 1.18.12.4 lib/libpthread/pthread_rwlock.c 1.13.6.2 lib/libpthread/pthread_sa.c 1.37.6.5 lib/libpthread/pthread_sig.c 1.47.4.8 lib/libpthread/pthread_sleep.c 1.7.6.2 lib/libpthread/sem.c 1.9.6.2 lib/libpthread/arch/sh3/pthread_md.h 1.3.6.1 regress/lib/libpthread/resolv/Makefile 1.1.12.1 regress/lib/libpthread/sigrunning/Makefile 1.1.2.1 regress/lib/libpthread/sigrunning/sigrunning.c 1.1.2.1 share/mk/bsd.own.mk 1.489.4.3 sys/arch/amd64/amd64/locore.S 1.18.14.1 sys/arch/amd64/amd64/machdep.c 1.44.2.3.2.1 sys/arch/amd64/conf/kern.ldscript 1.1.70.1 sys/arch/cats/conf/Makefile.cats.inc 1.17.30.1 sys/arch/shark/conf/Makefile.shark.inc 1.6.30.1 sys/arch/sparc64/conf/kern.ldscript 1.7.26.2 sys/arch/sparc64/conf/kern32.ldscript 1.6.26.2 sys/arch/sparc64/include/kcore.h 1.4.92.2 sys/arch/sparc64/sparc64/locore.s 1.232.4.4 sys/arch/sparc64/sparc64/machdep.c 1.193.4.3 sys/arch/sparc64/sparc64/pmap.c 1.184.2.1.2.4 sys/conf/newvers.sh 1.42.26.2 sys/kern/kern_sa.c 1.87.4.11 sys/kern/kern_synch.c 1.173.4.2 sys/sys/savar.h 1.20.10.2 tools/gdb/Makefile 1.9.4.1 tools/gdb/mknative-gdb 1.1.6.1 pullup the wrstuden-fixsa CVS branch to netbsd-4: toolchain/35540 - GDB 6 support for pthreads. port-sparc64/37534 - ktrace firefox gives kernel trap 30: data access expection GDB changes: - delete gdb53 - enable gdb6 on all architectures - add support for amd64 crash dumps - add support for sparc64 crash dumps - add support for /proc pid to executable filename for all archs - enable thread support for all architectures - add a note section to kernels to all platforms - support detection/unwinding of signals for most architectures. - Fix PTHREAD_UCONTEXT_TO_REG / PTHREAD_REG_TO_UCONTEXT on sh3. - Apply fix from binutils-current so that sparc gdb can be cross built on a 64bit host. SA/pthread changes: Pre-allocate memory needed for event delivery. Eliminates dropped interrupts under load. Deliver intra-process signals to running threads Eliminate some deadlock scenarios Fix intra-process signal delivery when delivering to a thread waiting for signals. Makes afs work again!
sync with head.
Remove clause 3 and 4 from TNF licenses
file pthread_lock.c was added on branch christos-time_t on 2008-04-28 20:23:02 +0000
Remove clause 3 and 4 from TNF licenses
sync with HEAD
machine/lock.h, not sys/lock.h
For PR bin/37347: - Override __libc_thr_init() instead of using our own constructor. - Add pthread__getenv() and use instead of getenv(). This is used before we are up and running and unfortunatley getenv() takes locks. Other changes: - Cache the spinlock vectors in pthread__st. Internal spinlock operations now take 1 function call instead of 3 (i386). - Use pthread__self() internally, not pthread_self(). - Use __attribute__ ((visibility("hidden"))) in some places. - Kill PTHREAD_MAIN_DEBUG.
sync with HEAD
Check in changes to locking behavior. pthread__sched() now takes a parameter indicating if the run queue is already locked. Useful in cases where we already hold pthread__runqueue_lock. pthread__suspend() now requires callers explicitly lock pthread__runqueue_lock so we avoid issues with locking order regarding pt_statelock. Adjsut our lock hierarchy. pthread__runqueue_lock is now above pt_statelock, triggering the above adjustments. Adjust a lot of routines as a result. Also move pt_siglock way up in the hierarchy, making pthread__kill() not violate locking. Add a few extra locks to the list. Adjust a botch in how pthread_join() used pthread-spintrylock(). pthread_cancel() now correctly walks up the locks with thread->pt_sleeplock. We can't just lock it, as it points to a lock in the top locking rung. So try locking, and if it fails, unlock and re-lock. Add code to cope with the target thread not being in the expected state (which was on a blocked queue) after we get all the locks. Add comments to describe what's going on in places that I got confused. Now that pt_statelock is lower in the locking order than pthread__runqueue_lock, we can explicitly lock a thread's state before we take it off the run queue. Adjust sched_yield() accordingly and add some locking calls that were commented out before (as they'd have been locking violations). pthread_next(): now that we can lock the state lock while holding the run queue lock, do so. Set a thread's state to PT_STATE_RUNNING before we pull it off the run queue. Since we always are going to switch to it, set pt_vpid and pt_lastlwp while setting the state. pthread_next callers now _don't_ set these values. pthread__kill(): grab pthread__runqueue_lock before target->pt_statelock. If we want to target a thread that is on a blocked queue, do the pthread_spintrylock() dance. Unlock all three locks we're running around with, lock target->pt_sleeplock, then re-lock them all. After we lock, make sure that the thread's still on a blocked queue before proceeding. If it's not, either exit (if we wanted to wake out of sigtimedwait()) or start it all over. If the thread has gone live, it may have blocked our signal and it'd be quite weird to get a signal you'd disabled, just because the signaller had been running before you blocked it.
Drop PTHREAD__NSPINS back from 1000 to 64. Setting the waiters bits and preparing to sleep on a mutex are slow in relative terms, so this allows us to recover from short lock holds without blocking, while not wasting too much time on longer holds.
Kill PTHREAD_SPIN_DEBUG - it's not must use with 1:1.
Resurrect the function pointers for lock operations and allow each architecture to provide asm versions of the RAS operations. We do this because relying on the compiler to get the RAS right is not sensible. (It gets alpha wrong and hppa is suboptimal) Provide asm RAS ops for hppa. (A slightly different version) reviewed by Andrew Doran.
Mostly fix the restartable atomic sequences by reversing the sense of the lock check and test for return value. At least alpha looks broken me and some are sub-optimal. "Looks good to me" from ad.
Merge nick-csl-alignment.
- Don't take the mutex's spinlock (ptr_interlock) in pthread_cond_wait(). Instead, make the deferred wakeup list a per-thread array and pass down the lwpid_t's that way. - In pthread_cond_wait(), take the mutex before dealing with early wakeup. In this way there should never be contention on the CV's spinlock if the app follows POSIX rules (there should only be contention on the user-provided mutex). - Add a port of the kernel's rwlocks. The rwlock's spinlock is only taken if there is contention. This is enabled where atomic ops are available. Right now that is only i386 and amd64 because I don't have other hardware to test with. It's trivial to add stubs for other architectures as long as they have compare-and-swap. When we have proper atomic ops the old rwlock code can be removed. - Add a new mutex implementation that's similar to the kernel's mutexes, but uses compare-and-swap to maintain the waiters list, so no spinlocks are involved. Same caveats apply as for the rwlocks.
If a libpthread internal spinlock is held, nanosleep() for a tick instead of yielding. This is a nasty band-aid but with many threads, looping over sched_yield() wastes a huge amount of CPU time. It would be nice to have a way to temporarily disable preemption, but it turns out that's yet another no-brain concept that has been patented and the patent holder seems to be suing people lately. Another alternative is probably to have kernel-assisted spinlocks.
Sync with HEAD.
Minor correction for debug code and a cosmetic change.
Trim fat off libpthread internal spinlock operations. Makes a mesurable improvement across the board.
- Reinitialize the absolute minimum when recycling user thread state. Chops another ~10% off create/join in a loop on i386. - Disable low level debugging as this is stable. Improves benchmarks across the board by a small percentage. Uncontested mutex acquire and release in a loop becomes about 8% quicker. - Minor cleanup.
Sync with HEAD.
Simplify the pthread__simple_lock_try RAS.
Some significant performance improvements, and a fix for a race with pthread detach/join. - Make mutex acquire spin for a short time, as done with spinlocks. - Make the number of spins controllable with the env var PTHREAD_NSPINS. - Reduce the amount of time that libpthread internal spinlocks are held. - Rely more on the barrier effects of park/unpark to avoid taking spinlocks. - Simplify the locking around pthreads and the global queues. - Align per-thread sync data on a 128 byte boundary. - Offset thread stacks by a small amount to try and reduce cache thrash.
file pthread_lock.c was added on branch matt-mips64 on 2007-08-04 13:37:50 +0000
Some significant performance improvements, and a fix for a race with pthread detach/join. - Make mutex acquire spin for a short time, as done with spinlocks. - Make the number of spins controllable with the env var PTHREAD_NSPINS. - Reduce the amount of time that libpthread internal spinlocks are held. - Rely more on the barrier effects of park/unpark to avoid taking spinlocks. - Simplify the locking around pthreads and the global queues. - Align per-thread sync data on a 128 byte boundary. - Offset thread stacks by a small amount to try and reduce cache thrash.
Initial work on provided correctly aligned __cpu_simple_lock_t for hppa and first attempt at adapting i386 to the changes. More to come.
- Test+branch is usually cheaper than making an indirect function call, so avoid making them. - When parking an LWP on a condition variable, point the hint argument at the mutex's waiters queue. Chances are we will be awoken from that later.
Cosmetic and minor debugging changes.
Remove the PTHREAD_SA option. If M:N threads is reimplemented it's better off done with a seperate library.
On x86, issue the pause instruction while spinning.
Fix bugs with and improve upon previous.
Conditionalised support for 1:1 threads. Needs associated kernel changes and more work to be useful.
Lint warning police -- don't use `//' for comments in C code.
Add some additional assertions and debugging printf()s.
It appears that <sys/lock.h> requires <sys/types.h>, so include that as well.
add libpthread part of concurrency support for SA on MP systems - enable concurrency according to environment variable PTHREAD_CONCURRENCY - add idle VP wakeup if there are additional jobs and idle VPs - make reidlequeue per VP - enable spinning for locks - fix race condition in alarm processing - fix race condition in mutex locking - make debugging output line buffered and add VP prefix to debug lines
Use the new RAS_*() macros.
Uppercase CPU, plural is CPUs.
; may be a comment character in assembly, use \n as a separator instead. This instance spotted by Martin Husemann.
Both pthread__lock_ras_start and pthread__lock_ras_end need to be explicitly declared global in the asm() statements for the benefit of SH5 binutils. Otherwise, the assembler/linker (I haven't figured out which) botches the SHmedia bit when generating GOT references for these symbols in the shared version of the library. Ok'd by Nathan.
add __RCSID()
Adapt to pthread__assert() and remove local debug toggle.
pthread__lock_ras_start and pthread__lock_ras_end need to be declared as function pointers, not character arrays, for the benefit of platforms (e.g. SH5) where the two types are quite distinct.
de-lint
Merge the nathanw_sa branch.
Add support for using RAS lock primitives on uniprocessors where RAS is available.
Log lock counts in debug messages.
Use PTHREAD_SPIN_DEBUG here instead of PTHREAD_SA_DEBUG. Add some checks, conditional on PTHREAD_SPIN_DEBUG, that the spinlock count is positive. Bail out manually instead of calling abort(), because abort() will call signal functions, which will try to use spinlocks....
Whitespace.
Revert 1.1.2.7 (don't switch if we're an upcall) and the assertion in 1.1.2.6 that encountering a locked spinlock is a bug. Since upcalls can hold spinlocks (signal system, recycle lock, alarm queue, condition variable interlocks via alarm queue callbacks) it is possible that an upcall that has itself been preempted will try to acquire a spinlock that is held by another thread in the lock-resolution code. In this case, the proper thing to do is to transfer control via the preempted-while-spinning code, rather than raising an assertion failure. This will permit the other thread to make forward progress in its critical region, after which this upcall will run again and can aquire the spinlock
Whitespace.
Implement POSIX spinlock functions.
Efficency tweak: don't take preemption-jumps out of switch routines if we're an upcall; the handler will just continue us at the same point anyway until we finish our business.
pt_spin_t -> pthread_spin_t. Add some debug logging and assertions.
pthread__switch() no longer needs to be implemeted in assembler, and doesn't have a lock parameter.
Reduce excessive header inclusion.
Note copyright. Standardize RCS IDs.
Add pthread_lockinit().
The beginnings of a scheduler activations-based pthread library.
file pthread_lock.c was initially added on branch nathanw_sa.