Commit Graph

562 Commits

Author SHA1 Message Date
peter
db8830bc2d Clean out the leftovers from the i386_set_gsbase() TLS conversion.
Like on libthr, there is an i386_set_gsbase() stub implementation here
to avoid libc.so.5 issues.  This should likely be a weak symbol and I
expect this will be fixed soon.

Approved by:	re
2005-06-29 23:15:36 +00:00
davidxu
fab6f17360 Fix off-by-one nanosecond in macro TIMESPEC_ADD.
Reviewed by: deischen
Approved by: re (dwhite)
MFC after  : 4 days
2005-06-22 22:35:49 +00:00
peter
408a98eda0 Remove the special _amd64_set_gsbase() code for #ifdef COMPAT_32BIT, now
that the amd64 kernel implements i386_get/set_gsbase().  All the rest of
the ldt backwards compat code should go away soon.
2005-04-26 20:41:48 +00:00
peter
03d84df307 Use the i386_set_gsbase() syscall if it is implemented in the kernel.
This is a little hairy here because the allocation and usage of this
functionality is split into two places in libpthread.
2005-04-14 00:13:20 +00:00
cognet
c7b04f713a Use the new atomic_cmpset_32(). 2005-04-07 22:06:05 +00:00
davidxu
17f1ca4d9b Eliminate plt relocation for kse_switchin. 2005-03-21 23:10:35 +00:00
delphij
55c4c85b99 Change the spin lock logic to a reasonable one. We should spin when
the lock is held by other thread, but not when nobody owns it.  According
to deischen@, this part of code will never be hit in our threads
library, since it does not use locks without wait/wakeup functions.

Spotted by:	mingyanguo via ChinaUnix.net forum
Reviewed by:	deischen
2005-02-27 17:45:55 +00:00
cognet
23a2642656 Bring in a more healthy version of the libpthread for arm, which uses
ARM_TP_ADDRESS.
2005-02-26 19:06:49 +00:00
deischen
d249e2f25d Somewhere along the line, tick accumulation for SA threads was
changed to use the statclock.  Make sure we calculate the value
of a tick correctly in userland.

Noticed by:	Kazuaki Oda <kaakun at highway dot ne dot jp>
2005-02-18 16:07:05 +00:00
deischen
80b24bb8d5 Set the default guardsize and stacksize in the default thread
attribute when the library is initialized.
2005-02-15 15:02:11 +00:00
deischen
b082404539 Increase the default stacksizes:
32-bit		64-bit
main thread	  2MB		  4MB
other threads	  1MB		  2MB
2005-02-13 18:38:06 +00:00
deischen
8fe8e68e76 Don't panic when sigsuspend is interrupted by a cancellation.
PR:	75273
2004-12-19 23:23:43 +00:00
deischen
a5b13ff571 Use a generic way to back threads out of wait queues when handling
signals instead of having more intricate knowledge of thread state
within signal handling.

Simplify signal code because of above (by David Xu).

Use macros for libpthread usage of pthread_cleanup_push() and
pthread_cleanup_pop().  This removes some instances of malloc()
and free() from the semaphore and pthread_once() implementations.

When single threaded and forking(), make sure that the current
thread's signal mask is inherited by the forked thread.

Use private mutexes for libc and libpthread.  Signals are
deferred while threads hold private mutexes.  This fix also
breaks www/linuxpluginwrapper; a patch that fixes it is at
http://people.freebsd.org/~deischen/kse/linuxpluginwrapper.diff

Fix race condition in condition variables where handling a
signal (pthread_kill() or kill()) may not see a wakeup
(pthread_cond_signal() or pthread_cond_broadcast()).

In collaboration with:	davidxu
2004-12-18 18:07:37 +00:00
peter
09f7cb0cec i386_set_ldt() is not available when running 32 bit binaries on amd64
kernels.  Use the recently exposed direct-set routines instead.  This is
only activated for when we compile i386 support libraries on amd64.
2004-11-06 03:35:51 +00:00
peter
1028f02dbd Cosmetic tweaks to reduce diffs to the i386 counterpart. 2004-11-06 03:33:19 +00:00
cognet
2310011fe2 Partial support of KSE for arm. 2004-11-05 23:49:21 +00:00
davidxu
de118d09d1 Save cancelflags in signal frame, this fixes a problem that
a thread in pthread_cond_wait handled a signal can no longer
be canceled.

Reviewed by: deischen
2004-11-01 10:49:34 +00:00
green
63795987cf Make pthread_mutex_trylock(3) return EBUSY on failure, as all software
packages expect and seems to be most correct according to the slightly-
ambiguous standards.

