summaryrefslogtreecommitdiffstats
path: root/lib/libthr/thread/thr_kern.c
Commit message (Collapse)AuthorAgeFilesLines
* libthr: Always use the threaded rtld lock implementation.jilles2013-01-181-5/+0
| | | | | | | | | | | The threaded rtld lock implementation is faster even in the single-threaded case because it postpones signal handlers via THR_CRITICAL_ENTER and THR_CRITICAL_LEAVE instead of calling sigprocmask(2). As a result, exception handling becomes faster in single-threaded applications linked with libthr. Reviewed by: kib
* MFp4:davidxu2012-08-111-7/+0
| | | | | Further decreases unexpected context switches by defering mutex wakeup until internal sleep queue lock is released.
* MFp4:davidxu2010-12-221-0/+92
| | | | | | | | | | | | | | | - Add flags CVWAIT_ABSTIME and CVWAIT_CLOCKID for umtx kernel based condition variable, this should eliminate an extra system call to get current time. - Add sub-function UMTX_OP_NWAKE_PRIVATE to wake up N channels in single system call. Create userland sleep queue for condition variable, in most cases, thread will wait in the queue, the pthread_cond_signal will defer thread wakeup until the mutex is unlocked, it tries to avoid an extra system call and a extra context switch in time window of pthread_cond_signal and pthread_mutex_unlock. The changes are part of process-shared mutex project.
* Add signal handler wrapper, the reason to add it becauses there aredavidxu2010-09-011-32/+0
| | | | | | | | | | | | | | | | | | | | | | | some cases we want to improve: 1) if a thread signal got a signal while in cancellation point, it is possible the TDP_WAKEUP may be eaten by signal handler if the handler called some interruptibly system calls. 2) In signal handler, we want to disable cancellation. 3) When thread holding some low level locks, it is better to disable signal, those code need not to worry reentrancy, sigprocmask system call is avoided because it is a bit expensive. The signal handler wrapper works in this way: 1) libthr installs its signal handler if user code invokes sigaction to install its handler, the user handler is recorded in internal array. 2) when a signal is delivered, libthr's signal handler is invoke, libthr checks if thread holds some low level lock or is in critical region, if it is true, the signal is buffered, and all signals are masked, once the thread leaves critical region, correct signal mask is restored and buffered signal is processed. 3) before user signal handler is invoked, cancellation is temporarily disabled, after user signal handler is returned, cancellation state is restored, and pending cancellation is rescheduled.
* use rtprio_thread system call to get or set thread priority.davidxu2006-09-211-0/+66
|
* Add locking support for rtld.davidxu2006-03-251-2/+0
|
* Import my recent 1:1 threading working. some features improved includes:davidxu2005-04-021-93/+48
| | | | | | | | | | | | | | | | 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
* Stop using signals for synchronizing threads. The performance penaltymtm2004-03-271-16/+4
| | | | was too much.
* When suspending a thread if the timeout was very short ormtm2004-01-291-0/+11
| | | | | | | | | | | | | the system call got interrupted and the absolute timeout is converted to a relative timeout, it may happen that we get a negative number. In such a case, simply set the timeout to zero so that if the event that the thread wants to wait for has happened it can still return successfully, but if it hasn't happened then the thread doesn't suspend indefinitely. This should fix certain applications (including mozilla) that seem to hang indefinitely sometimes. Noticed and debugged by: Morten Johansen <root@morten-johansen.net>
* Make it possible for the library to specify a timeout value whenmtm2003-12-301-1/+1
| | | | | | | | | | waiting on a locked mutex. This involves passing a struct timespec from the pthread mutex locking interfaces all the way down to the function that suspends the thread until the mutex is released. The timeout is assumed to be an absolute time (i.e. not relative to the current time). Also, in _thread_suspend() make the passed in timespec const.
* Don't block SIGTRAP - it makes it hard to debug programs with gdb.dfr2003-12-261-0/+1
| | | | Reviewed by: mtm
* Remove _giant_mutex and its associated macros.mtm2003-12-151-69/+0
|
* When _PTHREADSINVARIANTS is defined SIGABRT is not includedmtm2003-07-081-0/+3
| | | | | | in the set of signals to block. Also, make the PANIC macro call abort() instead of simply exiting.
* Change all instances of THR_LOCK/UNLOCK, etc to UMTX_*.mtm2003-07-061-2/+2
| | | | | It is a more acurate description of the locks they operate on.
* Sweep through pthread locking and use the new locking primitives formtm2003-06-291-2/+2
| | | | libthr.
* In a critical section, separate the aquisition of the thread lockmtm2003-06-291-16/+24
| | | | | | | | | | | | and the disabling of signals. What we are really interested in is keeping track of recursive disabling of signals. We should not be recursively acquiring thread locks. Any such situations should be reorganized to not require a recursive lock. Separating the two out also allows us to block signals independent of acquiring thread locks. This will be needed in libthr in the near future when we put the pieces together to protect libc functions that use pthread mutexes and low level locks.
* Make _thread_suspend work with both the old broken sigtimedwaitjdp2003-06-291-11/+2
| | | | | | implementation and the new improved one. We now precompute the signal set passed to sigtimedwait, using an inverted set when necessary for compatibility with older kernels.
* The libthr code makes use of higher-level primitives (pthread_mutex_t andmtm2003-05-251-0/+13
| | | | | | | | | | | | | pthread_cond_t) internaly in addition to the low-level spinlock_t. The garbage collector mutex and condition variable are two such examples. This might lead to critical sections nested within critical sections. Implement a reference counting mechanism so that signals are masked only on the first entry and unmasked on the last exit. I'm not sure I like the idea of nested critical sections, but if the library is going to use the pthread primitives it might be necessary. Approved by: re/blanket libthr
* EDOOFUSmtm2003-05-231-10/+2
| | | | | | | | Prevent one thread from messing up another thread's saved signal mask by saving it in struct pthread instead of leaving it as a global variable. D'oh! Approved by: re/blanket libthr
* Make WARNS2 clean. The fixes mostly included:mtm2003-05-231-1/+1
| | | | | | | | o removed unused variables o explicit inclusion of header files o prototypes for externally defined functions Approved by: re/blanket libthr
* msg1mtm2003-05-121-0/+50
|
* Use STDERR_FILENO as the file descriptor passed to _thread_printf()marcel2003-04-201-4/+7
| | | | instead of 0 (ie stdin). Writing to stdin may not be possible.
* - Don't drop and reacquire giant in thread_suspend(). Change callers to dojeff2003-04-011-38/+4
| | | | | this manually. This will facilitate the unrolling of giant. - Don't allow giant to recurse anymore. This should never happen.
* - Add libthr but don't hook it up to the regular build yet. This is anjeff2003-04-011-0/+188
adaptation of libc_r for the thr system call interface. This is beta quality code.
OpenPOWER on IntegriCloud