Commit Graph

566 Commits

Author SHA1 Message Date
David Xu
0e17930dd7 If a thread in critical region got a synchronous signal, according current
signal handling mode, there is no chance to handle the signal, something
must be wrong in the library, just call kse_thr_interrupt to dump its core.
I have the code for a long time, but forgot to commit it.
2003-11-09 00:37:14 +00:00
David Xu
38a53c6206 Use THR lock instead of KSE lock to avoid scheduler be blocked in spinlock.
Reviewed by: deischen
2003-11-08 06:07:04 +00:00
Daniel Eischen
7a1192c1d3 style(9)
Reviewed by:	bde
2003-11-05 18:19:24 +00:00
Daniel Eischen
94db4dd759 Don't declare the malloc lock; use the declaration provided in libc.
Noticed by:	bde
2003-11-05 18:18:45 +00:00
David Xu
dfde783410 Add pthread_atfork() source code. Dan forgot to commit this file. 2003-11-05 03:42:10 +00:00
Daniel Eischen
4c1123c1c0 Add an implementation for pthread_atfork().
Aside from the POSIX requirements for pthread_atfork(), when
fork()ing, take the malloc lock to keep malloc state consistent
in the child.

Reviewed by:	davidxu
2003-11-04 20:04:45 +00:00
Daniel Eischen
d6b826bac7 Add the ability to reinitialize libpthread's internal FIFO-queueing
locks.

Reviewed by:	davidxu
2003-11-04 20:01:38 +00:00
Daniel Eischen
15a06fd231 Add the ability to reinitialize a spinlock (libc/libpthread
internal lock, not a pthread spinlock).

Reviewed by:	davidxu
2003-11-04 19:59:22 +00:00
Daniel Eischen
264978955e s/foo()/foo(void)/
Add a blank line after a variable declaration.
2003-11-04 19:58:12 +00:00
Daniel Eischen
dc17710e7c Libpthread uses the convention that all of its (non-weak) symbols
begin with underscores and provide weak definitions without
underscores.  Make the pthread spinlock conform to this convention.
2003-11-04 19:56:12 +00:00
Daniel Eischen
ee574ccc3e Add the ability to reinitialize a mutex (internally, not a userland
API).

Reviewed by:	davidxu
2003-11-04 19:53:32 +00:00
Peter Wemm
d1a499ad2a Use amd64_set_fsbase() instead of calling sysarch() directly. 2003-10-23 06:12:57 +00:00
Daniel Eischen
5bb9c67cc7 This test relies on the concurrency level being 1; make it so. 2003-10-20 04:23:49 +00:00
Peter Wemm
eaa9864401 Update context code for my last ABI breakage of mcontext. I'm worried
about the fpu code here.  It should be using fxsave/fxrstor instead of
saving/restoring the control word.  The SSE registers are used a lot in
gcc generated code on amd64.  I'm not sure how this all fits together
though.
2003-10-17 16:30:09 +00:00
Daniel Eischen
077af0a4b4 Don't forget to initialize the fake tcb when the kcb is allocated. 2003-10-12 16:50:45 +00:00
Daniel Eischen
1f2215bcc4 Reverse the order of the first two arguments to _sparc64_enter_uts().
The first argument is the UTS function, the second argument is the
first argument to the UTS function.  Who's on first.
2003-10-09 20:52:17 +00:00
Daniel Eischen
97576c1c61 Convert a couple of hardcoded values to constants. Make thr_getcontext()
return 0 when called the first time, and return 1 when resumed by
thr_setcontext().
2003-10-09 14:48:09 +00:00
Daniel Eischen
203a51090b Add preliminary sparc64 support to libpthread. This does not
yet work, but hopefully someone familiar with the sparc64
port can pick up the reins.

Submitted by:	jake
With mods by:	deischen
2003-10-09 02:32:28 +00:00
David Xu
3128827980 Fix some comments for last commit. 2003-10-08 00:30:38 +00:00
David Xu
6e812b65c6 Complete cancellation support for M:N threads, check cancelling flag when
thread state is changed from RUNNING to WAIT state and do some cancellation
operations for every cancellable state.

Reviewed by: deischen
2003-10-08 00:20:50 +00:00
David Xu
eb0fa623b7 Use thread lock instead of scheduler lock to eliminate lock contention
for all wrapped syscalls under SMP.

Reviewed by: deischen
2003-10-08 00:17:13 +00:00
Daniel Eischen
833d1871ba Fix a logic error; use beq to check for a register being NULL, not bne. 2003-10-02 20:51:30 +00:00
Ruslan Ermilov
ce5508abbe Correct the library name. 2003-10-02 19:19:07 +00:00
Ken Smith
9afe2022ac - Remove error code that can't be returned (and original description
was not proper English)

PR:             docs/57434
Approved:       blackend (mentor)
Reviewed by:    deischen
2003-10-02 18:30:15 +00:00
David Xu
28e2ce478d Only generate code for _LCK_ASSERT if _LCK_DEBUG is defined. 2003-10-02 03:24:26 +00:00
David Xu
ee74732c91 When concurrency level is reduced and a kse is exiting, make sure no other
threads are still referencing the kse by migrating them to initial kse.

Reviewed by: deischen
2003-09-29 06:25:04 +00:00
David Xu
bd193b8ba7 Remove unused variable. 2003-09-28 13:47:29 +00:00
Marcel Moolenaar
ed74e02776 Relink libc_r.a, libc_r.so and libc_r_p.so from libthr to libkse.
On ia64, where there's no libc_r at all, libkse is now the default
thread library by virtue of these links.

The reasons for this change are:
1. libkse is slated to become the default thread library anyway,
2. active development and maintenance is only present for libkse,
3. GNOME and KDE, both in the process of being supported on ia64,
   work better with KSE; even on ia64.
