Commit Graph

197 Commits

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