Commit Graph

623 Commits

Author SHA1 Message Date
davidxu
be9db1f7cb Check debugger suspending flag for system scope thread.
Reviewed by: deischen
2004-08-08 22:42:11 +00:00
deischen
628d407e84 Add a way to force 1:1 mode for libpthread. To do this, define
LIBPTHREAD_SYSTEM_SCOPE in the environment.

You can still force libpthread to be built in strictly 1:1 by
adding -DSYSTEM_SCOPE_ONLY to CFLAGS.  This is kept for archs
that don't yet support M:N mode.

Requested by:   rwatson
Reviewed by:    davidxu
2004-08-07 15:15:38 +00:00
davidxu
6f2afa324d s/TMDF_DONOTRUNUSER/TMDF_SUSPEND/g
Dicussed with: deischen
2004-08-03 02:23:06 +00:00
davidxu
7ef444d527 Save context in kernel fashion, so it can be restored by
kse_switchin syscall.
2004-07-31 14:18:26 +00:00
davidxu
7dea99e896 Remove unused field. 2004-07-31 14:14:55 +00:00
davidxu
ab04048f48 Macro optimize, this increases context switch speed about 2% on my
athlon64 machine.
2004-07-31 01:53:21 +00:00
grehan
2de38b8015 PPC MD bits for KSE. Runs test cases OK. Crippled to 1:1 mode for
the time being.
2004-07-19 12:19:04 +00:00
marcel
9514d00916 Don't include lock.h and pthread_md.h when we're being included by
libthread_db. Both headers are included seperately.
2004-07-18 04:22:01 +00:00
davidxu
d2c424e30c Copy lwp id to thread mailbox. 2004-07-14 00:58:53 +00:00
davidxu
b241de2523 Call kse_switchin to switch context when being debugged. 2004-07-13 22:54:23 +00:00
davidxu
16b35fe1ee Remove unused symbols. 2004-07-13 22:53:56 +00:00
davidxu
19d6019657 Export necessary symbols to debugger. 2004-07-13 22:52:53 +00:00
davidxu
5d24033b92 Let debugger check signal, make SIGINFO works. 2004-07-13 22:52:11 +00:00
davidxu
4eaa7c96d8 If _libkse_debug is not zero, activate thread mode. 2004-07-13 22:51:03 +00:00
davidxu
2e3100b547 Add code to support thread debugging.
1. Add global varible _libkse_debug, debugger uses the varible to identify
   libpthread. when the varible is written to non-zero by debugger, libpthread
   will take some special action at context switch time, it will check
   TMDF_DOTRUNUSER flags, if a thread has the flags set by debugger, it won't
   be scheduled, when a thread leaves KSE critical region, thread checks
   the flag, if it was set, the thread relinquish CPU.

2. Add pq_first_debug to select a thread allowd to run by debugger.

3. Some names prefixed with _thr are renamed to _thread prefix.

which is allowed to run by debugger.
2004-07-13 22:49:58 +00:00
davidxu
404e9eb472 kse_switchin ABI was changed in kernel. 2004-07-12 07:41:01 +00:00
davidxu
c72d8a4de4 Check pending signals, if there is signal will be unblocked by
sigsuspend, thread shouldn't wait, in old code, it may be
ignored.
When a signal handler is invoked in sigsuspend, thread gets
two different signal masks, one is in thread structure,
sigprocmask() can retrieve it, another is in ucontext
which is a third parameter of signal handler, the former is
the result of sigsuspend mask ORed with sigaction's sa_mask
and current signal, the later is the mask in thread structure
before sigsuspend is called. After signal handler is called,
the mask in ucontext should be copied into thread structure,
and becomes CURRENT signal mask, then sigsuspend returns to
user code.

Reviewed by: deischen
Tested by: Sean McNeil <sean@mcneil.com>
2004-06-12 07:40:01 +00:00
tjr
bdd43780eb Avoid clobbering the red zone when running on the new context's stack in
_amd64_restore_context().
2004-06-07 21:25:16 +00:00
cognet
0ff01bbcf8 Arm bits for libpthread. It has no chances to work and should be considered
as stubs.
2004-05-14 12:21:29 +00:00
deischen
6920f21350 After forking and initializing the library to single-threaded
mode (where the forked thread is the one and only thread and
is marked as system scope), set the system scope flag before
initializing the signal mask.  This prevents trying to use
internal locks that haven't yet been initialized.

Reported by:	Dan Nelson <dnelson at allantgroup.com>
Reviewed by:	davidxu
2004-04-08 23:16:21 +00:00
davidxu
12db4373da Fix a POSIX conformance bug. POSIX says sigwait should return error number
in return value not in errno.
2004-03-17 02:12:19 +00:00
bde
1e78a65d3a Fixed a misspelling of 0 as NULL. 2004-03-14 05:27:26 +00:00
cperciva
371e76013c style cleanup: Remove duplicate $FreeBSD$ tags.
These files had tags after teh copyright notice,
inside the comment block (incorrect, removed),
and outside the comment block (correct).

Approved by:	rwatson (mentor)
2004-02-10 20:45:28 +00:00
cperciva
81f9b2b83a style cleanup: Remove duplicate $FreeBSD$ tags.
These files had tags after the copyright notice,
inside the comment block (incorrect, removed),
and outside the comment block (correct).

