Commit Graph

233 Commits

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