summaryrefslogtreecommitdiff
path: root/lib/libpthread
Commit message (Collapse)AuthorAgeFilesLines
* 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
* Don't forget to set kcb_self.David Xu2003-08-121-0/+1
| | | | Notes: svn path=/head/; revision=118844
* Correctly set current tcb. This fixes some IA64/KSE problems.David Xu2003-08-121-17/+11
| | | | | | | Reviewed by: deischen, julian Notes: svn path=/head/; revision=118817
* Add some quick pathes to exit process when signal action is default andDavid Xu2003-08-101-0/+21
| | | | | | | | | signal can causes process to exit. Reviewed by: deischen Notes: svn path=/head/; revision=118748
* Initialize rtld lock just before turning on thread mode andDavid Xu2003-08-103-35/+37
| | | | | | | uninitialize rtld lock after thread mode shutdown. Notes: svn path=/head/; revision=118747
* If thread mode is not activated yet, just call __sys_fork() directly,David Xu2003-08-101-1/+22
| | | | | | | | | | | otherwise masks all signals until fork() returns, in child process, we reset library state before restoring signal masks until we reach a safe to point. Reviewed by: deischen Notes: svn path=/head/; revision=118746
* Tweak rtld lock to allow recursive on reader lock and detect recursiveDavid Xu2003-08-101-10/+67
| | | | | | | | | on writer lock. This is first cut at rwlock for rtld. Submitted by: desichen Notes: svn path=/head/; revision=118745
* If thread mode is not activated yet, don't do extra work.David Xu2003-08-101-0/+4
| | | | | | | Reviewed by: deischen Notes: svn path=/head/; revision=118744
* Add alpha support to libpthread. It compiles but hasn't been tested;Daniel Eischen2003-08-096-1/+761
| | | | | | | | | there is still some missing kernel support. Reviewed by: marcel Notes: svn path=/head/; revision=118689
* o Add code to GC freed KSEs and KSE groupsDavid Xu2003-08-081-25/+116
| | | | | | | | | | o Fix a bug in kse_free_unlocked(), kcb_dtor shouldn't be called because the KSE is cached and will be resued in _kse_alloc(). Reviewed by: deischen Notes: svn path=/head/; revision=118676
* Allow gcc driver to process -r option iself, do not use -Wl,-r toAlexander Kabaev2003-08-081-1/+1
| | | | | | | | | | bypass it. Doing otherwise did not allow compiler to detect and disable conflicting options generated from specs. Reported by: jake Notes: svn path=/head/; revision=118644
* Grok async contexts. When a thread is interrupted and an upcallMarcel Moolenaar2003-08-072-9/+41
| | | | | | | | | | | | | | | | | | | | | | | | happens, the context of the interrupted thread is exported to userland. Unlike most contexts, it will be an async context and we cannot easily use our existing functions to set such a context. To avoid a lot of complexity that may possibly interfere with the common case, we simply let the kernel deal with it. However, we don't use the EPC based syscall path to invoke setcontext(2). No, we use the break-based syscall path. That way the trapframe will be compatible with the context we're trying to restore and we save the kernel a lot of trouble. The kind of trouble we did not want to go though ourselves... However, we also need to set the threads mailbox and there's no syscall to help us out. To avoid creating a new syscall, we use the context itself to pass the information to the kernel so that the kernel can update the mailbox. This involves setting a flag (_MC_FLAGS_KSE_SET_MBOX) and setting ifa (the address) and isr (the value). Notes: svn path=/head/; revision=118592
* Fix a typo. s/Line/Like/Daniel Eischen2003-08-061-1/+1
| | | | Notes: svn path=/head/; revision=118519
* Avoid a level of indirection to get from the thread pointer to theMarcel Moolenaar2003-08-062-39/+27
| | | | | | | | | | | | | | TCB. We know that the thread pointer points to &tcb->tcb_tp, so all we have to do is subtract offsetof(struct tcb, tcb_tp) from the thread pointer to get to the TCB. Any reasonably smart compiler will translate accesses to fields in the TCB as negative offsets from TP. In _tcb_set() make sure the fake TCB gets a pointer to the current KCB, just like any other TCB. This fixes a NULL-pointer dereference in _thr_ref_add() when it tried to get the current KSE. Notes: svn path=/head/; revision=118518
* Don't call kse_set_curthread() when scheduling a new boundDaniel Eischen2003-08-061-2/+3
| | | | | | | | | | thread. It should only be called by the current kse and never by a KSE on behalf of another. Submitted by: davidxu Notes: svn path=/head/; revision=118516
* Fix an off by one error in the number of arguments passed toMarcel Moolenaar2003-08-061-1/+1
| | | | | | | | | makecontext(). We only supply 3, not 4. This is mostly harmless, except that on ia64 the garbage can include NaT bits, resulting in NaT consumption faults. Notes: svn path=/head/; revision=118514
* Define the static TLS as an array of long double. This will guaranteeMarcel Moolenaar2003-08-061-2/+6
| | | | | | | | | | that the TLS is 16-byte aligned, as well as guarantee that the thread pointer is 16-byte aligned as it points to struct ia64_tp. Likewise, struct tcb and struct ksd are also guaranteed to be 16-byte aligned (if they weren't already). Notes: svn path=/head/; revision=118513
* Use auto LDT allocation for i386.Daniel Eischen2003-08-051-63/+6
| | | | Notes: svn path=/head/; revision=118512
* Rethink the MD interfaces for libpthread to account forDaniel Eischen2003-08-0520-676/+983
| | | | | | | | | | | | archs that can (or are required to) have per-thread registers. Tested on i386, amd64; marcel is testing on ia64 and will have some follow-up commits. Reviewed by: davidxu Notes: svn path=/head/; revision=118510
* Define THR_GETCONTEXT and THR_SETCONTEXT in terms of the userlandMarcel Moolenaar2003-08-051-4/+5
| | | | | | | | | | | | context functions. We don't need to enter the kernel anymore. The contexts are compatible (ie a context created by getcontext() can be restored by _ia64_restore_context()). While here, make the use of THR_ALIGNBYTES and THR_ALIGN a no-op. They are going to be removed anyway. Notes: svn path=/head/; revision=118507
* o In _ia64_save_context() clear the return registers except for r8.Marcel Moolenaar2003-08-051-13/+25
| | | | | | | | | | | | | We write 1 for r8 in the context so that _ia64_restore_context() will return with a non-zero value. _ia64_save_context() always return 0. o In _ia64_restore_context(), don't restore the thread pointer. It is not normally part of the context. Also, restore the return registers. We get called for contexts created by getcontext(), which means we have to restore all the syscall return values. Notes: svn path=/head/; revision=118504
* -15 is incorrect to be used to align stack to 16 bytes, use ~15 instead.David Xu2003-08-021-1/+1
| | | | Notes: svn path=/head/; revision=118368
* Use FSBase to map kse, GCC generates code which uses %fs to access TLS data.David Xu2003-07-311-4/+4
| | | | | | | Reminded by: marcel Notes: svn path=/head/; revision=118285
* This file hasn't been used for some time; nuke it.Daniel Eischen2003-07-311-42/+0
| | | | Notes: svn path=/head/; revision=118279