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
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
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
David Xu
e89510b152
Remove a redundant _get_curthread() call.
2005-11-02 14:06:29 +00:00
David Xu
7f838bf429
In raise(), use a shortcut to directly send signal to current thread.
2005-11-02 13:52:48 +00:00
David Xu
bff49d66ab
Fix some comments, eliminate a memory leak.
2005-11-01 13:05:47 +00:00
David Xu
6cae59b1e7
Use TIMERS_UNLOCK.
2005-11-01 07:05:32 +00:00
David Xu
53bbdf8646
Add code to handle timer_delete(). The timer wrapper code is completely
...
rewritten, now timers created with same sigev_notify_attributes will
run in same thread, this allows user to organize which timers can
run in same thread to save some thread resource.
2005-11-01 06:53:22 +00:00
David Xu
7a81302ce7
Add thread exit handler in timer_loop to handle broken buggy code which
...
could lead to memory leak.
2005-10-30 23:59:01 +00:00
David Xu
4a050d016e
Add timer_create wrapper.
2005-10-30 03:16:30 +00:00
David Xu
07b6889426
Add experiment code to implement POSIX timer's SIGEV_THREAD notification.
2005-10-26 11:08:32 +00:00
David Xu
d7f119abd5
Follow the change in kernel, joiner thread just waits at thread id
...
address, let kernel wake it up.
2005-10-26 07:11:43 +00:00
David Xu
c3d1b896b2
Add functions pthread_mutexattr_setpshared and pthread_mutexattr_getpshared.
2005-10-24 05:16:41 +00:00
David Xu
88676cbc2c
The pthread_attr_set_createsuspend_np was broken, fix it by
...
replacing THR_FLAGS_SUSPENDED with THR_FLAGS_NEED_SUSPEND.
2005-10-10 12:15:07 +00:00
David Xu
9e49a2370c
Add function pthread_timedjoin_np, the function is similar with pthread_join
...
except the function will return ETIMEDOUT if target thread does not exit
before specified absolute time passes.
2005-10-04 06:15:25 +00:00
Stefan Farfeleder
7e4cbc3a50
Include needed headers that were obtained through <pthread.h>. Sort headers
...
while here.
2005-09-01 15:21:23 +00:00
Stefan Farfeleder
ad7c49168f
- Prefix MUTEX_TYPE_MAX with PTHREAD_ to avoid namespace pollution.
...
- Remove the macros MUTEX_TYPE_FAST and MUTEX_TYPE_COUNTING_FAST.
OK'ed by: deischen
2005-08-19 21:31:42 +00:00
Daniel Eischen
14d5987375
Add a cancellation point for usleep().
...
While here, fix sleep() so that it is also a cancellation point (a
missing weak reference prevented that).
2005-08-03 00:47:31 +00:00
David Xu
2ff77b9220
Cast to uintptr_t to avoid compiler warning, it was broken by
...
the recent atomic_ptr() change.
2005-07-28 03:34:54 +00:00
David Xu
3adc17c503
Fix off-by-one nanosecond bug in macro TIMESPEC_ADD.
...
Reviewed by: deischen
Approved by: re (dwhite)
MFC after : 4 days
2005-06-22 22:38:56 +00:00
David Xu
80c9676e8b
Use thr_new syscall to create a new thread, obscure context operations
...
is no longer needed.
2005-04-23 02:48:59 +00:00
David Xu
7a4cd8d366
Conditionally report initial thread event.
2005-04-12 03:13:49 +00:00
David Xu
4faae5e992
Add missing event reporting code.
2005-04-12 03:08:11 +00:00
David Xu
d245d9e13f
Add debugger event reporting support, current only TD_CREATE and TD_DEATH
...
events are reported.
2005-04-12 03:00:28 +00:00
David Xu
62a2d99ce5
Adjust hash function for smaller pthread structure size.
2005-04-07 06:09:17 +00:00
David Xu
bc1eb018c1
Remove unique id field which is no longer used by debugger.
2005-04-06 13:57:31 +00:00
David Xu
619f4fce79
Pass exact number of threads.
2005-04-04 23:43:53 +00:00
David Xu
a091d823ad
Import my recent 1:1 threading working. some features improved includes:
...
1. fast simple type mutex.
2. __thread tls works.
3. asynchronous cancellation works ( using signal ).
4. thread synchronization is fully based on umtx, mainly, condition
variable and other synchronization objects were rewritten by using
umtx directly. those objects can be shared between processes via
shared memory, it has to change ABI which does not happen yet.
5. default stack size is increased to 1M on 32 bits platform, 2M for
64 bits platform.
As the result, some mysql super-smack benchmarks show performance is
improved massivly.
Okayed by: jeff, mtm, rwatson, scottl
2005-04-02 01:20:00 +00:00
Joe Marcus Clarke
c5a6625e3e
Increase the default stacksizes:
...
32-bit 64-bit
main thread 2 MB 4 MB
other threads 1 MB 2 MB
Approved by: mtm
Adapted from: libpthread
2005-03-06 07:56:18 +00:00
David Schultz
6004362e66
Don't include sys/user.h merely for its side-effect of recursively
...
including other headers.
2004-11-27 06:51:39 +00:00
Mike Makonnen
5dbd7addb0
1. Now that it's a thread's state is changed from within the kernel, where
...
no userland locks are heald, the dead thread lock can no longer protect
access to it. Therefore, instead of using an if (!dead)...else clause
after walking the active threads list test the thread pointer before
deciding not to walk the dead threads list. If the thread pointer is null
it means it was not found in the active threads list and the dead threads
list should be checked.
2. Do not free the stack of a thread that is not marked dead. This is the
2nd and final part of eliminating the race to free a thread's stack.
MFC after: 3 days
2004-10-13 11:42:20 +00:00
Mike Makonnen
4cdb7f14ed
Remove a reference to a non-existent syscall: _thr_exit(). The
...
actual name is thr_exit(). How this ever worked is beyond me.
2004-10-08 14:48:02 +00:00
Mike Makonnen
401901ac43
Close a race between a thread exiting and the freeing of it's stack.
...
After some discussion the best option seems to be to signal the thread's
death from within the kernel. This requires that thr_exit() take an
argument.
Discussed with: davidxu, deischen, marcel
MFC after: 3 days
2004-10-06 14:23:00 +00:00
Mike Makonnen
2d79470f8a
Remove vestiges of libthr's signal mangling past. This fixes that last
...
known problem with mysql on libthr: not being able to kill mysqld.
2004-09-22 18:51:16 +00:00