summaryrefslogtreecommitdiffstats
path: root/lib/libthr
Commit message (Collapse)AuthorAgeFilesLines
* r179417 introduced a bug into pthread_once(). Previously pthread_once()rstone2011-04-201-0/+2
| | | | | | | | | | | | | | | | | used a global pthread_mutex_t for synchronization. r179417 replaced that with an implementation that directly used atomic instructions and thr_* syscalls to synchronize callers to pthread_once. However, calling pthread_mutex_lock on the global mutex implicitly ensured that _thr_check_init() had been called but with r179417 this was no longer guaranteed. This meant that if you were unlucky enough to have your first call into libthr be a call to pthread_once(), you would segfault when trying to access the pointer returned by _get_curthread(). The fix is to explicitly call _thr_check_init() from pthread_once(). Reviewed by: davidxu Approved by: emaste (mentor) MFC after: 1 week
* Introduce a non-portable function pthread_getthreadid_np(3) to retrievejkim2011-02-073-0/+51
| | | | | | | calling thread's unique integral ID, which is similar to AIX function of the same name. Bump __FreeBSD_version to note its introduction. Reviewed by: kib
* Fix a typo.davidxu2011-01-111-1/+1
| | | | Submitted by: avg
* For the process that already loaded libthr but still not initializedkib2011-01-101-0/+26
| | | | | | | threading, fall back to libc method of performing __pthread_map_stacks_exec() job. Reported and tested by: Mykola Dzham <i levsha me>
* Implement the __pthread_map_stacks_exec() for libthr.kib2011-01-095-1/+53
| | | | | | | | | | | | Stack creation code is changed to call _rtld_get_stack_prot() to get the stack protection right. There is a race where thread is created during dlopen() of dso that requires executable stacks. Then, _rtld_get_stack_prot() may return PROT_READ | PROT_WRITE, but thread is still not linked into the thread list. In this case, the callback misses the thread stack, and rechecks the required protection afterward. Reviewed by: davidxu
* Add section .note.GNU-stack for assembly files used by 386 and amd64.kib2011-01-072-0/+4
|
* Return 0 instead of garbage value.davidxu2011-01-061-2/+1
| | | | Found by: clang static analyzer
* Because sleepqueue may still being used, we should always check wchan withdavidxu2011-01-041-6/+0
| | | | queue locked.
* Always clear flag PMUTEX_FLAG_DEFERED when unlocking, as it is onlydavidxu2010-12-241-2/+2
| | | | significant for lock owner.
* Add sleep queue code.davidxu2010-12-221-0/+175
|
* MFp4:davidxu2010-12-229-191/+666
| | | | | | | | | | | | | | | - 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.
* Use sysctl kern.sched.cpusetsize to retrieve size of kernel cpuset.davidxu2010-11-021-8/+5
|
* Return previous sigaction correctly.davidxu2010-10-291-1/+4
| | | | Submitted by: avg
* Remove local variable 'first', instead check signal number in memory,davidxu2010-10-291-4/+1
| | | | | because the variable can be in register, second checking the variable may still return true, however this is unexpected.
* Check small set and reject it, this is how kernel did. Always use thedavidxu2010-10-271-37/+32
| | | | size kernel is using.
* - Revert r214409.davidxu2010-10-271-5/+6
| | | | - Use long word to figure out sizeof kernel cpuset, hope it works.
* Remove locking and unlock in pthread_mutex_destroy, becausedavidxu2010-10-271-25/+2
| | | | | it can not fix race condition in application code, as a result, the problem described in PR threads/151767 is avoided.
* Fix typo.davidxu2010-10-251-1/+1
|
* Get cpuset in pthread_attr_get_np() and free it in pthread_attr_destroy().davidxu2010-10-252-10/+31
| | | | MFC after: 7 days
* Revert revision 214007, I realized that MySQL wants to resolvedavidxu2010-10-204-52/+2
| | | | | | | a silly rwlock deadlock problem, the deadlock is caused by writer waiters, if a thread has already locked a reader lock, and wants to acquire another reader lock, it will be blocked by writer waiters, but we had already fixed it years ago.
* Set default type to PTHREAD_RWLOCK_PREFER_WRITER_NONRECURSIVE_NP, thisdavidxu2010-10-181-0/+1
| | | | is the type we are using.
* sort function name.davidxu2010-10-181-2/+2
|
* s/||/&&davidxu2010-10-181-2/+2
|
* Add pthread_rwlockattr_setkind_np and pthread_rwlockattr_getkind_np, thedavidxu2010-10-184-2/+50
| | | | | | | | | functions set or get pthread_rwlock type, current supported types are: PTHREAD_RWLOCK_PREFER_READER_NP, PTHREAD_RWLOCK_PREFER_WRITER_NONRECURSIVE_NP, PTHREAD_RWLOCK_PREFER_WRITER_NP, default is PTHREAD_RWLOCK_PREFER_WRITER_NONCECURSIVE_NP, this maintains binary compatible with old code.
* Oops, don't remove -fexceptions flag.davidxu2010-10-081-0/+1
|
* unwind.h was imported, gcc directory is no longer needed.davidxu2010-10-081-1/+0
|
* change code to use unwind.h.davidxu2010-09-302-5/+6
|
* Check invalid mutex in _mutex_cv_unlock.davidxu2010-09-291-0/+6
|
* In current code, statically initialized and destroyed object havedavidxu2010-09-285-195/+160
| | | | | | | | same null value, the code can not distinguish between them, to fix the problem, now a destroyed object is assigned to a non-null value, and it will be rejected by some pthread functions. PTHREAD_ADAPTIVE_MUTEX_INITIALIZER_NP is changed to number 1, so that adaptive mutex can be statically initialized correctly.
* Report death event to debugger before moving to gc list, otherwisedavidxu2010-09-261-3/+2
| | | | debugger may can not find it on thread list.
* Only access unwind_disabled when _PTHREAD_FORCED_UNWIND is defined.davidxu2010-09-251-1/+2
|
* Add missing field.davidxu2010-09-251-0/+1
|
* Because old _pthread_cleanup_push/pop do not have frame address,davidxu2010-09-252-13/+17
| | | | | | it is incompatible with stack unwinding code, if they are invoked, disable stack unwinding for current thread, and when thread is exiting, print a warning message.
* Simplify code, and in while loop, fix operator to match the unwindingdavidxu2010-09-251-7/+4
| | | | direction.
* To support stack unwinding for cancellation points, add -fexceptions flagdavidxu2010-09-255-5/+20
| | | | | | | for them, two functions _pthread_cancel_enter and _pthread_cancel_leave are added to let thread enter and leave a cancellation point, it also makes it possible that other functions can be cancellation points in libraries without having to be rewritten in libthr.
* inline testcancel() into thr_cancel_leave(), because cancel_pending isdavidxu2010-09-241-2/+3
| | | | almost false, this makes a slight better branch predicting.
* In most cases, cancel_point and cancel_async needn't be checked again,davidxu2010-09-243-5/+3
| | | | because cancellation is almostly checked at cancellation points.
* If we are at cancellation point, always work as deferred mode despitedavidxu2010-09-211-34/+32
| | | | | | whether asynchronous mode is turned on or not, this always gives us a chance to decide whether thread should be canceled or not in cancellation points.
* Because atfork lock is held while forking, a thread cancellation triggereddavidxu2010-09-194-12/+13
| | | | by atfork handler is unsafe, use intenal flag no_cancel to disable it.
* Fix typo.davidxu2010-09-191-1/+1
|
* - _Unwind_Resume function is not used, remove it.davidxu2010-09-191-14/+8
| | | | | | - Use a store barrier to make sure uwl_forcedunwind is lastest thing other threads can see. - Add some comments.
* Fix a race condition when finding stack unwinding functions.davidxu2010-09-191-7/+20
|
* add code to support stack unwinding when thread exits. note that onlydavidxu2010-09-156-1/+184
| | | | | | defer-mode cancellation works, asynchrnous mode does not work because it lacks of libuwind's support. stack unwinding is not enabled unless LIBTHR_UNWIND_STACK is defined in Makefile.
* Move back IN_GCLIST flag into field tlflags, since thread list and gc listdavidxu2010-09-151-6/+6
| | | | still share same lock.
* Don't compare thread pointers again.davidxu2010-09-131-3/+3
|
* Fix copy&paste problem.davidxu2010-09-131-2/+2
|
* Update symbol.davidxu2010-09-131-1/+1
|
* PS_DEAD state needs not be checked because _thr_find_thread() has alreadydavidxu2010-09-131-4/+0
| | | | checked it.
* Convert thread list lock from mutex to rwlock.davidxu2010-09-1315-129/+153
|
* Merge from tbemd, with a small amount of rework:imp2010-09-139-16/+11
| | | | | | | | | | For all libthr contexts, use ${MACHINE_CPUARCH} for all libc contexts, use ${MACHINE_ARCH} if it exists, otherwise use ${MACHINE_CPUARCH} Move some common code up a layer (the .PATH statement was the same in all the arch submakefiles). # Hope she hasn't busted powerpc64 with this...
OpenPOWER on IntegriCloud