History log of /netbsd-src/lib/libpthread/pthread_lock.c (Results 1 – 25 of 35)
Revision Date Author Comments
# 568eb77e 10-Apr-2022 riastradh <riastradh@NetBSD.org>

pthread: Nix trailing whitespace.


# 7adb4107 12-Feb-2022 riastradh <riastradh@NetBSD.org>

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 t

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.)

show more ...


# ce099b40 28-Apr-2008 martin <martin@NetBSD.org>

Remove clause 3 and 4 from TNF licenses


# b43749fd 05-Jan-2008 ad <ad@NetBSD.org>

machine/lock.h, not sys/lock.h


# 15e9cec1 13-Nov-2007 ad <ad@NetBSD.org>

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 unfortunatle

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.

show more ...


# 50590878 04-Oct-2007 ad <ad@NetBSD.org>

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,

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.

show more ...


# af8ed8ad 24-Sep-2007 ad <ad@NetBSD.org>

Kill PTHREAD_SPIN_DEBUG - it's not must use with 1:1.


# d32ed989 24-Sep-2007 skrll <skrll@NetBSD.org>

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

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.

show more ...


# f9577d3a 17-Sep-2007 skrll <skrll@NetBSD.org>

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.


# 9fdaf800 10-Sep-2007 skrll <skrll@NetBSD.org>

Merge nick-csl-alignment.


# 8ccc6e06 07-Sep-2007 ad <ad@NetBSD.org>

- 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()

- 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.

show more ...


# c67dc640 07-Sep-2007 ad <ad@NetBSD.org>

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

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.

show more ...


# cc383c57 16-Aug-2007 ad <ad@NetBSD.org>

Minor correction for debug code and a cosmetic change.


# d9adedd7 16-Aug-2007 ad <ad@NetBSD.org>

Trim fat off libpthread internal spinlock operations. Makes a mesurable
improvement across the board.


# b8833ff5 16-Aug-2007 ad <ad@NetBSD.org>

- 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
ac

- 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.

show more ...


# 50fa8db4 04-Aug-2007 ad <ad@NetBSD.org>

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

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.

show more ...


# a5070151 24-Mar-2007 ad <ad@NetBSD.org>

- 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.

- 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.

show more ...


# da3cc0ff 05-Mar-2007 ad <ad@NetBSD.org>

Cosmetic and minor debugging changes.


# de213816 02-Mar-2007 ad <ad@NetBSD.org>

Remove the PTHREAD_SA option. If M:N threads is reimplemented it's
better off done with a seperate library.


# 1bcb6087 02-Mar-2007 ad <ad@NetBSD.org>

On x86, issue the pause instruction while spinning.


# ded26025 24-Dec-2006 ad <ad@NetBSD.org>

Fix bugs with and improve upon previous.


# 1ac6a89b 23-Dec-2006 ad <ad@NetBSD.org>

Conditionalised support for 1:1 threads. Needs associated kernel changes
and more work to be useful.


# f5798452 17-Mar-2005 jwise <jwise@NetBSD.org>

Lint warning police -- don't use `//' for comments in C code.


# 75a94788 06-Jan-2005 mycroft <mycroft@NetBSD.org>

Add some additional assertions and debugging printf()s.


# 99f69b6c 14-Mar-2004 he <he@NetBSD.org>

It appears that <sys/lock.h> requires <sys/types.h>, so include that as well.


12