David Xu
850f4d66cb
- 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
Warner Losh
13d2e92b70
Commit missing mips libthr support that I thought I'd committed earlier
2008-05-11 05:54:52 +00:00
David Xu
cf181aee60
Remove libc_r's remnant code.
2008-05-06 07:27:11 +00:00
David Xu
8d6a11a070
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 Kennaway
dd77f9f7f2
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
Warner Losh
416e6cfbf0
Bring in mips threads support from perforce mips2-jnpr branch.
2008-04-26 12:17:57 +00:00
Xin LI
d0aa4fd3ca
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
David Xu
fb2641d9b1
Use native rwlock.
2008-04-22 06:44:11 +00:00
David Xu
6d9517bc9f
_vfork is not in libthr, remove the reference.
2008-04-16 03:19:11 +00:00
David Xu
fa4b421a7a
don't include pthread_np.h, it is not used.
2008-04-14 08:08:40 +00:00
David Xu
caad30a422
put THR_CRITICAL_LEAVE into do .. while statement.
2008-04-03 02:47:35 +00:00
David Xu
a6cba9400a
add __hidden suffix to _umtx_op_err, this eliminates PLT.
2008-04-03 02:13:51 +00:00
David Xu
7abb97dcd8
Non-portable functions are in pthread_np.h, fix compiling problem.
2008-04-02 11:41:12 +00:00
David Xu
7a30bcf04b
Add pthread_setaffinity_np and pthread_getaffinity_np to libc namespace.
2008-04-02 08:53:18 +00:00
David Xu
8b873a2328
Remove unused functions.
2008-04-02 08:33:42 +00:00
David Xu
d6e0eb0a48
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
David Xu
8bf1a48cb3
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
David Xu
18967c1918
Restore normal pthread_cond_signal path to avoid some obscure races.
2008-04-01 06:23:08 +00:00
David Xu
f5bc4f9930
return EAGAIN early rather than running bunch of code later, micro optimize
...
static branch prediction.
2008-04-01 00:21:49 +00:00
David Xu
5ab512bb8e
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
Ruslan Ermilov
dbdb679c6f
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
Ruslan Ermilov
e03efb02bc
Compile libthr with warnings.
2008-03-25 13:28:12 +00:00
Ruslan Ermilov
7e0e78248e
Fixed mis-implementation of pthread_mutex_get{spin,yield}loops_np().
...
Reviewed by: davidxu
2008-03-25 09:48:10 +00:00
David Xu
9939a13667
Add POSIX pthread API pthread_getcpuclockid() to get a thread's cpu
...
time clock id.
2008-03-22 09:59:20 +00:00
David Xu
04a57d2c83
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
Ruslan Ermilov
a1292a02d3
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
David Xu
8c38215f50
Preserve application code's errno in rtld locking code, it attemps to keep
...
any case safe.
2008-03-20 09:35:44 +00:00
David Xu
48ebe2ebc4
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
David Xu
c8a4eae56f
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
David Xu
519e8d87bb
- Trim trailing spaces.
...
- Use a different sigmask variable name to avoid confusing.
2008-03-19 08:13:04 +00:00
David Xu
86a06c6000
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
David Xu
2ea1f90a18
- 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
David Xu
a9a11568ff
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
David Xu
150b71918c
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
David Xu
8a18c0d3c8
Fix a bug when calculating remnant size.
2008-03-06 03:24:03 +00:00
David Xu
697b4b49be
Don't report death event to debugger if it is a forced exit.
2008-03-06 02:07:18 +00:00
David Xu
70e79fbb0d
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
David Xu
1cb51125aa
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
David Xu
54dff16b26
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
David Xu
07bbb16640
Add more cpu affinity function's symbols.
2008-03-05 06:56:35 +00:00
David Xu
21845eb98d
Check actual size of cpuset kernel is using and define underscore version
...
of API.
2008-03-05 06:55:48 +00:00
David Xu
76a9679f8e
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
David Xu
54c9b47c2b
Include cpuset.h, unbreak compiling.
2008-03-04 03:45:11 +00:00
David Xu
a759db946a
implement pthread_attr_getaffinity_np and pthread_attr_setaffinity_np.
2008-03-04 03:03:24 +00:00
David Xu
57030e1071
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
Dag-Erling Smørgrav
096ba44775
_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
David E. O'Brien
a2c4cd4549
style.Makefile(5)
2008-02-13 05:25:43 +00:00
David E. O'Brien
6cc9986927
style(9)
2008-02-13 05:12:05 +00:00
Dag-Erling Smørgrav
47252f4e65
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
Dag-Erling Smørgrav
d29b081fee
Remove unnecessary prototype.
2008-02-06 20:43:19 +00:00
Dag-Erling Smørgrav
a9b9744ff8
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
Dag-Erling Smørgrav
facfc98226
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
Dag-Erling Smørgrav
1cbdac2668
Per discussion on -threads, rename _islocked_np() to _isowned_np().
2008-02-06 19:34:31 +00:00
Dag-Erling Smørgrav
fcd61d9141
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
Dag-Erling Smørgrav
5fd410a787
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
David Xu
8d0a4dab61
SYSTEM_SCOPE_ONLY flag is no longer needed, it is the only mode libthr
...
supports.
2008-01-18 04:29:36 +00:00
David Xu
0c921dadbb
sem_post() requires to return -1 on error.
2008-01-07 02:26:29 +00:00
David Xu
9ba01c866b
call underscore version of pthread_cleanup_pop instead.
2007-12-20 04:40:12 +00:00
David Xu
06c8eb55ce
Remove vfork() overloading, it is no longer needed.
2007-12-20 04:32:28 +00:00
David Xu
c5f411515c
Add function prototypes.
2007-12-17 02:53:11 +00:00
David Xu
093fcf1694
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
David Xu
6a663207e7
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
Jason Evans
b6b7fd3e2a
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
Jason Evans
e1636e1f97
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
David Xu
da4410f25f
Simplify code, fix a thread cancellation bug in sem_wait and sem_timedwait.
2007-11-23 05:42:52 +00:00
David Xu
4877aaebc1
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
David Xu
73ba600faa
Remove warning level and aliasing restrictions.
2007-11-21 05:29:57 +00:00
David Xu
9e1ddd5fa0
Convert ceiling type to unsigned integer before comparing, fix compiler
...
warnings.
2007-11-21 05:25:27 +00:00
David Xu
922d56f9de
Add some function prototypes.
2007-11-21 05:23:54 +00:00
David Xu
6fdfcacb4a
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
John Birrell
0aad0f2282
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 Strobl
9a2706abcc
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
David Xu
56b45d9067
Avoid doing adaptive spinning for priority protected mutex, current
...
implementation always does lock in kernel.
2007-10-31 01:50:48 +00:00
David Xu
55f18e070f
Don't do adaptive spinning if it is running on UP kernel.
2007-10-31 01:44:50 +00:00
David Xu
e8ef3c283b
Restore revision 1.55, the kris's adaptive mutex type.
2007-10-31 01:37:13 +00:00
Kris Kennaway
83941f797f
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
David Xu
7416cdabcd
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 Kennaway
2017a7cdfe
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
Ruslan Ermilov
886659fe14
- 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
David Xu
5150e987d2
Use macro THR_CLEANUP_PUSH/POP, they are cheaper than pthread_cleanup_push/pop.
2007-10-16 07:46:15 +00:00
David Xu
286b41104d
Reverse the logic of UP and SMP.
...
Submitted by: jasone
2007-10-16 07:36:02 +00:00
David E. O'Brien
946367b8e2
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
Ruslan Ermilov
948809b1ae
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
David Xu
4aa80591b6
Output error message to STDERR_FILENO.
...
Approved by: re (bmah)
2007-08-07 04:50:14 +00:00
David Xu
44a31c2d7f
Set warning level to 2.
2007-06-08 02:21:13 +00:00
Daniel Eischen
419ecd5dee
Bump library versions in preparation for 7.0.
...
Ok'd by: kan
2007-05-21 02:49:08 +00:00
Ruslan Ermilov
539e7a7770
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
Daniel Eischen
683f4c0a40
Allow DEFAULT_THREAD_LIB to be set from /etc/src.conf.
...
Submitted by: ru
2007-05-17 04:54:35 +00:00
Daniel Eischen
00fb440c1a
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
David Xu
00784f8b10
backout experimental adaptive spinning mutex for product use.
2007-05-09 08:39:33 +00:00
Daniel Eischen
5f864214bb
Use C comments since we now preprocess these files with CPP.
2007-04-29 14:05:22 +00:00
David Xu
6839e793cf
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
Warner Losh
fed32d7544
Remove 3rd clause, renumber, ok per email
2007-01-12 07:26:21 +00:00
David Xu
03779e5c2b
Insert mutex at tail if it has highest ceiling.
2007-01-05 03:57:11 +00:00
David Xu
da20a63dbb
Oops, don't corrupt the list.
2007-01-05 03:33:47 +00:00
David Xu
5470bb56fc
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
David Xu
74c751131b
get LIBPTHREAD_ADAPTIVE_SPIN early, so it can be used for some global
...
mutexes.
2006-12-20 05:05:44 +00:00
David Xu
842a092b74
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
David Xu
d99f6dac14
- 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
David Xu
8a8178c010
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
David Xu
9e8a8aa551
Correctly check failed syscall.
2006-12-12 05:26:39 +00:00
David Xu
347126a2e2
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
David Xu
b774466b61
test cancel_pending to save a thr_wake call in some specical cases.
2006-12-06 00:15:35 +00:00
David Xu
a8a343d2e6
_thr_ucond_wait drops lock, we should pick it up again.
2006-12-05 23:46:11 +00:00
David Xu
3b8a017442
the c_has_waiters is lazily updated, temporarily disable the false
...
alarm code.
2006-12-05 07:23:58 +00:00
David Xu
4d617f2d10
Use ucond to implement barrier.
2006-12-05 06:54:25 +00:00
David Xu
670b44d65a
Add _thr_ucond_init().
2006-12-05 06:53:44 +00:00
David Xu
3ce4e91d4e
Tweak _thr_cancel_leave_defer a bit to fix a possible race.
2006-12-05 05:01:57 +00:00
David Xu
3c61d00ab6
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
David Xu
2bd2c90703
Use kernel provided userspace condition variable to implement pthread
...
condition variable.
2006-12-04 14:20:41 +00:00
David Xu
6f54e82927
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
Ruslan Ermilov
8af480aec1
- 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
David Xu
f08e1bf682
Eliminate atomic operations in thread cancellation functions, it should
...
reduce overheads of cancellation points.
2006-11-24 09:57:38 +00:00
David Xu
58c7bab332
Move code calculating new inherited priority into single function.
2006-11-11 13:33:47 +00:00
David Xu
5656b5fafa
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
David Xu
8042f26d52
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
David Xu
0b90fa4ad0
Use type pthread_state for thread state.
2006-10-13 12:45:21 +00:00
David Xu
e6747c7ce1
use rtprio_thread system call to get or set thread priority.
2006-09-21 04:21:30 +00:00
David Xu
ddaf6689e3
Use return value of _thr_umutex_lock instead of using zero.
2006-09-08 09:29:14 +00:00
David Xu
bddd24cd9c
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
David Xu
8549079365
Same as pthread_setschedparam, use sizeof(struct sched_param) instead.
2006-09-05 14:39:06 +00:00
David Xu
be0bfdd207
Pass correct parameter size.
2006-09-05 14:37:22 +00:00
Marcel Moolenaar
be2f4bda88
Stylize: avoid using a global register variable.
2006-09-01 21:01:11 +00:00
Marcel Moolenaar
cc79b334de
Rename TLS_TP_OFFSET back to TP_OFFSET. The former clashes with rtld.
2006-09-01 06:36:00 +00:00
Marcel Moolenaar
8e61dbecfc
Stylize.
2006-09-01 06:15:00 +00:00
Marcel Moolenaar
35ca217bf0
Stylize.
2006-08-31 23:31:18 +00:00
Marcel Moolenaar
9f7b8b0d3c
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 Moolenaar
91705de0c2
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 Moolenaar
57c2251d5c
o Set TP using inline assembly to avoid dead code elimination.
...
o Eliminate _tcb.
2006-08-30 03:31:32 +00:00
David Xu
fd2b89c48c
Remove unused file.
2006-08-29 13:01:23 +00:00
David Xu
215318a7a3
pthread_sigmask is in thr_sig.c, remove this file.
2006-08-28 12:29:54 +00:00
David Xu
6361212beb
Kill unused files.
2006-08-28 05:01:31 +00:00
David Xu
8ab9d78b9d
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
David Xu
cf13ecda6a
Add umutex APIs.
2006-08-28 04:47:27 +00:00
Ruslan Ermilov
2b46c64c9c
Remove alpha left-overs.
2006-08-22 08:03:01 +00:00
David Xu
065dbdc130
Axe unused member field.
2006-08-08 05:04:43 +00:00
David Xu
6b73f08519
Get number of CPUs and ignore spin count on single processor machine.
2006-08-08 04:42:41 +00:00
David Xu
05c3a5eab4
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
Xin LI
da84584390
Unexpand two TAILQ_FOREACH_SAFE cases.
...
Ok'ed by: davidxu
2006-07-17 09:23:44 +00:00
David Xu
e2dc286c1c
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
David Xu
561a89f945
Use thr_setscheduler, thr_getscheduler and thr_setschedparam to implement
...
pthread functions.
2006-07-13 06:35:43 +00:00
David Xu
7b4f8f037f
Use kernel facilities to support real-time scheduling.
2006-07-12 06:13:18 +00:00
David Xu
9bbc6c7f54
__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
David Xu
7fabe0b5cc
Remove unused member.
2006-06-03 00:19:40 +00:00
David Xu
b971a73040
Remove unused member field m_queue.
2006-06-02 08:37:01 +00:00
Xin LI
631574e7dc
Explicitly request pre-zeroed memory instead of memset'ing our
...
own.
Ok'ed by: davidxu
2006-05-31 00:31:38 +00:00
David Xu
e92b415c5a
Add symbol versions: FBSD_1.0 and FBSDprivate.
2006-05-11 07:02:52 +00:00
David Xu
0a5fa45560
s/long/int.
2006-04-27 08:25:13 +00:00
David Xu
245116cafc
- 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
David Xu
d96413eaa4
Remove multiple _get_curthread() calls.
2006-04-23 11:23:37 +00:00
Ruslan Ermilov
84e709f1f1
Install shared libpthread library into /lib; needed by some
...
/sbin programs.
2006-04-12 19:42:20 +00:00
David Xu
a97944597b
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
David Xu
b7e118b1e0
Remove declaration of _thr_initial from MD header file, it is no longer
...
needed.
2006-04-04 03:35:26 +00:00
David Xu
7bd761788d
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
David Xu
37a6356bbe
WARNS level 4 cleanup.
2006-04-04 02:57:49 +00:00
Dag-Erling Smørgrav
552585665b
Fix prototype mismatch.
2006-03-28 21:46:55 +00:00
David Xu
9ad4b64459
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
David Xu
649814dd6c
Comment out -g compiler option, found by 'FreeBSD Build Options Survey'.
2006-03-27 05:58:58 +00:00
David Xu
d448272d3c
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
David Xu
efe33769b9
Don't cancel thread if it is in critical region.
2006-03-25 07:03:13 +00:00
David Xu
f656ae703e
Only wake up writer if the lock is free.
2006-03-25 05:14:21 +00:00
David Xu
07c7c80074
Compile thr_rtld.c
2006-03-25 05:00:54 +00:00
David Xu
b6b894f66b
Add locking support for rtld.
2006-03-25 04:49:07 +00:00
David Xu
c147998f53
set an upper limit for thread structures which can be allocated.
2006-03-24 04:34:06 +00:00
David Xu
6f79c82641
Set default contention scope to system.
2006-03-20 03:14:14 +00:00
Ruslan Ermilov
5740a2b62d
Convert NO_PROFILE and NO_LIB32 to new style.
2006-03-18 21:37:05 +00:00
David Xu
d3de1dcae7
Remove mqueue and timer, now they are in librt.
2006-03-08 23:47:04 +00:00
Daniel Eischen
f4cd2a5b5c
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
David Xu
7b8797d300
Reimplement mutex_init to get rid of compile warning.
2006-02-28 06:06:19 +00:00
David Xu
b620798174
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
David Xu
bab012a948
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
David Xu
6f716c2f82
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
David Xu
c5d2fb8df7
After fork(), reinitialize internal locks for pthread_once().
2006-02-15 13:41:02 +00:00
David Xu
8956297a57
Now, thread name is stored in kernel, userland no longer has to keep it.
2006-02-05 03:04:54 +00:00
David Xu
3f7dda33b7
use syscall thr_set_name to implement pthread_set_name_np.
2006-02-05 02:26:17 +00:00
David Xu
5f9df00649
Add missing symbol pthread_set_name_np.
2006-01-23 06:11:23 +00:00
David Xu
1c9db39d88
Eliminate unused code.
2006-01-16 05:33:48 +00:00
David Xu
add2da0db1
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
Jason Evans
90dc795234
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
Jason Evans
52828c0e9c
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
David Xu
07a263153e
The thr_new sysscall was already in libc, don't generate it.
2006-01-11 06:10:05 +00:00
David Xu
9572a73405
Use macro STATIC_LIB_REQUIRE to declare a symbol should be linked into
...
static binary.
2006-01-10 04:53:03 +00:00
David Xu
e35e2ebd24
Rescue pthread_set_name_np for compatible reason, remove unused code.
2006-01-09 08:07:22 +00:00
David Xu
a53747d8fe
Tweak macro THR_LOCK_RELEASE a bit for non-PTHREAD_INVARIANTS case.
2006-01-09 07:32:22 +00:00
David Xu
4160cda0dc
Return real detached state.
2006-01-09 03:59:51 +00:00
David Xu
1775714935
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
David Xu
23db0a33f7
Allow background threads to be suspended.
2006-01-08 01:49:31 +00:00
David Xu
0d29c148eb
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
David Xu
d827aa478d
Remove functions i386_get_gsbase and i386_set_gsbase, they were already
...
in libc.
2006-01-07 06:01:43 +00:00
David Xu
bc414752d3
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
David Xu
5131df80a5
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
David Xu
97986a2ea0
Remove in-progress wait code to sync with libpthread's behavior.
2006-01-03 13:30:23 +00:00
David Xu
e6262545cf
Let _mutex_cv_lock call internal functiona mutex_lock_common.
2005-12-21 05:14:07 +00:00
David Xu
8429e73473
Hide umtx API symbols as well.
2005-12-21 03:53:29 +00:00
David Xu
cf905a1575
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
David Xu
7a65760923
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
David Xu
597dc824a0
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
David Xu
df2cf82178
Update copyright.
2005-12-17 09:42:45 +00:00
David Xu
e6a9baa280
Remove unused _get_curthread() call.
2005-12-12 07:14:57 +00:00
David Xu
8f0371f19d
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