summaryrefslogtreecommitdiff
path: root/lib/libpthread
Commit message (Collapse)AuthorAgeFilesLines
* 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
* Take the same approach for i386 as that for ia64 and amd64. UseDaniel Eischen2003-07-315-226/+75
| | | | | | | | | | | | the userland version of [gs]etcontext to switch between a thread and the UTS scheduler (and back again). This also fixes a bug in i386 _thr_setcontext() which wasn't properly restoring the context. Reviewed by: davidxu Notes: svn path=/head/; revision=118277
* Set GSBASE for kse. Finally make libkse work on AMD64.David Xu2003-07-311-6/+3
| | | | Notes: svn path=/head/; revision=118257
* Fix some typos, correctly jump into UTS.David Xu2003-07-311-2/+2
| | | | Notes: svn path=/head/; revision=118256
* sysctlbyname needs size_t type, not int.David Xu2003-07-311-1/+1
| | | | Notes: svn path=/head/; revision=118254
* Don't forget to unlock the scheduler lock. Somehow this got removedDaniel Eischen2003-07-301-0/+1
| | | | | | | | | | from one of my last commits. This only affected priority ceiling mutexes. Pointy hat to: deischen Notes: svn path=/head/; revision=118206
* Simplify sigwait code a bit by using a waitset and removing oldsigmask.David Xu2003-07-273-22/+17
| | | | | | | Reviewed by: deischen Notes: svn path=/head/; revision=118075
* Fix typo.David Xu2003-07-261-5/+5
| | | | Notes: svn path=/head/; revision=118037
* Move idle kse wakeup to outside of regions where locks are held.Daniel Eischen2003-07-238-73/+130
| | | | | | | | | | | This eliminates ping-ponging of locks, where the idle KSE wakes up only to find the lock it needs is being held. This gives little or no gain to M:N mode but greatly speeds up 1:1 mode. Reviewed & Tested by: davidxu Notes: svn path=/head/; revision=117907
* Add missing arguments to _amd64_restore_context() when called fromDaniel Eischen2003-07-201-2/+4
| | | | | | | THR_SETCONTEXT(). Notes: svn path=/head/; revision=117807
* Override libc function raise(), in threading mode, raise() willDavid Xu2003-07-193-0/+56
| | | | | | | | | send signal to current thread. Reviewed by: deischen Notes: svn path=/head/; revision=117758
* Add some very beta amd64 bits. These will also need some tweaking.Daniel Eischen2003-07-196-0/+528
| | | | Notes: svn path=/head/; revision=117756
* Cleanup thread accounting. Don't reset a threads timesliceDaniel Eischen2003-07-183-38/+27
| | | | | | | | | | | when it blocks; it only gets reset when it yields. Properly set a thread's default stack guardsize. Reviewed by: davidxu Notes: svn path=/head/; revision=117715
* Add a preemption point when a mutex or condition variable isDaniel Eischen2003-07-182-6/+18
| | | | | | | | | | | | | | | | | | handed-off/signaled to a higher priority thread. Note that when there are idle KSEs that could run the higher priority thread, we still add the preemption point because it seems to take the kernel a while to schedule an idle KSE. The drawbacks are that threads will be swapped more often between CPUs (KSEs) and that there will be an extra userland context switch (the idle KSE is still woken and will probably resume the preempted thread). We'll revisit this if and when idle CPU/KSE wakeup times improve. Inspired by: Petri Helenius <pete@he.iki.fi> Reviewed by: davidxu Notes: svn path=/head/; revision=117714
* Clean up KSE specific data (KSD) macros a bit.Daniel Eischen2003-07-181-29/+8
| | | | | | | Reviewed by: davidxu Notes: svn path=/head/; revision=117713
* o Eliminate upcall for PTHREAD_SYSTEM_SCOPE thread, now itDavid Xu2003-07-1716-395/+602
| | | | | | | | | | | | | | | | is system bound thread and when it is blocked, no upcall is generated. o Add ability to libkse to allow it run in pure 1:1 threading mode, defining SYSTEM_SCOPE_ONLY in Makefile can turn on this option. o Eliminate code for installing dummy signal handler for sigwait call. o Add hash table to find thread. Reviewed by: deischen Notes: svn path=/head/; revision=117706
* Don't resume sigwait thread If signal is masked.David Xu2003-07-091-8/+12
| | | | Notes: svn path=/head/; revision=117366
* POSIX says if a thread is in sigwait state, although a signal may not inDavid Xu2003-07-092-11/+29
| | | | | | | | | | | its waitset, but if the signal is not masked by the thread, the signal can interrupt the thread and signal action can be invoked by the thread, sigwait should return with errno set to EINTR. Also save and restore thread internal state(timeout and interrupted) around signal handler invoking. Notes: svn path=/head/; revision=117353
* Restore signal mask correctly after fork().David Xu2003-07-092-4/+6
| | | | Notes: svn path=/head/; revision=117345
* Save and restore thread's error code around signal handling.David Xu2003-07-091-1/+2
| | | | | | | Reviewed by: deischen Notes: svn path=/head/; revision=117344
* Correctly print signal mask, the bug was introduced by cut and pasteDavid Xu2003-07-071-11/+20
| | | | | | | in last commit. Notes: svn path=/head/; revision=117305
* Add a newline to debug message.David Xu2003-07-071-1/+1
| | | | Notes: svn path=/head/; revision=117301
* Avoid accessing user provided parameters in critical region.David Xu2003-07-079-46/+65
| | | | | | | Reviewed by: deischen Notes: svn path=/head/; revision=117300
* Print thread's scope, also print signal mask for every thread and printDavid Xu2003-07-071-17/+13
| | | | | | | it in one line. Notes: svn path=/head/; revision=117297
* Correctly lock/unlock signal lock. I must be in bad state, need to sleep.David Xu2003-07-041-1/+2
| | | | Notes: svn path=/head/; revision=117217
* Always check and restore sigaction previously set, also access user parameterDavid Xu2003-07-041-4/+7
| | | | | | | outside of lock. Notes: svn path=/head/; revision=117216
* If select() is only used for sleep, convert it to nanosleep,David Xu2003-07-031-4/+9
| | | | | | | it only need purely wait in user space. Notes: svn path=/head/; revision=117197
* Check if thread is in critical region, only testing check_pendingDavid Xu2003-07-031-1/+2
| | | | | | | is not enough. Notes: svn path=/head/; revision=117193
* Style.Ruslan Ermilov2003-07-021-2/+2
| | | | Notes: svn path=/head/; revision=117179
* Take thr_support.c out of SRCS so that it does not end up in libraries.Ruslan Ermilov2003-07-022-3/+8
| | | | | | | | | Record the missing dependency of thr_libc.So on the libc_pic.a library. OK'ed by: kan Notes: svn path=/head/; revision=117178
* Set unlock_mutex to 1 after locked mutex.David Xu2003-07-021-2/+4
| | | | | | | | Use THR_CONDQ_CLEAR not THR_COND_SET in cond_queue_deq, current cond_queue_deq is not used. Notes: svn path=/head/; revision=117165
* Fix typo.David Xu2003-07-021-1/+1
| | | | Notes: svn path=/head/; revision=117162
* Unbreak "make checkdpadd".Ruslan Ermilov2003-07-011-1/+1
| | | | Notes: svn path=/head/; revision=117125
* Axe AINC.Ruslan Ermilov2003-07-011-1/+0
| | | | | | | Submitted by: bde Notes: svn path=/head/; revision=117120
* Because there are only _SIG_MAXSIG elements in thread siginfo array,David Xu2003-06-303-16/+16
| | | | | | | use [signal number - 1] as subscript to access the array. Notes: svn path=/head/; revision=117066
* Remove surplus unlocking code I accidentally checked in. This won't beDavid Xu2003-06-301-4/+0
| | | | | | | triggered until LDT entry is exhausted. Notes: svn path=/head/; revision=117063
* o Use a daemon thread to monitor signal events in kernel, if pendingDavid Xu2003-06-2814-586/+813
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | signals were changed in kernel, it will retrieve the pending set and try to find a thread to dispatch the signal. The dispatching process can be rolled back if the signal is no longer in kernel. o Create two functions _thr_signal_init() and _thr_signal_deinit(), all signal action settings are retrieved from kernel when threading mode is turned on, after a fork(), child process will reset them to user settings by calling _thr_signal_deinit(). when threading mode is not turned on, all signal operations are direct past to kernel. o When a thread generated a synchoronous signals and its context returned from completed list, UTS will retrieve the signal from its mailbox and try to deliver the signal to thread. o Context signal mask is now only used when delivering signals, thread's current signal mask is always the one in pthread structure. o Remove have_signals field in pthread structure, replace it with psf_valid in pthread_signal_frame. when psf_valid is true, in context switch time, thread will backout itself from some mutex/condition internal queues, then begin to process signals. when a thread is not at blocked state and running, check_pending indicates there are signals for the thread, after preempted and then resumed time, UTS will try to deliver signals to the thread. o At signal delivering time, not only pending signals in thread will be scanned, process's pending signals will be scanned too. o Change sigwait code a bit, remove field sigwait in pthread_wait_data, replace it with oldsigmask in pthread structure, when a thread calls sigwait(), its current signal mask is backuped to oldsigmask, and waitset is copied to its signal mask and when the thread gets a signal in the waitset range, its current signal mask is restored from oldsigmask, these are done in atomic fashion. o Two additional POSIX APIs are implemented, sigwaitinfo() and sigtimedwait(). o Signal code locking is better than previous, there is fewer race conditions. o Temporary disable most of code in _kse_single_thread as it is not safe after fork(). Notes: svn path=/head/; revision=116977
* Use mmap retuned value.David Xu2003-06-281-2/+3
| | | | | | | Reviewed by: deischen Notes: svn path=/head/; revision=116976
* Temporary disable rwlock based code, replace it with low level KSE lockingDavid Xu2003-06-281-0/+92
| | | | | | | | | | code until rtld-elf and libkse can cooperate better, those code can be restored. Reviewed by: deischen Notes: svn path=/head/; revision=116975
* Write new thread pointer back only when success.David Xu2003-06-281-3/+4
| | | | | | | Reviewed by: deischen Notes: svn path=/head/; revision=116974
* After thread was interrupted by signal, it should relock mutex.David Xu2003-06-281-2/+1
| | | | | | | Reviewed by: deischen Notes: svn path=/head/; revision=116973
* if thread is exiting, just returns. kse_thr_interrupt interfaceDavid Xu2003-06-281-2/+6
| | | | | | | | | | was changed, it needs signal parameter, pass -1 to it, it indicates to interrupt syscall. Reviewed by: deischen Notes: svn path=/head/; revision=116972
* Implement _ia64_save_context() and _ia64_restore_context(). BothMarcel Moolenaar2003-06-271-0/+285
| | | | | | | | | | | | | | | | | | | functions are derived from the swapctx() and restorectx() (resp) from sys/ia64/ia64/context.s. The code is expected to be 99% correct, but has not yet been tested. Note that with these functions operating on mcontext_t, we also created the foundation upon which we can implement getcontext(2) and setcontext(2) replacements. It's not guaranteed that the use of these syscalls and _ia64_{save|restore}_context() on the same uicontext_t is actually going to work. Replacing the syscalls is now trivially achieved. This commit completes the ia64 port of libpthread itself (modulo testing and bugfixes). Notes: svn path=/head/; revision=116905