Approved by:	rwatson (mentor)
2004-02-10 20:42:33 +00:00
deischen
72c7aa83c9 Add sem_timedwait to the symbol map, otherwise the libc version will
get used.
2004-02-10 05:36:09 +00:00
deischen
ba84b16ebb Add cancellation point to sem_wait() and sem_timedwait() for pshared
semaphores.  Also add cancellation cleanup handlers to keep semaphores
in a consistent state.

Submitted in part by:	davidxu
Reviewed by:		davidxu
2004-02-06 15:20:56 +00:00
davidxu
c03701303f libkse was renamed to libpthread. 2004-02-05 02:55:20 +00:00
deischen
aea62cb1af Provide a userland version of non-pshared semaphores and add cancellation
points to sem_wait() and sem_timedwait().  Also make sem_post signal-safe.
2004-02-03 05:50:07 +00:00
marcel
288be8413e Now that libpthread is the default threading library, remove the
compatibility link from libc_r to libpthread (previously a link
from libc_r to libkse).
2004-01-31 05:05:45 +00:00
deischen
674bc2cc3f Change libkse back to libpthread and make it the default
thread library for i386, amd64, and ia64.  For alpha
and sparc64 the library is not changed and remains libkse,
and links are installed so that libpthread -> libc_r.

The gcc -pthread option will be changed in a separate
commit so that it links to -lpthread instead of -lc_r.

Approved by:	re@
2004-01-30 12:13:17 +00:00
davidxu
47933921d0 Return EPERM if mutex owner is not current thread but it tries to
unlock the mutex, old code confuses some programs when it returns EINVAL.

Noticed by: bland
2004-01-17 03:09:57 +00:00
ru
57b6bbbf56 Have a single set of POSIX threads man pages. The LIBRARY section
of each manpage lists libraries that have corresponding interfaces
implemented.

Prodded by:	threads
Reviewed by:	deischen
2004-01-14 21:44:26 +00:00
deischen
b5d5c1e2e6 Add a simple work-around for deadlocking on recursive read locks
on a rwlock while there are writers waiting.  We normally favor
writers but when a reader already has at least one other read lock,
we favor the reader.  We don't track all the rwlocks owned by a
thread, nor all the threads that own a rwlock -- we just keep
a count of all the read locks owned by a thread.

PR:	24641
2004-01-08 15:37:09 +00:00
davidxu
f3e2bcfe4c Kernel now supports per-thread sigaltstack, follow the change to
enable sigaltstack for scope system thread.
2004-01-03 02:40:27 +00:00
davidxu
32583a78cf Return error code in errno, not in return value. 2004-01-02 00:38:42 +00:00
davidxu
abb0f21d58 Fix a typo. 2004-01-02 00:27:30 +00:00
ru
af0a846800 Removed MLINKS to nonimplemented/nonexistent functions. 2003-12-30 17:13:20 +00:00
ru
00755078ab Merge from libc_r: document pthread_attr_[gs]etstack(). 2003-12-30 17:08:23 +00:00
ru
67877ecd48 Pull some changes (mostly cosmetic) from libc_r manpages
in preparation for the merge.
2003-12-30 14:59:10 +00:00
davidxu
d6b72f0aa3 Forgot to commit this file for last commit. :( 2003-12-29 23:33:51 +00:00
davidxu
8d750bfb1b Implement sigaltstack() as per-threaded. Current only scope process thread
is supported, for scope system process, kernel signal bits need to be
changed.

Reviewed by: deischen
Tested on  : i386 amd64 ia64
2003-12-29 23:21:09 +00:00
davidxu
d2abf7e6f9 Correctly retrieve sigaction flags. 2003-12-28 12:20:04 +00:00
davidxu
7b3cca8521 Replace a comment with more accurated one, memory heap is now protected by
new fork() wrapper.
2003-12-19 13:24:54 +00:00
davidxu
c7be5e14dc Code clean up, remove unused MACROS and function prototypes. 2003-12-19 12:57:08 +00:00
deischen
1f8c5c54fd accept() returns a file descriptor when it succeeds which is very
likely to be non-zero.  When leaving the cancellation point, check
the return value against -1 to see if cancellation should be
checked.  While I'm here, make the same change to connect() just
to be consisitent.

Pointed out by: davidxu
2003-12-09 23:40:27 +00:00
deischen
ed86f0d4d5 Remove an unused struct definition. 2003-12-09 15:18:40 +00:00
deischen
212e86fbe9 Add cancellation points for accept() and connect(). 2003-12-09 15:16:27 +00:00
davidxu
7813286b21 Use mutex instead of low level thread lock to implement spinlock, this
avoids signal to be blocked when otherwise it can be handled.
2003-12-09 02:37:40 +00:00
davidxu
22c52834eb Rename _thr_enter_cancellation_point to _thr_cancel_enter, rename
_thr_leave_cancellation_point to _thr_cancel_leave, add a parameter
to _thr_cancel_leave to indicate whether cancellation point should be
checked, this gives us an option to not check cancallation point if
a syscall successfully returns to avoid any leaks, current I have
creat(), open() and fcntl(F_DUPFD) to not check cancellation point
after they sucessfully returned.

Replace some members in structure kse with bit flags to same some
memory.

Conditionally compile THR_ASSERT to nothing if _PTHREAD_INVARIANTS is
not defined.

Inline some small functions in thr_cancel.c.

Use __predict_false in thr_kern.c for some executed only once code.

Reviewd by: deischen
2003-12-09 02:20:56 +00:00
davidxu
3f57a77355 More reliably check timeout for pthread_mutex_timedlock. 2003-12-09 00:52:28 +00:00