summaryrefslogtreecommitdiffstats
path: root/lib/libthr/thread
Commit message (Collapse)AuthorAgeFilesLines
* Fix pointer dereferencing problems in _pthread_mutex_init_calloc_cb() thatjasone2007-11-281-7/+3
| | | | were obscured by pseudo-opaque pthreads API pointer casting.
* Add _pthread_mutex_init_calloc_cb() to libthr and libkse, so that malloc(3)jasone2007-11-271-6/+27
| | | | | (part of libc) can use pthreads mutexes without causing infinite recursion during initialization.
* Simplify code, fix a thread cancellation bug in sem_wait and sem_timedwait.davidxu2007-11-231-21/+15
|
* Reuse nwaiter member field to record number of waiters, in sem_post(),davidxu2007-11-211-7/+31
| | | | | this should reduce the chance having to do a syscall when there is no waiter in the semaphore.
* Convert ceiling type to unsigned integer before comparing, fix compilerdavidxu2007-11-211-3/+3
| | | | warnings.
* Add some function prototypes.davidxu2007-11-211-0/+5
|
* Remove umtx_t definition, use type long directly, add wrapper functiondavidxu2007-11-217-18/+31
| | | | | _thr_umtx_wait_uint() for umtx operation UMTX_OP_WAIT_UINT, use the function in semaphore operations, this fixed compiler warnings.
* In _pthread_key_create() ensure that libthr is initialized. Thismarius2007-11-061-1/+5
| | | | | | | | | | | 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
* Avoid doing adaptive spinning for priority protected mutex, currentdavidxu2007-10-311-2/+5
| | | | implementation always does lock in kernel.
* Don't do adaptive spinning if it is running on UP kernel.davidxu2007-10-311-3/+5
|
* Restore revision 1.55, the kris's adaptive mutex type.davidxu2007-10-311-14/+36
|
* Adaptive mutexes should have the same deadlock detection properties thatkris2007-10-301-0/+1
| | | | | | default (errorcheck) mutexes do. Noticed by: davidxu
* Add my recent work of adaptive spin mutex code. Use two environments variabledavidxu2007-10-303-47/+50
| | | | | | | | | | | | | | | | | | | | | | | | | 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.
* Add a new "non-portable" mutex type, PTHREAD_MUTEX_ADAPTIVE_NP. Thiskris2007-10-291-0/+29
| | | | | | | | | | | | | | | | | | | | | | | | | | | | 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
* Use macro THR_CLEANUP_PUSH/POP, they are cheaper than pthread_cleanup_push/pop.davidxu2007-10-161-2/+4
|
* Reverse the logic of UP and SMP.davidxu2007-10-161-1/+1
| | | | Submitted by: jasone
* Output error message to STDERR_FILENO.davidxu2007-08-071-1/+1
| | | | Approved by: re (bmah)
* backout experimental adaptive spinning mutex for product use.davidxu2007-05-093-9/+0
|
* If a thread who's name is being set is not the current thread, use macrosdavidxu2007-04-051-2/+2
| | | | | | | 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
* Remove 3rd clause, renumber, ok per emailimp2007-01-1221-88/+22
|
* Insert mutex at tail if it has highest ceiling.davidxu2007-01-051-1/+1
|
* Oops, don't corrupt the list.davidxu2007-01-051-1/+1
|
* Check if the PP mutex is recursive, if we have already locked it, place thedavidxu2007-01-051-9/+28
| | | | mutex in right order sorted by priority ceiling.
* get LIBPTHREAD_ADAPTIVE_SPIN early, so it can be used for some globaldavidxu2006-12-201-2/+5
| | | | mutexes.
* Check environment variable PTHREAD_ADAPTIVE_SPIN, if it is set, usedavidxu2006-12-205-1/+8
| | | | it as a default spin cycle count.
* - Remove variable _thr_scope_system, all threads are system scope.davidxu2006-12-154-24/+8
| | | | | - Rename _thr_smp_cpus to boolean variable _thr_is_smp. - Define CPU_SPINWAIT macro for each arch, only X86 supports it.
* Create inline function _thr_umutex_trylock2 to only try one atomicdavidxu2006-12-142-3/+11
| | | | | operation, if it is failed, we call syscall directly, this saves one atomic operation per lock contention.
* Correctly check failed syscall.davidxu2006-12-121-10/+10
|
* Move checking for c_has_waiters into low level _thr_ucond_signal anddavidxu2006-12-122-16/+12
| | | | | | | _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.
* test cancel_pending to save a thr_wake call in some specical cases.davidxu2006-12-061-1/+1
|
* _thr_ucond_wait drops lock, we should pick it up again.davidxu2006-12-051-0/+1
|
* the c_has_waiters is lazily updated, temporarily disable the falsedavidxu2006-12-051-0/+2
| | | | alarm code.
* Use ucond to implement barrier.davidxu2006-12-052-8/+10
|
* Add _thr_ucond_init().davidxu2006-12-052-3/+10
|
* Tweak _thr_cancel_leave_defer a bit to fix a possible race.davidxu2006-12-051-3/+7
|
* Fix typo, I was using a wrong header file, and the typo is not detecteddavidxu2006-12-041-1/+1
| | | | by compiler.
* Use kernel provided userspace condition variable to implement pthreaddavidxu2006-12-046-96/+105
| | | | condition variable.
* If a thread was detached, return EINVAL instead, the error codedavidxu2006-11-281-1/+1
| | | | | | | | 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.
* Eliminate atomic operations in thread cancellation functions, it shoulddavidxu2006-11-2412-213/+176
| | | | reduce overheads of cancellation points.
* Move code calculating new inherited priority into single function.davidxu2006-11-111-30/+21
|
* Don't inherit THR_FLAGS_NEED_SUSPEND for child process, child processdavidxu2006-10-141-0/+2
| | | | | only has one thread, setting the flag can cause the thread to be suspended and no another thread will resume it.
* o Make _thr_umutex_init a function.davidxu2006-10-132-21/+23
| | | | | | o Eliminate unused parameter for some functions. o Convert type of first parameter to void * for _thr_umtx_wait and _thr_umtx_wake.
* Use type pthread_state for thread state.davidxu2006-10-131-1/+1
|
* use rtprio_thread system call to get or set thread priority.davidxu2006-09-217-16/+90
|
* Use return value of _thr_umutex_lock instead of using zero.davidxu2006-09-081-2/+1
|
* Replace internal usage of struct umtx with umutex which can supportsdavidxu2006-09-0614-158/+94
| | | | real-time if we want, no functionality is changed.
* Same as pthread_setschedparam, use sizeof(struct sched_param) instead.davidxu2006-09-051-2/+2
|
* Pass correct parameter size.davidxu2006-09-051-2/+2
|
* Remove unused file.davidxu2006-08-291-59/+0
|
* pthread_sigmask is in thr_sig.c, remove this file.davidxu2006-08-281-52/+0
|
OpenPOWER on IntegriCloud