summaryrefslogtreecommitdiff
path: root/lib/libpthread
Commit message (Collapse)AuthorAgeFilesLines
* Remove unused variable.David Xu2003-09-281-2/+0
| | | | Notes: svn path=/head/; revision=120554
* Relink libc_r.a, libc_r.so and libc_r_p.so from libthr to libkse.Marcel Moolenaar2003-09-271-0/+12
| | | | | | | | | | | | | | On ia64, where there's no libc_r at all, libkse is now the default thread library by virtue of these links. The reasons for this change are: 1. libkse is slated to become the default thread library anyway, 2. active development and maintenance is only present for libkse, 3. GNOME and KDE, both in the process of being supported on ia64, work better with KSE; even on ia64. Notes: svn path=/head/; revision=120533
* Add __volatile keyword.David Xu2003-09-261-2/+4
| | | | Notes: svn path=/head/; revision=120469
* s/ia64/alpha/gMarcel Moolenaar2003-09-261-5/+4
| | | | Notes: svn path=/head/; revision=120454
* pthread API should return error code in return value not in errno.David Xu2003-09-251-2/+2
| | | | | | | Reviewed by: deischen Notes: svn path=/head/; revision=120436
* If syscall failed, restore old sigaction and return error to thread.David Xu2003-09-251-11/+19
| | | | Notes: svn path=/head/; revision=120429
* As comments in _mutex_lock_backout state, only current threadDavid Xu2003-09-241-6/+4
| | | | | | | | | | | | | | | | | can clear the pointer to mutex, not the thread doing mutex handoff. Because _mutex_lock_backout does not hold scheduler lock while testing THR_FLAGS_IN_SYNCQ and then reading mutex pointer, it is possible mutex owner begin to unlock and handoff the mutex to the current thread, and mutex pointer will be cleared to NULL before current thread reading it, so current thread will end up with deferencing a NULL pointer, Fix the race by making mutex waiters to clear their mutex pointers. While I am here, also save inherited priority in mutex for PTHREAD_PRIO_INERIT mutex in mutex_trylock_common just like what we did in mutex_lock_common. Notes: svn path=/head/; revision=120403
* Free thread name memory if there is.David Xu2003-09-231-0/+4
| | | | Notes: svn path=/head/; revision=120370
* Save and restore timeout field for signal frame just like what we didDavid Xu2003-09-222-1/+4
| | | | | | | | | for interrupted field. Also in _thr_sig_handler, retrieve current signal mask from kernel not from ucp, the later is pre-unioned mask, not current signal mask. Notes: svn path=/head/; revision=120338
* Fix FPU state restoring bug by jumping to right position.David Xu2003-09-221-2/+2
| | | | Notes: svn path=/head/; revision=120337
* Print waitset correctly.David Xu2003-09-221-1/+1
| | | | Notes: svn path=/head/; revision=120325
* Make KSE_STACKSIZE machine dependent by moving it from thr_kern.c toMarcel Moolenaar2003-09-195-3/+8
| | | | | | | | | pthread_md.h. This commit only moves the definition; it does not change it for any of the platforms. This more easily allows 64-bit architectures (in particular) to pick a slightly larger stack size. Notes: svn path=/head/; revision=120263
* _ia64_break_setcontext() now takes a mcontext_t. While here, defineMarcel Moolenaar2003-09-191-10/+3
| | | | | | | | | | | | | | | THR_SETCONTEXT as PANIC(). The THR_SETCONTEXT macro is currently not used, which means that the definition we had could be wrong, overly pessimistic or unknowingly right. I don't like the odds... The new _ia64_break_setcontext() and corresponding kernel fixes make KSE mostly usable. There's still a case where we don't properly restore a context and end up with a NaT consumption fault (typically an indication for not handling NaT collection points correctly), but at least now mutex_d works... Notes: svn path=/head/; revision=120254
* Stop using the setcontext() syscall to restore an async context.Marcel Moolenaar2003-09-191-5/+5
| | | | | | | | Instead use the break instruction with an immediate specially created for us. Notes: svn path=/head/; revision=120253
* pthread api should return error code in return value, not in errno.David Xu2003-09-181-2/+1
| | | | Notes: svn path=/head/; revision=120197
* Fix a typo. Also turn on PTHREAD_SCOPE_SYSTEM after fork().David Xu2003-09-161-1/+2
| | | | Notes: svn path=/head/; revision=120109
* Remove a comment that questioned why the size of the FPUDaniel Eischen2003-09-161-10/+1
| | | | | | | | | | | | | | state for amd64 was twice as large as necessary. Peter recently fixed this, so the comment no longer applies. Also, since the size of struct mcontext changed, adjust the threads library version of get&set context to match. FYI, any change layout/size change to any arch's struct mcontext will likely need some minor changes in libpthread. Notes: svn path=/head/; revision=120108
* Fix bogus comment and assign sigmask in critical region, useDavid Xu2003-09-151-2/+4
| | | | | | | SIG_CANTMASK to remove unmaskable signal masks. Notes: svn path=/head/; revision=120079
* Fix a bogus comment, sigmask must be maintained correctly,David Xu2003-09-151-1/+1
| | | | | | | it will be inherited in pthread_create. Notes: svn path=/head/; revision=120078
* 1. Allocating and freeing lock related resource in _thr_alloc and _thr_freeDavid Xu2003-09-144-94/+87
| | | | | | | | | | | | | | to avoid potential memory leak, also fix a bug in pthread_create, contention scope should be inherited when PTHREAD_INHERIT_SCHED is set, and also check right field for PTHREAD_INHERIT_SCHED, scheduling inherit flag is in sched_inherit. 2. Execute hooks registered by atexit() on thread stack but not on scheduler stack. 3. Simplify some code in _kse_single_thread by calling xxx_destroy functions. Reviewed by: deischen Notes: svn path=/head/; revision=120074
* When invoking an old style signal handler, use true traditional BSD style toDavid Xu2003-09-141-6/+13
| | | | | | | | | invoke signal handler. Reviewed by: deischen Notes: svn path=/head/; revision=120073
* Respect POSIX specification, a value return from pthread_attr_getguardsizeDavid Xu2003-09-142-16/+18
| | | | | | | | | | | | should be a value past to pthread_attr_setguardsize, not a rounded up value. Also fix a stack size matching bug in thr_stack.c, now stack matching code uses number of pages but not bytes length to match stack size, so for example, size 512 bytes and size 513 bytes should both match 1 page stack size. Reviewed by: deischen Notes: svn path=/head/; revision=120072
* Avoid garbage bits in c_flags by direct assigning value.David Xu2003-09-141-1/+1
| | | | | | | Reviewed by: deischen Notes: svn path=/head/; revision=120069
* If user is seting scope process flag, clear PTHREAD_SCOPE_SYSTEM bitDavid Xu2003-09-141-2/+4
| | | | | | | | | accordingly. Reviewed by: deischen Notes: svn path=/head/; revision=120068
* Check invalid parameter and return EINVAL.David Xu2003-09-141-0/+3
| | | | | | | Reviewed by: deischen Notes: svn path=/head/; revision=120066
* Get rid of duplicates.Ruslan Ermilov2003-09-141-1/+1
| | | | Notes: svn path=/head/; revision=120054
* Original pthread_once code has memory leak if pthread_once_t is used inDavid Xu2003-09-092-9/+52
| | | | | | | | | | | | | | | | | | a shared library or any other dyanmic allocated data block, once pthread_once_t is initialized, a mutex is allocated, if we unload the shared library or free those data block, then there is no way to deallocate the mutex, result is memory leak. To fix this problem, we don't use mutex field in pthread_once_t, instead, we use its state field and an internal mutex and conditional variable in libkse to do any synchronization, we introduce a third state IN_PROGRESS to wait if another thread is already in invoking init_routine(). Also while I am here, make pthread_once() conformed to pthread cancellation point specification. Reviewed by: deischen Notes: svn path=/head/; revision=119928
* Add code to support pthread spin lock.David Xu2003-09-094-0/+171
| | | | | | | Reviewed by: deischen Notes: svn path=/head/; revision=119909
* mdoc(7): Use the new feature of the .In macro.Ruslan Ermilov2003-09-081-1/+1
| | | | Notes: svn path=/head/; revision=119893
* Add small piece of code to support pthread_rwlock_timedrdlock andDavid Xu2003-09-062-8/+47
| | | | | | | pthread_rwlock_timedrwlock. Notes: svn path=/head/; revision=119790
* The caller is expected to set up PIC register corectly beforeAlexander Kabaev2003-09-051-0/+2
| | | | | | | | jumping to .cerror. This means .cerror has to be present in the same module with its consumers, or bad things will happen. Notes: svn path=/head/; revision=119777
* Add code to support barrier synchronous object and implementDavid Xu2003-09-047-6/+363
| | | | | | | | | pthread_mutex_timedlock(). Reviewed by: deischen Notes: svn path=/head/; revision=119736
* Remove repeated macro THR_IN_CONDQ.David Xu2003-09-041-1/+0
| | | | Notes: svn path=/head/; revision=119733
* Allow hooks registered by atexit() to run with current thread pointer set,David Xu2003-09-041-1/+4
| | | | | | | without this change, my atexit test dumps core. Notes: svn path=/head/; revision=119732
* Don't assume sizeof(long) = sizeof(int) on x86; use intDaniel Eischen2003-09-0313-21/+63
| | | | | | | | | | | | | | | instead of long types for low-level locks. Add prototypes for some internal libc functions that are wrapped by the library as cancellation points. Add memory barriers to alpha atomic swap functions (submitted by davidxu). Requested by: bde Notes: svn path=/head/; revision=119723
* Move kse_wakeup_multi call to just before KSE_SCHED_UNLOCK.David Xu2003-09-031-4/+2
| | | | | | | Tested on: SMP Notes: svn path=/head/; revision=119700
* Rethink the way thr_libc.So is generated. Relying on GCC to extractAlexander Kabaev2003-09-022-10/+32
| | | | | | | | | only needed symbols from libc_pic is not working on sparc64. Requested by: jake Notes: svn path=/head/; revision=119693
* Allow the concurrency level to be reduced.Daniel Eischen2003-08-303-35/+63
| | | | | | | Reviewed by: davidxu Notes: svn path=/head/; revision=119577
* Repost masked signal to kernel for scope system thread, it hardly happensDavid Xu2003-08-211-6/+25
| | | | | | | | | in real world. Reviewed by: deischen Notes: svn path=/head/; revision=119249
* _thr_sig_check_pending is also called by scope system thread when it leavesDavid Xu2003-08-201-0/+3
| | | | | | | | | | | | critical region, we wrap some syscalls for thread cancellation point, and when syscalls returns, we call _thr_leave_cancellation_point, at the time if a signal comes in, it would be buffered, and when the thread leaves _thr_leave_cancellation_point, buffered signals will be processed, to avoid messing up normal syscall errno, we should save and restore errno around signal handling code. Notes: svn path=/head/; revision=119177
* Add back a loop for up to PTHREAD_DESTRUCTOR_ITERATIONS toDaniel Eischen2003-08-201-12/+20
| | | | | | | | | | destroy thread-specific data. Display a warning when thread specific data remains after PTHREAD_DESTRUCTOR_ITERATIONS. Reviewed by: davidxu Notes: svn path=/head/; revision=119154
* Support printing 64 bits pointer and long integer.David Xu2003-08-191-10/+27
| | | | | | | Reviewed by: deischen Notes: svn path=/head/; revision=119117
* Save and restore errno around sigprocmask.David Xu2003-08-191-1/+5
| | | | Notes: svn path=/head/; revision=119099
* Direct call exit if thread was never created. This makes it safe to callDavid Xu2003-08-181-0/+2
| | | | | | | | | pthread_exit in main() without creating any thread. Tessted by: deischen Notes: svn path=/head/; revision=119064
* Treat initial thread as scope system thread when KSE mode is not activatedDavid Xu2003-08-1812-81/+47
| | | | | | | | | | | | yet, so we can protect some locking code from being interrupted by signal handling. When KSE mode is turned on, reset the thread flag to scope process except we are running in 1:1 mode which we needn't turn it off. Also remove some unused member variables in structure kse. Tested by: deischen Notes: svn path=/head/; revision=119063
* If threaded mode is not turned on yet, direct call __sys_sched_yield.David Xu2003-08-161-2/+3
| | | | Notes: svn path=/head/; revision=118989
* Keep initial kse and kse group just like we keep initial thread,David Xu2003-08-161-9/+11
| | | | | | | | | Don't free them, so some code can still reference them. Reviewed by: deischen Notes: svn path=/head/; revision=118985
* Access user provided pointer out of lock, and also check the case whenDavid Xu2003-08-161-8/+10
| | | | | | | a key is less than 0. Notes: svn path=/head/; revision=118984
* Don't run verify directly as that would require the perl script toMarcel Moolenaar2003-08-131-3/+4
| | | | | | | | | have execute permissions. Run "perl verify" instead. Replace all occurences of the hardcoding of ./verify with $(VERIFY) to allow it to be overridden as well. Notes: svn path=/head/; revision=118854
* Always set tcb for bound thread, and switch tcb for M:N thread at correctDavid Xu2003-08-131-7/+18
| | | | | | | time. Notes: svn path=/head/; revision=118850