Commit Graph

156 Commits

Author SHA1 Message Date
martin
f546abe798 Catch up with Nathan's changes to other archs. 2003-06-17 23:18:48 +00:00
nathanw
876d7e7eec Dodge a potential race condition in pthread__debuglog_printf(). It's
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.
2003-06-16 21:24:48 +00:00
martin
aba86b525b Catch up with changes Nathan did to other archs. 2003-06-15 17:11:36 +00:00
scw
7d221cb560 Apply Nathan's switch-away fix and previous save-PT_UC from new stack fix. 2003-06-13 08:07:03 +00:00
scw
04f197eae9 Apply Nathan's switch-away fix and previous save-PT_UC from new stack fix.
Compile-tested only.
2003-06-13 07:45:17 +00:00
nathanw
4bd45b7b3b Oops, that's switch_return_point, not locked_return_point. The perils
of cut-and-paste.
2003-06-12 23:19:27 +00:00
nathanw
aa6f5de228 STACKSPACE of 16 is too small, given the use of CALLFRAME_SIZ;
increase to match.
2003-06-12 23:01:17 +00:00
nathanw
eb6ba6fbef Apply switch-away fix and previous save-PT_UC from new stack fix. 2003-06-12 23:00:28 +00:00
fvdl
1a31b8db4d Apply Nathan's switch-away fix. 2003-06-12 22:03:18 +00:00
nathanw
b43f1c7405 In pthread__resolve_locks(), change the conditions for removing a normal
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.
2003-06-12 21:49:42 +00:00
nathanw
f866ba061d Two fixes:
* 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...)
2003-06-12 21:46:03 +00:00
nathanw
edc79413b1 Don't need to set the MSR field here; _INITCONTEXT_U_MD() takes care
of that where necessary.
2003-06-12 19:09:45 +00:00
thorpej
e714d726a6 $NetBSD$, not $Header$. 2003-06-08 06:44:28 +00:00
nathanw
877f89857f Tiny bit of infrastructure for ABI-supported thread-ID storage. 2003-06-06 21:06:07 +00:00
nathanw
1809ee5c2c Fix typo in comment. 2003-06-06 19:35:03 +00:00
nathanw
33314cffa1 Make infrastructure for man pages. 2003-06-03 21:34:00 +00:00
nathanw
5581819638 Man pages for libpthread, adapted from FreeBSD by Stephen Degler. 2003-06-03 21:33:06 +00:00
nathanw
380bb3a8b0 Man pages for libpthread, written by Stephen Degler. 2003-06-03 21:31:36 +00:00
christos
dc1665b80b Add pthread_attr_getstack{,size,addr} needed by jdk 2003-06-02 16:59:26 +00:00
christos
143f5a277a pass lint:
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.
2003-05-27 15:24:24 +00:00
christos
4e29fa8276 add missing notreached lint comment. 2003-05-27 15:22:56 +00:00
nathanw
5faa7f5bef * Recycle upcall stacks as soon as possible rather than waiting to
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.
2003-05-26 19:41:03 +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
scw
644aebe258 Duh. s/PIC_PROLOGUE/PIC_EPILOGUE/ 2003-05-16 22:40:56 +00:00
nathanw
baa073280b Separately report unlocking an unlocked mutex and unlocking a mutex
owned by another thread.
2003-05-16 21:28:26 +00:00
wiz
76907a433e Fix typo in comment. 2003-05-15 19:16:37 +00:00
nathanw
a06836c083 Remove an unnecessary test in pthread_getspecific(). 2003-05-15 19:13:24 +00:00
petrov
cf5b7785eb Add missing include and copyright. 2003-05-07 01:21:13 +00:00
nathanw
ff14fbf244 Move call to pthread__alarm_init() from pthread_init() (called at load
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.
2003-04-28 17:46:30 +00:00
nathanw
3f6de8d84a Use pthread__error() instead of pthread__abort(). 2003-04-23 19:36:12 +00:00
nathanw
df2772713e Introduce a pthread__error() macro, for detected application errors as
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".
2003-04-23 19:35:47 +00:00
nathanw
b7ac97b866 More agressive assertions. Change a number of detected conditions, which
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.
2003-04-18 21:36:38 +00:00
nathanw
66fc73c7eb Use a __predict_true() in the definition of pthread__assert(). 2003-04-18 21:32:32 +00:00
fvdl
b32287cc19 Catch up with changed struct reg (same as gregs in mcontext now). 2003-04-17 10:13:51 +00:00
nathanw
a74799949a pthread_mutex_trylock(): It's not an error to call trylock() on a
mutex already locked by the calling thread, even for non-recursive
mutexes.
2003-04-16 18:59:12 +00:00
nathanw
008033bb65 When a thread sleeps on a mutex or cv, have it put itself on the
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.
2003-04-16 18:30:43 +00:00
nathanw
8114703654 Fix a fencepost error in writing to the debug buffer. 2003-04-16 17:37:47 +00:00
nathanw
2a4cef11ba When threads are started, register an atfork callback to clear
pthread__started in the child process. This lets sleep() work in the
child, as required by POSIX.
2003-04-07 21:29:48 +00:00
nathanw
45c9543071 Consistently use pthread__assert() rather than err() to assert that
timer_settime() worked, and don't bother calling err() after a
pthread__assert() call.
2003-04-07 19:41:22 +00:00
bjh21
55cecd0f26 NetBSD/acorn26 has used APCS-32 for years, so unifdef -U__APCS_26__. 2003-04-05 23:15:10 +00:00
nathanw
4777259ff2 Don't call pthread__locked_switch() to switch to ourself. Bad stack
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.
2003-04-04 01:08:25 +00:00
scw
52569eab7f Add PIC support. 2003-03-26 22:33:56 +00:00
nathanw
a0628261fe Use pthread__assert() instead of plain assert(), as the latter has
locking issues.
2003-03-20 01:03:52 +00:00
nathanw
a25b9285d9 Add a wrapper for the execve() system call that arranges for the current
thread sigal mask to be propagated into the new process image.
2003-03-14 22:27:34 +00:00
thorpej
04d0b802f7 Include <sys/types> before <sys/lock.h>, shuffle <ucontext.h>. 2003-03-13 19:51:33 +00:00
nathanw
64324a8175 Remove debugging code accidentally committed. 2003-03-11 16:27:38 +00:00
nathanw
16612d0814 * Use a <= comparison rather than a < comparison when searching for
alarms to process.

* Remove a redundant assignment.

* Make a debug message more consistent with the others.
2003-03-11 00:18:36 +00:00
nathanw
37c11910ec Re-enable nanosleep(); kernel bug is squished (kern_time.c:1.67). 2003-03-10 22:16:36 +00:00
lukem
f043c0fb57 add __RCSID() 2003-03-08 08:03:34 +00:00
scw
65e4a59445 Don't use FP instructions when building for m68010. Fixes broken sun2 build.
G/C some unused code.
2003-03-01 11:51:59 +00:00