davidxu
c0f6b35a3a
- Reduce function call overhead for uncontended case.
...
- Remove unused flags MUTEX_FLAGS_* and their code.
- Check validity of the timeout parameter in mutex_self_lock().
2008-05-29 07:57:33 +00:00
imp
b9242ed45b
Commit missing mips libthr support that I thought I'd committed earlier
2008-05-11 05:54:52 +00:00
davidxu
fc58e99cef
Remove libc_r's remnant code.
2008-05-06 07:27:11 +00:00
davidxu
0e9d39ae8f
Use UMTX_OP_WAIT_UINT_PRIVATE and UMTX_OP_WAKE_PRIVATE to save
...
time in kernel(avoid VM lookup).
2008-04-29 03:58:18 +00:00
kris
4a87c82b19
Increase the default MUTEX_ADAPTIVE_SPINS to 2000, after further
...
testing it turns out 200 was too short to give good adaptive
performance.
Reviewed by: jeff
MFC after: 1 week
2008-04-26 13:19:07 +00:00
imp
92f18b23d5
Bring in mips threads support from perforce mips2-jnpr branch.
2008-04-26 12:17:57 +00:00
delphij
6b7d752076
Avoid various shadowed variables. libthr is now almost WARNS=4 clean except
...
for some const dequalifiers that needs more careful investigation.
Ok'ed by: davidxu
2008-04-23 21:06:51 +00:00
davidxu
b794176bc5
Use native rwlock.
2008-04-22 06:44:11 +00:00
davidxu
6a349c6771
_vfork is not in libthr, remove the reference.
2008-04-16 03:19:11 +00:00
davidxu
a1371575f4
don't include pthread_np.h, it is not used.
2008-04-14 08:08:40 +00:00
davidxu
8d9f007088
put THR_CRITICAL_LEAVE into do .. while statement.
2008-04-03 02:47:35 +00:00
davidxu
2d5bf7e6fc
add __hidden suffix to _umtx_op_err, this eliminates PLT.
2008-04-03 02:13:51 +00:00
davidxu
f1df18eb48
Non-portable functions are in pthread_np.h, fix compiling problem.
2008-04-02 11:41:12 +00:00
davidxu
d00a98a4e8
Add pthread_setaffinity_np and pthread_getaffinity_np to libc namespace.
2008-04-02 08:53:18 +00:00
davidxu
aa2019ec00
Remove unused functions.
2008-04-02 08:33:42 +00:00
davidxu
570834290d
Replace function _umtx_op with _umtx_op_err, the later function directly
...
returns errno, because errno can be mucked by user's signal handler and
most of pthread api heavily depends on errno to be correct, this change
should improve stability of the thread library.
2008-04-02 07:41:25 +00:00
davidxu
8d50c29c72
Replace userland rwlock with a pure kernel based rwlock, the new
...
implementation does not switch pointers when it resumes waiters.
Asked by: jeff
2008-04-02 04:32:31 +00:00
davidxu
111802a962
Restore normal pthread_cond_signal path to avoid some obscure races.
2008-04-01 06:23:08 +00:00
davidxu
664ef9f365
return EAGAIN early rather than running bunch of code later, micro optimize
...
static branch prediction.
2008-04-01 00:21:49 +00:00
davidxu
220584ad61
Rewrite rwlock to user atomic operations to change rwlock state, this
...
eliminates internal mutex lock contention when most rwlock operations
are read.
Orignal patch provided by: jeff
2008-03-31 02:55:49 +00:00
ru
0f0375e36a
Remove options MK_LIBKSE and DEFAULT_THREAD_LIB now that we no longer
...
build libkse. This should fix WITHOUT_LIBTHR builds as a side effect.
2008-03-29 17:44:40 +00:00
ru
e8df07e5aa
Compile libthr with warnings.
2008-03-25 13:28:12 +00:00
ru
e2f2131976
Fixed mis-implementation of pthread_mutex_get{spin,yield}loops_np().
...
Reviewed by: davidxu
2008-03-25 09:48:10 +00:00
davidxu
1423f22a4c
Add POSIX pthread API pthread_getcpuclockid() to get a thread's cpu
...
time clock id.
2008-03-22 09:59:20 +00:00
davidxu
8420f5505a
Resolve __error()'s PLT early so that it needs not to be resolved again,
...
otherwise rwlock is recursivly called when signal happens and the __error
was never resolved before.
2008-03-21 02:31:55 +00:00
ru
735c62ce43
pthread_mutexattr_destroy() was accidentally broken in last revision,
...
unbreak it. We should really start compiling this with warnings.
2008-03-20 11:47:08 +00:00
davidxu
8326c06222
Preserve application code's errno in rtld locking code, it attemps to keep
...
any case safe.
2008-03-20 09:35:44 +00:00
davidxu
1bc96ca9dc
Make pthread_mutexattr_settype to return error number directly and
...
conformant to POSIX specification.
Bug reported by: modelnine at modelnine dt org
2008-03-20 08:27:14 +00:00
davidxu
5e11ba1ac4
don't reduce new thread's refcount if current thread can not set cpuset
...
for it, since the new thread will reduce it by itself.
2008-03-19 09:33:07 +00:00
davidxu
a6c50de140
- Trim trailing spaces.
...
- Use a different sigmask variable name to avoid confusing.
2008-03-19 08:13:04 +00:00
davidxu
e846a1612b
if passed thread pointer is equal to current thread, pass -1 to kernel
...
to speed up searching.
2008-03-19 06:38:21 +00:00
davidxu
9dbfb036ab
- Copy signal mask out before THR_UNLOCK(), because THR_UNLOCK() may call
...
_thr_suspend_check() which messes sigmask saved in thread structure.
- Don't suspend a thread has force_exit set.
- In pthread_exit(), if there is a suspension flag set, wake up waiting-
thread after setting PS_DEAD, this causes waiting-thread to break loop
in suspend_common().
2008-03-18 02:06:51 +00:00
davidxu
3da38e35b4
Actually delete SIGCANCEL mask for suspended thread, so the signal will not
...
be masked when it is resumed.
2008-03-16 03:22:38 +00:00
davidxu
19ffe8108d
If a thread is cancelled, it may have already consumed a umtx_wake,
...
check waiter and semphore counter to see if we may wake up next thread.
2008-03-11 03:26:47 +00:00
davidxu
cd00bbaa4b
Fix a bug when calculating remnant size.
2008-03-06 03:24:03 +00:00
davidxu
6b41341850
Don't report death event to debugger if it is a forced exit.
2008-03-06 02:07:18 +00:00
davidxu
5f0ffdddf1
Restore code setting new thread's scheduler parameters, I was thinking
...
that there might be starvations, but because we have already locked the
thread, the cpuset settings will always be done before the new thread
does real-world work.
2008-03-06 01:59:08 +00:00
davidxu
1efa6566c1
Increase and decrease in_sigcancel_handler accordingly to avoid possible
...
error caused by nested SIGCANCEL stack, it is a bit complex.
2008-03-05 07:04:55 +00:00
davidxu
d6c532fa79
Use cpuset defined in pthread_attr for newly created thread, for now,
...
we set scheduling parameters and cpu binding fully in userland, and
because default scheduling policy is SCHED_RR (time-sharing), we set
default sched_inherit to PTHREAD_SCHED_INHERIT, this saves a system
call.
2008-03-05 07:01:20 +00:00
davidxu
b118d117f4
Add more cpu affinity function's symbols.
2008-03-05 06:56:35 +00:00
davidxu
adf8d28a8f
Check actual size of cpuset kernel is using and define underscore version
...
of API.
2008-03-05 06:55:48 +00:00
davidxu
8ead1ed2f9
If a new thread is created, it inherits current thread's signal masks,
...
however if current thread is executing cancellation handler, signal
SIGCANCEL may have already been blocked, this is unexpected, unblock the
signal in new thread if this happens.
MFC after: 1 week
2008-03-04 04:28:59 +00:00
davidxu
e0d98325b4
Include cpuset.h, unbreak compiling.
2008-03-04 03:45:11 +00:00
davidxu
7046a9b037
implement pthread_attr_getaffinity_np and pthread_attr_setaffinity_np.
2008-03-04 03:03:24 +00:00
davidxu
f88b971008
Implement functions pthread_getaffinity_np and pthread_setaffinity_np to
...
get and set thread's cpu affinity mask.
2008-03-03 09:16:29 +00:00
des
c5334cac08
_pthread_mutex_isowned_np(): use a more reliable method; the current code
...
will work in simple cases, but may fail in more complicated ones.
Reviewed by: davidxu
2008-02-14 12:37:58 +00:00
obrien
d3499a87ee
style.Makefile(5)
2008-02-13 05:25:43 +00:00
obrien
d8f894d961
style(9)
2008-02-13 05:12:05 +00:00
des
ddda03a2e0
Yet another pointy hat: when I zapped FBSDprivate_1.1, I forgot to move
...
its contents to FBSDprivate_1.0.
2008-02-06 20:45:46 +00:00
des
f006d1f25a
Remove unnecessary prototype.
2008-02-06 20:43:19 +00:00
des
3086491df6
Convert pthread.map to the format expected by version_gen.awk, and modify
...
the Makefile accordingly; libthr now explicitly uses libc's Versions.def.
MFC after: 2 weeks
2008-02-06 20:25:00 +00:00
des
85a226c62d
Remove incorrectly added FBSDprivate_1.1 namespace, and move symbols which
...
are new in FreeBSD 8 to the appropriate namespace.
2008-02-06 20:20:29 +00:00
des
053e111aba
Per discussion on -threads, rename _islocked_np() to _isowned_np().
2008-02-06 19:34:31 +00:00
des
c089534891
After careful consideration (and a brief discussion with attilio@), change
...
the semantics of pthread_mutex_islocked_np() to return true if and only if
the mutex is held by the current thread.
Obviously, change the regression test to match.
MFC after: 2 weeks
2008-02-04 12:35:23 +00:00
des
72d185548f
Add pthread_mutex_islocked_np(), a cheap way to verify that a mutex is
...
locked. This is intended primarily to support the userland equivalent
of the various *_ASSERT_LOCKED() macros we have in the kernel.
MFC after: 2 weeks
2008-02-03 22:38:10 +00:00
davidxu
9acb5351ab
SYSTEM_SCOPE_ONLY flag is no longer needed, it is the only mode libthr
...
supports.
2008-01-18 04:29:36 +00:00
davidxu
70ef09a695
sem_post() requires to return -1 on error.
2008-01-07 02:26:29 +00:00
davidxu
cbdadd6e3e
call underscore version of pthread_cleanup_pop instead.
2007-12-20 04:40:12 +00:00
davidxu
cd0acadf51
Remove vfork() overloading, it is no longer needed.
2007-12-20 04:32:28 +00:00
davidxu
42e5c27a87
Add function prototypes.
2007-12-17 02:53:11 +00:00
davidxu
5340a5f502
1. Add function pthread_mutex_setspinloops_np to turn a mutex's spin
...
loop count.
2. Add function pthread_mutex_setyieldloops_np to turn a mutex's yield
loop count.
3. Make environment variables PTHREAD_SPINLOOPS and PTHREAD_YIELDLOOPS
to be only used for turnning PTHREAD_MUTEX_ADAPTIVE_NP mutex.
2007-12-14 06:25:57 +00:00
davidxu
50439b0991
Enclose all code for macro ENQUEUE_MUTEX in do while statement, and
...
add missing brackets.
MFC: after 1 day
2007-12-11 08:00:58 +00:00
jasone
600513aa8d
Fix pointer dereferencing problems in _pthread_mutex_init_calloc_cb() that
...
were obscured by pseudo-opaque pthreads API pointer casting.
2007-11-28 00:16:24 +00:00
jasone
21bb948195
Add _pthread_mutex_init_calloc_cb() to libthr and libkse, so that malloc(3)
...
(part of libc) can use pthreads mutexes without causing infinite recursion
during initialization.
2007-11-27 03:16:44 +00:00
davidxu
e24c6a3904
Simplify code, fix a thread cancellation bug in sem_wait and sem_timedwait.
2007-11-23 05:42:52 +00:00
davidxu
df28d4b72f
Reuse nwaiter member field to record number of waiters, in sem_post(),
...
this should reduce the chance having to do a syscall when there is no
waiter in the semaphore.
2007-11-21 06:01:02 +00:00
davidxu
6a4c1655fd
Remove warning level and aliasing restrictions.
2007-11-21 05:29:57 +00:00
davidxu
a0922e4b91
Convert ceiling type to unsigned integer before comparing, fix compiler
...
warnings.
2007-11-21 05:25:27 +00:00
davidxu
e90ed63757
Add some function prototypes.
2007-11-21 05:23:54 +00:00
davidxu
c63688968a
Remove umtx_t definition, use type long directly, add wrapper function
...
_thr_umtx_wait_uint() for umtx operation UMTX_OP_WAIT_UINT, use the
function in semaphore operations, this fixed compiler warnings.
2007-11-21 05:21:58 +00:00
jb
5582e69034
These are the things that the tinderbox has problems with because it
...
doesn't use the default CFLAGS which contain -fno-strict-aliasing.
Until the code is cleaned up, just add -fno-strict-aliasing to the
CFLAGS of these for the tinderboxes' sake, allowing the rest of the
tree to have -Werror enabled again.
2007-11-20 02:07:30 +00:00
marius
af79ab51ec
In _pthread_key_create() ensure that libthr is initialized. This
...
fixes a NULL-dereference of curthread when libstdc+ initializes
the exception handling globals on archs we can't use GNU TLS due
to lack of support in binutils 2.15 (i.e. arm and sparc64), yet,
thus making threaded C++ programs compiled with GCC 4.2.1 work
again on these archs.
Reviewed by: davidxu
MFC after: 3 days
2007-11-06 21:50:43 +00:00
davidxu
c01b764192
Avoid doing adaptive spinning for priority protected mutex, current
...
implementation always does lock in kernel.
2007-10-31 01:50:48 +00:00
davidxu
674cdbbcee
Don't do adaptive spinning if it is running on UP kernel.
2007-10-31 01:44:50 +00:00
davidxu
e199852bb6
Restore revision 1.55, the kris's adaptive mutex type.
2007-10-31 01:37:13 +00:00
kris
9e91eb96b8
Adaptive mutexes should have the same deadlock detection properties that
...
default (errorcheck) mutexes do.
Noticed by: davidxu
2007-10-30 09:24:23 +00:00
davidxu
97a20b1db7
Add my recent work of adaptive spin mutex code. Use two environments variable
...
to tune pthread mutex performance:
1. LIBPTHREAD_SPINLOOPS
If a pthread mutex is being locked by another thread, this environment
variable sets total number of spin loops before the current thread
sleeps in kernel, this saves a syscall overhead if the mutex will be
unlocked very soon (well written application code).
2. LIBPTHREAD_YIELDLOOPS
If a pthread mutex is being locked by other threads, this environment
variable sets total number of sched_yield() loops before the currrent
thread sleeps in kernel. if a pthread mutex is locked, the current thread
gives up cpu, but will not sleep in kernel, this means, current thread
does not set contention bit in mutex, but let lock owner to run again
if the owner is on kernel's run queue, and when lock owner unlocks the
mutex, it does not need to enter kernel and do lots of work to resume
mutex waiters, in some cases, this saves lots of syscall overheads for
mutex owner.
In my practice, sometimes LIBPTHREAD_YIELDLOOPS can massively improve performance
than LIBPTHREAD_SPINLOOPS, this depends on application. These two environments
are global to all pthread mutex, there is no interface to set them for each
pthread mutex, the default values are zero, this means spinning is turned off
by default.
2007-10-30 05:57:37 +00:00
kris
bbfd76f872
Add a new "non-portable" mutex type, PTHREAD_MUTEX_ADAPTIVE_NP. This
...
is also implemented in glibc and is used by a number of existing
applications (mysql, firefox, etc).
This mutex type is a default mutex with the additional property that
it spins briefly when attempting to acquire a contested lock, doing
trylock operations in userland before entering the kernel to block if
eventually unsuccessful.
The expectation is that applications requesting this mutex type know
that the mutex is likely to be only held for very brief periods, so it
is faster to spin in userland and probably succeed in acquiring the
mutex, than to enter the kernel and sleep, only to be woken up almost
immediately. This can help significantly in certain cases when
pthread mutexes are heavily contended and held for brief durations
(such as mysql).
Spin up to 200 times before entering the kernel, which represents only
a few us on modern CPUs. No performance degradation was observed with
this value and it is sufficient to avoid a large performance drop in
mysql performance in the heavily contended pthread mutex case.
The libkse implementation is a NOP.
Reviewed by: jeff
MFC after: 3 days
2007-10-29 21:01:47 +00:00
ru
8ea97e9ef7
- Stop calling libthr alternative as it's now the default
...
threading library.
- Now that libpthread is a symlink, it's no longer possible
to link applications with libpthread and have libmap.conf(5)
select the desired threading library; applications will be
linked to the default threading library, libkse or libthr.
Remove an obsolete paragraph.
- Mention that improvements can be seen compared to libkse.
Reviewed by: deischen, davidxu
2007-10-22 10:13:38 +00:00
davidxu
5523a9bb34
Use macro THR_CLEANUP_PUSH/POP, they are cheaper than pthread_cleanup_push/pop.
2007-10-16 07:46:15 +00:00
davidxu
38b01da7d2
Reverse the logic of UP and SMP.
...
Submitted by: jasone
2007-10-16 07:36:02 +00:00
obrien
a1598920aa
Tweak the handling of "WITHOUT_LIBPTHREAD". Also remove the accidental
...
treatment of 'LIBKSE' as an "old style" knob.
Submitted by: ru
Approved by: re(kensmith)
2007-10-09 23:31:11 +00:00
ru
08a6766d3a
Always install libpthread.* symlinks if at least one of
...
the threading libraries is built. This simplifies the
logic in makefiles that need to check if the pthreads
support is present. It also fixes a bug where we would
build a threading library that we shouldn't have built:
for example, building with WITHOUT_LIBTHR and the default
value of DEFAULT_THREADING_LIB (libthr) would mistakenly
build the libthr library, but not install it.
Approved by: re (kensmith)
2007-10-01 18:29:55 +00:00
davidxu
52bd1282cd
Output error message to STDERR_FILENO.
...
Approved by: re (bmah)
2007-08-07 04:50:14 +00:00
davidxu
abf8c6f8db
Set warning level to 2.
2007-06-08 02:21:13 +00:00
deischen
ff36458e08
Bump library versions in preparation for 7.0.
...
Ok'd by: kan
2007-05-21 02:49:08 +00:00
ru
3be5d73f3d
Fix a logic bug I re-introduced in my patch I sent to Daniel
...
that would cause the selected shared threading library to be
overwritten with its 32-bit version on amd64.
PR: amd64/112509
2007-05-18 12:25:48 +00:00
deischen
7d5de3a8a3
Allow DEFAULT_THREAD_LIB to be set from /etc/src.conf.
...
Submitted by: ru
2007-05-17 04:54:35 +00:00
deischen
bf3a79274d
Enable symbol versioning by default. Use WITHOUT_SYMVER to disable it.
...
Warning, after symbol versioning is enabled, going back is not easy
(use WITHOUT_SYMVER at your own risk).
Change the default thread library to libthr.
There most likely still needs to be a version bump for at least the
thread libraries. If necessary, this will happen later.
2007-05-13 14:12:40 +00:00
davidxu
d97c4f1e52
backout experimental adaptive spinning mutex for product use.
2007-05-09 08:39:33 +00:00
deischen
2a7306fdc5
Use C comments since we now preprocess these files with CPP.
2007-04-29 14:05:22 +00:00
davidxu
2dd85eafce
If a thread who's name is being set is not the current thread, use macros
...
THR_THREAD_LOCK and THR_THREAD_UNLOCK instead, this should fix wrong
lock level problem.
Bug reported by: ed dot maste at gmail dot com
2007-04-05 07:20:31 +00:00
imp
9109b1ceb8
Remove 3rd clause, renumber, ok per email
2007-01-12 07:26:21 +00:00
davidxu
9770c4c640
Insert mutex at tail if it has highest ceiling.
2007-01-05 03:57:11 +00:00
davidxu
dec2b546dd
Oops, don't corrupt the list.
2007-01-05 03:33:47 +00:00
davidxu
190109deab
Check if the PP mutex is recursive, if we have already locked it, place the
...
mutex in right order sorted by priority ceiling.
2007-01-05 03:29:15 +00:00
davidxu
d305995d66
get LIBPTHREAD_ADAPTIVE_SPIN early, so it can be used for some global
...
mutexes.
2006-12-20 05:05:44 +00:00
davidxu
e034ab54f2
Check environment variable PTHREAD_ADAPTIVE_SPIN, if it is set, use
...
it as a default spin cycle count.
2006-12-20 04:43:34 +00:00
davidxu
ca27871833
- Remove variable _thr_scope_system, all threads are system scope.
...
- Rename _thr_smp_cpus to boolean variable _thr_is_smp.
- Define CPU_SPINWAIT macro for each arch, only X86 supports it.
2006-12-15 11:52:01 +00:00
davidxu
26cbb63b3f
Create inline function _thr_umutex_trylock2 to only try one atomic
...
operation, if it is failed, we call syscall directly, this saves
one atomic operation per lock contention.
2006-12-14 13:22:02 +00:00
davidxu
229aca4634
Correctly check failed syscall.
2006-12-12 05:26:39 +00:00
davidxu
fcda4340a4
Move checking for c_has_waiters into low level _thr_ucond_signal and
...
_thr_ucond_broadcast, clear condition variable pointer in cancellation
info after returing from _thr_ucond_wait, since kernel has already
dropped the internal lock, so we don't need to unlock it in cancellation
handler again.
2006-12-12 03:08:49 +00:00
davidxu
33168bd24f
test cancel_pending to save a thr_wake call in some specical cases.
2006-12-06 00:15:35 +00:00
davidxu
b01e86cf0a
_thr_ucond_wait drops lock, we should pick it up again.
2006-12-05 23:46:11 +00:00
davidxu
3f73376426
the c_has_waiters is lazily updated, temporarily disable the false
...
alarm code.
2006-12-05 07:23:58 +00:00
davidxu
f26900460b
Use ucond to implement barrier.
2006-12-05 06:54:25 +00:00
davidxu
f1f5293365
Add _thr_ucond_init().
2006-12-05 06:53:44 +00:00
davidxu
19c999e75f
Tweak _thr_cancel_leave_defer a bit to fix a possible race.
2006-12-05 05:01:57 +00:00
davidxu
5ad129a10a
Fix typo, I was using a wrong header file, and the typo is not detected
...
by compiler.
2006-12-04 14:27:42 +00:00
davidxu
cbb0fd8174
Use kernel provided userspace condition variable to implement pthread
...
condition variable.
2006-12-04 14:20:41 +00:00
davidxu
61e0842016
If a thread was detached, return EINVAL instead, the error code
...
is also returned by pthread_detach() if a thread was already
detached, the error code was already documented:
> [EINVAL] The implementation has detected that the value speci-
> fied by thread does not refer to a joinable thread.
2006-11-28 11:05:31 +00:00
ru
815d860c2f
- When building world WITHOUT_LIBPTHREAD, link libthr to libpthread.
...
- Don't build ngctl(8) and cached(8) if threading libs aren't built.
- Fix various issues in a cached(8) makefile.
2006-11-26 14:36:34 +00:00
davidxu
add205129c
Eliminate atomic operations in thread cancellation functions, it should
...
reduce overheads of cancellation points.
2006-11-24 09:57:38 +00:00
davidxu
cc0840138e
Move code calculating new inherited priority into single function.
2006-11-11 13:33:47 +00:00
davidxu
e8a2970aaf
Don't inherit THR_FLAGS_NEED_SUSPEND for child process, child process
...
only has one thread, setting the flag can cause the thread to be
suspended and no another thread will resume it.
2006-10-14 13:40:08 +00:00
davidxu
653013bedc
o Make _thr_umutex_init a function.
...
o Eliminate unused parameter for some functions.
o Convert type of first parameter to void * for _thr_umtx_wait
and _thr_umtx_wake.
2006-10-13 22:31:00 +00:00
davidxu
4fdad8dba6
Use type pthread_state for thread state.
2006-10-13 12:45:21 +00:00
davidxu
d2c57b7fad
use rtprio_thread system call to get or set thread priority.
2006-09-21 04:21:30 +00:00
davidxu
e83ab88356
Use return value of _thr_umutex_lock instead of using zero.
2006-09-08 09:29:14 +00:00
davidxu
21e4536026
Replace internal usage of struct umtx with umutex which can supports
...
real-time if we want, no functionality is changed.
2006-09-06 04:04:10 +00:00
davidxu
567ba06917
Same as pthread_setschedparam, use sizeof(struct sched_param) instead.
2006-09-05 14:39:06 +00:00
davidxu
5b28602728
Pass correct parameter size.
2006-09-05 14:37:22 +00:00
marcel
d21513035e
Stylize: avoid using a global register variable.
2006-09-01 21:01:11 +00:00
marcel
2d71eb396a
Rename TLS_TP_OFFSET back to TP_OFFSET. The former clashes with rtld.
2006-09-01 06:36:00 +00:00
marcel
1125db3243
Stylize.
2006-09-01 06:15:00 +00:00
marcel
6a1762d589
Stylize.
2006-08-31 23:31:18 +00:00
marcel
5ffd88a18e
TLS fixes:
...
o The TLS pointer (r2) points 0x7000 after the *end* of the TCB.
o _rtld_allocate_tls() gets a pointer to the current TCB, not the
current TLS pointer.
o _rtld_free_tls() gets the size of the TCB structure.
2006-08-31 19:16:47 +00:00
marcel
c088f26c25
Fix harmless bug: sizeof(tcb) equals sizeof(void*) not sizeof(struct tcb).
...
The argument is (currently) not used by _rtld_free_tls().
2006-08-31 19:06:30 +00:00
marcel
4736b1fdce
o Set TP using inline assembly to avoid dead code elimination.
...
o Eliminate _tcb.
2006-08-30 03:31:32 +00:00
davidxu
37473cc569
Remove unused file.
2006-08-29 13:01:23 +00:00
davidxu
faa99f1910
pthread_sigmask is in thr_sig.c, remove this file.
2006-08-28 12:29:54 +00:00
davidxu
b7dde83f82
Kill unused files.
2006-08-28 05:01:31 +00:00
davidxu
58fc7458af
Use umutex APIs to implement pthread_mutex, member pp_mutexq is added
...
into pthread structure to keep track of locked PTHREAD_PRIO_PROTECT mutex,
no real mutex code is changed, the mutex locking and unlocking code should
has same performance as before.
2006-08-28 04:52:50 +00:00
davidxu
77e7cda2cf
Add umutex APIs.
2006-08-28 04:47:27 +00:00
ru
4d582ffe09
Remove alpha left-overs.
2006-08-22 08:03:01 +00:00
davidxu
c8a98491d0
Axe unused member field.
2006-08-08 05:04:43 +00:00
davidxu
cfa46376c7
Get number of CPUs and ignore spin count on single processor machine.
2006-08-08 04:42:41 +00:00
davidxu
5193e44c40
1. Don't override underscore version of aio_suspend(), system(),
...
wait(), waitpid() and usleep(), they are internal versions and
should not be cancellation points.
2. Make wait3() as a cancellation point.
3. Move raise() and pause() into file thr_sig.c.
4. Add functions _sigsuspend, _sigwait, _sigtimedwait and _sigwaitinfo,
remove SIGCANCEL bit in wait-set for those functions, the signal is
used internally to implement thread cancellation.
2006-07-25 12:50:05 +00:00
delphij
36c285d128
Unexpand two TAILQ_FOREACH_SAFE cases.
...
Ok'ed by: davidxu
2006-07-17 09:23:44 +00:00
davidxu
2b1dbc0acb
Caching scheduling policy and priority in userland, a critical but baddly
...
written application is frequently changing thread priority for SCHED_OTHER
policy.
2006-07-13 22:45:19 +00:00
davidxu
19b8418903
Use thr_setscheduler, thr_getscheduler and thr_setschedparam to implement
...
pthread functions.
2006-07-13 06:35:43 +00:00
davidxu
ecacf536b0
Use kernel facilities to support real-time scheduling.
2006-07-12 06:13:18 +00:00
davidxu
f53e1c9383
__error could be called too early before libthr is initialized, test
...
this case and return global varible errno instead.
2006-07-12 03:44:05 +00:00
davidxu
be54fdbbff
Remove unused member.
2006-06-03 00:19:40 +00:00
davidxu
523fcb36a8
Remove unused member field m_queue.
2006-06-02 08:37:01 +00:00
delphij
6e4a34202a
Explicitly request pre-zeroed memory instead of memset'ing our
...
own.
Ok'ed by: davidxu
2006-05-31 00:31:38 +00:00
davidxu
975a6925fe
Add symbol versions: FBSD_1.0 and FBSDprivate.
2006-05-11 07:02:52 +00:00
davidxu
6a9d879cfe
s/long/int.
2006-04-27 08:25:13 +00:00
davidxu
66d0fee031
- Use same priority range returned by kernel's sched_get_priority_min()
...
and sched_get_priority_max() syscalls.
- Remove unused fields from structure pthread_attr.
2006-04-27 08:18:23 +00:00
davidxu
8001df6f90
Remove multiple _get_curthread() calls.
2006-04-23 11:23:37 +00:00
ru
450f399135
Install shared libpthread library into /lib; needed by some
...
/sbin programs.
2006-04-12 19:42:20 +00:00
davidxu
7d0c23506c
Do not check validity of timeout if a mutex can be acquired immediately.
...
Completly drop recursive mutex in pthread_cond_wait and restore recursive
after resumption. Reorganize code to make gcc to generate better code.
2006-04-08 13:24:44 +00:00
davidxu
f921934131
Remove declaration of _thr_initial from MD header file, it is no longer
...
needed.
2006-04-04 03:35:26 +00:00
davidxu
8bff50a485
Simplify _get_curthread() and _tcb_ctor because libc and rtld now
...
already allocate thread pointer space in tls block for initial thread.
Only i386 and amd64 have been done, others still have to be tested.
2006-04-04 03:26:06 +00:00
davidxu
31f2b819c6
WARNS level 4 cleanup.
2006-04-04 02:57:49 +00:00
des
5438ed2ce6
Fix prototype mismatch.
2006-03-28 21:46:55 +00:00
davidxu
255936645e
Remove priority mutex code because it does not work correctly,
...
to make it work, turnstile like mechanism to support priority
propagating and other realtime scheduling options in kernel
should be available to userland mutex, for the moment, I just
want to make libthr be simple and efficient thread library.
Discussed with: deischen, julian
2006-03-27 23:50:21 +00:00
davidxu
4b5909711d
Comment out -g compiler option, found by 'FreeBSD Build Options Survey'.
2006-03-27 05:58:58 +00:00
davidxu
32673f0256
Check cancellation state carefully to see we really need to call
...
_pthread_testcancel(). Preserve errno in _thr_suspend_check().
2006-03-26 01:57:03 +00:00
davidxu
2926ddf5d1
Don't cancel thread if it is in critical region.
2006-03-25 07:03:13 +00:00
davidxu
679e2338c0
Only wake up writer if the lock is free.
2006-03-25 05:14:21 +00:00
davidxu
cba4d932c1
Compile thr_rtld.c
2006-03-25 05:00:54 +00:00
davidxu
6ee36bbb6d
Add locking support for rtld.
2006-03-25 04:49:07 +00:00
davidxu
eb9bdb4259
set an upper limit for thread structures which can be allocated.
2006-03-24 04:34:06 +00:00
davidxu
020594940d
Set default contention scope to system.
2006-03-20 03:14:14 +00:00
ru
5f8b6d3c5a
Convert NO_PROFILE and NO_LIB32 to new style.
2006-03-18 21:37:05 +00:00
davidxu
d119bdaa7a
Remove mqueue and timer, now they are in librt.
2006-03-08 23:47:04 +00:00
deischen
e586a0042e
Add some more pthread stubs so that librt can use them.
...
The thread jump table has been resorted, so you need to
keep libc, libpthread, and libthr in sync.
Submitted by: xu
2006-03-05 18:10:28 +00:00
davidxu
6fdf2b7d81
Reimplement mutex_init to get rid of compile warning.
2006-02-28 06:06:19 +00:00
davidxu
bb43155dbb
Disable POSIX SIGEV_THREAD notification support, soon we will have a common
...
library which can be reused both for libthr and libpthread.
2006-02-22 02:52:22 +00:00
davidxu
91fda076fb
Read cycle count before sending signal, this fixes a userland thread
...
suspension bug.
MFC after: 3 days
2006-02-20 09:02:40 +00:00
davidxu
70ea4e1323
Rework last change of pthread_once, create a function _thr_once_init to
...
reinitialize its internal locks.
2006-02-15 23:05:03 +00:00
davidxu
44a8ce5006
After fork(), reinitialize internal locks for pthread_once().
2006-02-15 13:41:02 +00:00
davidxu
08b1c5c928
Now, thread name is stored in kernel, userland no longer has to keep it.
2006-02-05 03:04:54 +00:00
davidxu
118990614c
use syscall thr_set_name to implement pthread_set_name_np.
2006-02-05 02:26:17 +00:00
davidxu
3172ccca0f
Add missing symbol pthread_set_name_np.
2006-01-23 06:11:23 +00:00
davidxu
97a1cdabb8
Eliminate unused code.
2006-01-16 05:33:48 +00:00
davidxu
aedf24a684
Enable mutex inheritance code in mutex_fork, I forgot to turn on it.
...
while here, add some comments about process shared mutex.
2006-01-14 11:33:43 +00:00
jasone
e30d92806f
Increase the number of spinlocks, since libc's malloc implementation is
...
about to significantly increase the number of spinlocks used.
Approved by: markm (mentor)
2006-01-13 06:14:04 +00:00
jasone
3668a2e494
In preparation for a new malloc implementation:
...
* Add posix_memalign().
* Move calloc() from calloc.c to malloc.c. Add a calloc() implementation in
rtld-elf in order to make the loader happy (even though calloc() isn't
used in rtld-elf).
* Add _malloc_prefork() and _malloc_postfork(), and use them instead of
directly manipulating __malloc_lock.
Approved by: phk, markm (mentor)
2006-01-12 07:28:21 +00:00
davidxu
84187b477c
The thr_new sysscall was already in libc, don't generate it.
2006-01-11 06:10:05 +00:00
davidxu
1218aa5627
Use macro STATIC_LIB_REQUIRE to declare a symbol should be linked into
...
static binary.
2006-01-10 04:53:03 +00:00
davidxu
36bb818343
Rescue pthread_set_name_np for compatible reason, remove unused code.
2006-01-09 08:07:22 +00:00
davidxu
8798f9bcec
Tweak macro THR_LOCK_RELEASE a bit for non-PTHREAD_INVARIANTS case.
2006-01-09 07:32:22 +00:00
davidxu
db9594be6e
Return real detached state.
2006-01-09 03:59:51 +00:00
davidxu
6f27a53b6f
Fix a bug recently introduced, the _thread_active_count should be
...
decreased if thread can not be created.
2006-01-08 10:13:18 +00:00
davidxu
d1f7b6d605
Allow background threads to be suspended.
2006-01-08 01:49:31 +00:00
davidxu
4c4f339838
Try to reduce total time needed for suspending all threads,
...
first broadcast signals to all threads, then enter a wait loop.
2006-01-08 01:48:51 +00:00
davidxu
f04292bb19
Remove functions i386_get_gsbase and i386_set_gsbase, they were already
...
in libc.
2006-01-07 06:01:43 +00:00
davidxu
d6c88c0f27
Refine thread suspension code, now thread suspension is a blockable
...
operation, the caller is blocked util target threads are really
suspended, also avoid suspending a thread when it is holding a
critical lock.
Fix a bug in _thr_ref_delete which tests a never set flag.
2006-01-05 13:51:22 +00:00
davidxu
45180066f9
1. Add SIGEV_THREAD notification for mq_notify.
...
2. Reuse current timer code and abstract some common code to
to support both timer and mqueue.
2006-01-04 11:48:02 +00:00
davidxu
46ad9344c2
Remove in-progress wait code to sync with libpthread's behavior.
2006-01-03 13:30:23 +00:00
davidxu
2d34e45c94
Let _mutex_cv_lock call internal functiona mutex_lock_common.
2005-12-21 05:14:07 +00:00
davidxu
5ac55e9c46
Hide umtx API symbols as well.
2005-12-21 03:53:29 +00:00
davidxu
8d9e23fb51
1. Retire macro SCLASS, instead simply use language keyword and
...
put variables in thr_init.c.
2. Hide all global symbols which won't be exported.
2005-12-21 03:14:06 +00:00
davidxu
3e60ee73cb
Follow the mistake in libpthread, the first version name in libpthread
...
is LIBTHREAD_1_0, but really it should be LIBPTHREAD_1_0.
Fix it so libmap.conf works again (it was broken by recent versioning
code in rtld_elf).
2005-12-21 02:34:20 +00:00
davidxu
a8cc7e07c2
Clear return code to zero if joiner successfully waited joinee.
...
Bug reported by: jasone at connonware when using ports lang/onyx
MFC after: 3 days
2005-12-19 03:20:55 +00:00
davidxu
272f64aa70
Update copyright.
2005-12-17 09:42:45 +00:00
davidxu
7bdde27518
Remove unused _get_curthread() call.
2005-12-12 07:14:57 +00:00
davidxu
ae161ac239
Fix name compatible problem with POSIX standard. the sigval_ptr and
...
sigval_int really should be sival_ptr and sival_int.
Also sigev_notify_function accepts a union sigval value but not a
pointer.
2005-11-04 09:41:00 +00:00