including (interface borrowed from FreeBSD) pthread_attr_get_np().
Remove a few limit-indicating symbols that don't actually need to be defined
(and if they did need to be defined, it would be in limits.h, not here).
and use it preferentially to a value in pt_uc, clearing it once on the new
stack. Move stores into pt_uc back to before the stack switch; storing
after the stack switch opened a one-instruction race condition where an upcall
that had just started a chain could be preempted again, and would bomb when
restarted due to its pt_uc not yet having been updated. Now that pt_trapuc
is what the upcall code writes to, it is safe to store to pt_uc before
switching stacks.
Remove obsolete pt_sleepuc code.
in switchto targets and vitims, and print it in debug messages (including
indication of whether a context is trap or user context).
Remove obsolete pt_sleepuc handling.
by the kernel. Separating this from pt_uc makes it possible to avoid a race
condition in pt_uc management near the STACK_SWITCH part of pthread__switch()
and pthread__locked_switch().
Remove pt_sleepuc pointer, which was made obsolete by the previous round of
UC juggling but still present in the assembler files.
still possible for multiple threads to write into the same space, but
they shouldn't be able to corrupt the write pointer in the process.
Also, check for pointer-lapping a bit more carefully in the wrap
vs. non-wrap case.
thread from the continuation chain: Not only must it have released all
spinlocks, but it must have signaled completion by finishing pthread__switch
or by having stored into pt_switchto.
Together with the previous pthread_switch.S changes, this fixes a couple of
crasehes caused by race conditions in the examination and use of pt_next,
and by switching to empty pt_switchtouc's.
* In switch-away cases, write PT_SWITCHTO last (after PT_SWITCHTOUC), so
that pthread__resolve_locks() doesn't see an empty SWITCHTOUC value. This
also permits pthread__resolve_locks() to use the presence of PT_SWITCHTO
as a sign that the thread has done all of its necessary chain work.
* Make the return-point of pthread__switch global and visible, so that its
address can be compared to the PC of a thread, again as a sign that its
chain-work is done.
(other architectures in progress, after they get the *previous* asm fix...)
1. add new pthread__abort() and change pthread_assert(0) to it.
2. put constcond in the right place (in the macro).
3. no space after pthread__assert macro.
accumulate half of the total number. There are too many ways for
the SA subsystem to deadlock waiting for stacks that userland has no
reason to recycle.
* Consolidate switchto handling in pthread_resolve_locks().
* Add code to re-chain the preempting parents of switchtos.
* Tweak debuglog output in a couple of cases.
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.
time) to pthread__start() (called on the first call of
pthread_create()), so that there's no opportunity for a fork() to
clear the per-process timer.
Problem pointed out by a test program from Mihai CHELARU on
current-users.
opposed to internal errors. The setting of the PTHREAD_ERRORMODE
environment variable determines the runtime behavior. Valid settings
are "ignore", "abort", and "print". The default is currently "abort".
officially have undefined behavior, from returning an error code to raising
an assertion failure.
Also, don't bother to explicitly test for (illegal) null pointers and return
an error; they'll bomb out soon enough.
front of the sleep queue rather than the back. This is more
cache-friendly behavior and within the (lack of) constraints on wakeup
ordering imposed on equal-priority threads.
mangling results.
Fixes regression in test yield2, dating to 2003/1/2 when
pthread__locked_switch() was changed to not store the saved-context
pointer until after switching stacks.
Note to self: regression tests exist to be run.
* pthread_attr_getname_np()
* pthread_attr_setname_np()
* pthread_getname_np()
* pthread_setname_np()
In addition to being query'able by the application (for log messages, etc.),
it is intended that these names can show up in the debugger.
Reviewed by nathanw.
PT_FLAG_CS_DISABLED in pt_flags.
Prevents cancellation cleanup handlers from thinking that they've been
canceled and exiting mid-handler. Problem spotted by Matt Thomas.
to sleep a lot, and there's no need for each such thread to consume kernel
resources.
(accidentally checked the pthread.c part of this in yesterday; no reason
not to finish the job)
pthread_cond_timedwait() is called before any threads have been
created and the SA infrastructure is up and running.
Addresses PR lib/20139.
XXX probably need to do this for all of the pthread_*_timedlock()
functions, too.
over a sleep queue and puts everything on the run queue. This permits
the iteration to be inside the acquisition of the run queue spinlock,
avoiding repetitive acquire/release cycles.
pthread_cond_broadcast(): use double-checked locking to avoid
pthread__self() and pthread_spinlock() when signaling or broadcasting
on a condition variable with no waiters.
* Use a double-checked locking technique to avoid taking
the interlock in pthread_mutex_unlock().
* In pthread_mutex_lock() and pthread_mutex_trylock(), only store the
stack pointer, not the thread ID, in ptm_owner. Do the translation
to a thread ID in the slow-lock, errorcheck, and recursive mutex
cases rather than in the common path.
* Juggle where pthread__self() is called, to move it out of the fast path.
Overall, this means that neither pthread_self() nor
pthread_spin[un]lock() are used in the course of locking and unlocking
an uncontested mutex. Speeds up the fast path by 40-50%, and
eliminates about 98% of spinlocks used by a couple of large threaded
applications.
(Still a GET_MUTEX_PRIVATE() in the fast path... perhaps the type
should be in the main body of the mutex).
* Implement pthread_kill().
* Return the old thread mask, not the old process mask, in our
interpositioned sigaction call.
* Refer to _NSIG, not NSIG.
* Gut pthread_sigmask(). It was handling a lot of corner cases that
weren't legal anyway. Handle unblocked signals with a new
pthread__kill_self() routine (also used by pthread_kill()).
* Be more consistent with locking around pt_sigacts[].
switch statement, and moving upcall-type-specific code into that switch.
Beneficial side effect: don't manipulate a statelock before lock resolution
occurs.
by adding a generation number to the barrier structure and incrementing it
when the barrier fires.
XXX this is an ABI change for anything using barriers, but the library is
new enough and nothing in the tree uses barriers so I'm going to let it
slide. Using the private data pointer for a field that will always be present
would be excessive.
- Signal handlers now simply continue executing the current thread,
rather than trying to put themselves back on the queue that they came
from, which was rather fragile. As a result, all callers of
pthread__block() must be prepared to handle spurious wakeups.
- When a signal arrives for a thread that is blocked in the kernel,
note this in another field in pthread_st and set a flag. Process the
signal and set up the trampoline for the handler *after* the thread
unblocks, so that both the trampoline and the returned state from
the kernel are preserved.
- Factor out some code into a pthread__deliver_signal() routine;
the signal-taking code in pthread_sigmask() should be able to use this
soon.
This is still gross, and there are still some terrible MP issues lurking here,
but progress crawls along.
if the corresponding TSD entry is empty.
Cuts down lock/unlock pairs for this operation from 256 to the number
of active TSD entries; sicne this is done when every thread exits, it saves
many total lock/unlock pairs.