2003-09-27 23:27:19 +00:00
David Xu
90c6d14eb1 Add __volatile keyword. 2003-09-26 11:59:04 +00:00
Marcel Moolenaar
2dd4819fe6 s/ia64/alpha/g 2003-09-26 06:53:54 +00:00
David Xu
58effe49ae pthread API should return error code in return value not in errno.
Reviewed by: deischen
2003-09-25 13:53:49 +00:00
David Xu
a551fe8dc1 If syscall failed, restore old sigaction and return error to thread. 2003-09-25 06:23:40 +00:00
David Xu
3d10572d1a As comments in _mutex_lock_backout state, only current thread
can clear the pointer to mutex, not the thread doing mutex
handoff. Because _mutex_lock_backout does not hold scheduler
lock while testing THR_FLAGS_IN_SYNCQ and then reading mutex
pointer, it is possible mutex owner begin to unlock and
handoff the mutex to the current thread, and mutex pointer
will be cleared to NULL before current thread reading it, so
current thread will end up with deferencing a NULL pointer,
Fix the race by making mutex waiters to clear their mutex pointers.
While I am here, also save inherited priority in mutex for
PTHREAD_PRIO_INERIT mutex in mutex_trylock_common just like what
we did in mutex_lock_common.
2003-09-24 12:52:57 +00:00
David Xu
cc640f7aaa Free thread name memory if there is. 2003-09-23 04:02:23 +00:00
David Xu
4841159528 Save and restore timeout field for signal frame just like what we did
for interrupted field.
Also in _thr_sig_handler, retrieve current signal mask from kernel not
from ucp, the later is pre-unioned mask, not current signal mask.
2003-09-22 14:40:36 +00:00
David Xu
b1f054a092 Fix FPU state restoring bug by jumping to right position. 2003-09-22 14:34:02 +00:00
David Xu
5dd6159cd4 Print waitset correctly. 2003-09-22 00:40:23 +00:00
Marcel Moolenaar
302e193264 Make KSE_STACKSIZE machine dependent by moving it from thr_kern.c to
pthread_md.h. This commit only moves the definition; it does not
change it for any of the platforms. This more easily allows 64-bit
architectures (in particular) to pick a slightly larger stack size.
2003-09-19 23:28:13 +00:00
Marcel Moolenaar
aec40a4c57 _ia64_break_setcontext() now takes a mcontext_t. While here, define
THR_SETCONTEXT as PANIC(). The THR_SETCONTEXT macro is currently not
used, which means that the definition we had could be wrong, overly
pessimistic or unknowingly right. I don't like the odds...

The new _ia64_break_setcontext() and corresponding kernel fixes make
KSE mostly usable. There's still a case where we don't properly
restore a context and end up with a NaT consumption fault (typically
an indication for not handling NaT collection points correctly),
but at least now mutex_d works...
2003-09-19 23:00:28 +00:00
Marcel Moolenaar
492eea0dcd Stop using the setcontext() syscall to restore an async context.
Instead use the break instruction with an immediate specially
created for us.
2003-09-19 22:54:05 +00:00
David Xu
68c1e83721 pthread api should return error code in return value, not in errno. 2003-09-18 12:19:28 +00:00
David Xu
0f5297f5c3 Fix a typo. Also turn on PTHREAD_SCOPE_SYSTEM after fork(). 2003-09-16 02:03:39 +00:00
Daniel Eischen
a87a12715c Remove a comment that questioned why the size of the FPU
state for amd64 was twice as large as necessary.  Peter
recently fixed this, so the comment no longer applies.

Also, since the size of struct mcontext changed, adjust
the threads library version of get&set context to match.

FYI, any change layout/size change to any arch's struct
mcontext will likely need some minor changes in libpthread.
2003-09-16 00:00:53 +00:00
David Xu
e153cba635 Fix bogus comment and assign sigmask in critical region, use
SIG_CANTMASK to remove unmaskable signal masks.
2003-09-15 00:08:48 +00:00
David Xu
b9fe6075a0 Fix a bogus comment, sigmask must be maintained correctly,
it will be inherited in pthread_create.
2003-09-15 00:06:46 +00:00
David Xu
a3a398b57d 1. Allocating and freeing lock related resource in _thr_alloc and _thr_free
to avoid potential memory leak, also fix a bug in pthread_create, contention
   scope should be inherited when PTHREAD_INHERIT_SCHED is set, and also check
   right field for PTHREAD_INHERIT_SCHED, scheduling inherit flag is in sched_inherit.
2. Execute hooks registered by atexit() on thread stack but not on scheduler
   stack.
3. Simplify some code in _kse_single_thread by calling xxx_destroy functions.

Reviewed by: deischen
2003-09-14 22:52:16 +00:00
David Xu
06925cea04 When invoking an old style signal handler, use true traditional BSD style to
invoke signal handler.

Reviewed by: deischen
2003-09-14 22:42:39 +00:00
David Xu
89c6390006 Respect POSIX specification, a value return from pthread_attr_getguardsize
should be a value past to pthread_attr_setguardsize, not a rounded up value.
Also fix a stack size matching bug in thr_stack.c, now stack matching code
uses number of pages but not bytes length to match stack size, so for example,
size 512 bytes and size 513 bytes should both match 1 page stack size.

Reviewed by: deischen
2003-09-14 22:39:44 +00:00
David Xu
a0efa60dc9 Avoid garbage bits in c_flags by direct assigning value.
Reviewed by: deischen
2003-09-14 22:33:32 +00:00
David Xu
c5f1d9f6f8 If user is seting scope process flag, clear PTHREAD_SCOPE_SYSTEM bit
accordingly.

Reviewed by: deischen
2003-09-14 22:32:28 +00:00