Commit Graph

33 Commits

Author SHA1 Message Date
martin ce099b4099 Remove clause 3 and 4 from TNF licenses 2008-04-28 20:22:51 +00:00
ad b43749fde1 machine/lock.h, not sys/lock.h 2008-01-05 01:37:35 +00:00
ad 15e9cec117 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.
2007-11-13 15:57:10 +00:00
ad 5059087834 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.
2007-10-04 21:04:32 +00:00
ad af8ed8ad89 Kill PTHREAD_SPIN_DEBUG - it's not must use with 1:1. 2007-09-24 13:56:42 +00:00
skrll d32ed98975 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.
2007-09-24 12:19:39 +00:00
skrll f9577d3ada 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.
2007-09-17 13:25:59 +00:00
skrll 9fdaf800d9 Merge nick-csl-alignment. 2007-09-10 11:34:05 +00:00
ad 8ccc6e060d - 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.
2007-09-07 14:09:27 +00:00
ad c67dc640cd 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.
2007-09-07 00:07:54 +00:00
ad cc383c5771 Minor correction for debug code and a cosmetic change. 2007-08-16 23:37:08 +00:00
ad d9adedd764 Trim fat off libpthread internal spinlock operations. Makes a mesurable
improvement across the board.
2007-08-16 13:54:16 +00:00
ad b8833ff53f - 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.
2007-08-16 12:01:49 +00:00
ad 50fa8db4e4 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.
2007-08-04 13:37:48 +00:00
ad a5070151ae - 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.
2007-03-24 18:51:59 +00:00
ad da3cc0ffcf Cosmetic and minor debugging changes. 2007-03-05 23:30:17 +00:00
ad de2138164c Remove the PTHREAD_SA option. If M:N threads is reimplemented it's
better off done with a seperate library.
2007-03-02 18:53:51 +00:00
ad 1bcb6087a6 On x86, issue the pause instruction while spinning. 2007-03-02 17:34:21 +00:00
ad ded2602507 Fix bugs with and improve upon previous. 2006-12-24 18:39:45 +00:00
ad 1ac6a89b79 Conditionalised support for 1:1 threads. Needs associated kernel changes
and more work to be useful.
2006-12-23 05:14:46 +00:00
jwise f579845294 Lint warning police -- don't use `//' for comments in C code. 2005-03-17 17:23:21 +00:00
mycroft 75a9478818 Add some additional assertions and debugging printf()s. 2005-01-06 17:38:29 +00:00
he 99f69b6c5f It appears that <sys/lock.h> requires <sys/types.h>, so include that as well. 2004-03-14 12:49:31 +00:00
cl f2f106648c 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
2004-03-14 01:19:41 +00:00
thorpej 1cda93b426 Use the new RAS_*() macros. 2004-03-03 21:06:07 +00:00
wiz d20841bb64 Uppercase CPU, plural is CPUs. 2004-02-13 11:36:08 +00:00
kleink 9f0429b6cc ; may be a comment character in assembly, use \n as a separator instead.
This instance spotted by Martin Husemann.
2004-01-19 16:18:33 +00:00
scw 5bd6b99940 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.
2003-05-16 23:37:47 +00:00
lukem f043c0fb57 add __RCSID() 2003-03-08 08:03:34 +00:00
nathanw 53827081be Adapt to pthread__assert() and remove local debug toggle. 2003-02-15 04:37:04 +00:00
scw 04c6e0b141 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.
2003-01-22 13:52:03 +00:00
christos 9631ace572 de-lint 2003-01-18 18:40:52 +00:00
thorpej c62a74e6d5 Merge the nathanw_sa branch. 2003-01-18 10:32:11 +00:00