MFC after:		1 month
Corroborated by:	POSIX <http://tinyurl.com/4uvub>
Reviewed by: 		silence on threads@
2004-10-31 05:03:50 +00:00
ru
5db2b9d5b3 For variables that are only checked with defined(), don't provide
any fake value.
2004-10-24 15:33:08 +00:00
davidxu
a4118f925e Check unhandled signals before thread marks itself as DEAD,
this reduces chances of signal losting problem found by
Peter Holm <peter@holm.cc>
2004-10-23 23:37:54 +00:00
davidxu
df721e35be 1. Move thread list flags into new separate member, and atomically
put DEAD thread on GC list, this closes a race between pthread_join
   and thr_cleanup.
2. Introduce a mutex to protect tcb initialization, tls allocation and
   deallocation code in rtld seems no lock protection or it is broken,
   under stress testing, memory is corrupted.

Reviewed by: deischen
patch partly provided by: deischen
2004-10-23 23:28:36 +00:00
davidxu
261287ba18 Decrease reference count if we won't use the thread, this avoids memory
leak under some cases.
2004-10-21 03:42:24 +00:00
davidxu
7e9cf9f934 if system scope thread didn't set timeout, don't call clock_gettime syscall
before and after sleeping.

Reviewed by: deischen
2004-10-08 22:57:30 +00:00
davidxu
c4a10c9c77 Use PTHREAD_SCOPE_SYSTEM to decide what should be done. 2004-10-07 14:23:15 +00:00
davidxu
3b8ee1c512 Follow kernel change, restore signal mask correctly by using a command
of kse_thr_interrupt.
2004-10-07 13:52:18 +00:00
davidxu
0a270f4e6a Allocate red zone and stack space together and then split red zone from
allocated space, orignal code left red zone unallocated, but those space
can be allocated by user code, and result was providing no protection.
2004-10-06 08:11:07 +00:00
deischen
e06ce725da Add a wrapper for execve(). The exec'd process must be started with
the signal mask and pending signals of the calling thread.  These
are stored in userland in libpthread.

There is a small race condition in this patch which could cause
problems if a signal arrives after setting the (kernel) signal
mask and before exec'ing.  The thread's set of pending signals
also are not yet installed in the exec'd process.  Both of these
will be corrected with the addition of a special syscall.

Reported & Tested by:	Joost Bekkers <joost at jodocus dot org>
Reviewed by:	julian, davidxu
2004-09-26 06:50:15 +00:00
cognet
e06c72a787 _tcb_ctor takes two args. 2004-09-24 13:02:30 +00:00
ssouhlal
650224c287 Make sure we don't call _thr_start_sig_daemon() when SYSTEM_SCOPE_ONLY is defined. This makes libpthread usable on powerpc.
Approved by:	grehan (mentor), deischen
2004-09-24 06:36:31 +00:00
davidxu
8eb09c15b9 Add missing brackets. It was committed from wrong tree. 2004-08-26 02:41:01 +00:00
davidxu
a4dbc4af0d gcc -O2 cleanup. tested for a long time.
Reviewed by: deischen
2004-08-25 23:42:40 +00:00
davidxu
f62c438c72 Pull debug symbols in for statically linked binary.
Reviewed by: desichen
2004-08-21 11:49:19 +00:00
davidxu
776807c108 Fix compile, s/tp_dtv/tp_tdv/g. 2004-08-16 14:07:38 +00:00
grehan
a14d72d426 Bring PPC up to date with latest TLS changes. 2004-08-16 05:41:39 +00:00
davidxu
4872917430 1. Add macro DTV_OFFSET to calculate dtv offset in tcb.
2. Export symbols needed by debugger.
2004-08-16 03:27:29 +00:00
davidxu
62ead65343 Add a file to collection all symbols will be needed by debugger. 2004-08-16 03:25:07 +00:00
dfr
4dd05c8c57 Add TLS support for i386 and amd64. 2004-08-15 16:28:05 +00:00
deischen
0340faafa1 As long as we have a knob to force system scope threads, why not have
a knob to force process scope threads.  If the environment variable
LIBPTHREAD_PROCESS_SCOPE is set, force all threads to be process
scope threads regardless of how the application creates them.  If
LIBPTHREAD_SYSTEM_SCOPE is set (forcing system scope threads), it
overrides LIBPTHREAD_PROCESS_SCOPE.

        $ # To force system scope threads
        $ LIBPTHREAD_SYSTEM_SCOPE=anything threaded_app
        $ # To force process scope threads
        $ LIBPTHREAD_PROCESS_SCOPE=anything threaded_app
2004-08-12 12:12:12 +00:00
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
5d24033b92 Let debugger check signal, make SIGINFO works. 2004-07-13 22:52:11 +00:00