Commit Graph

298 Commits

Author SHA1 Message Date
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