summaryrefslogtreecommitdiffstats
path: root/lib/libpthread/thread
Commit message (Collapse)AuthorAgeFilesLines
* If threaded mode is not turned on yet, direct call __sys_sched_yield.davidxu2003-08-161-2/+3
|
* Keep initial kse and kse group just like we keep initial thread,davidxu2003-08-161-9/+11
| | | | | | Don't free them, so some code can still reference them. Reviewed by: deischen
* Access user provided pointer out of lock, and also check the case whendavidxu2003-08-161-8/+10
| | | | a key is less than 0.
* Always set tcb for bound thread, and switch tcb for M:N thread at correctdavidxu2003-08-131-7/+18
| | | | time.
* Correctly set current tcb. This fixes some IA64/KSE problems.davidxu2003-08-121-17/+11
| | | | Reviewed by: deischen, julian
* Add some quick pathes to exit process when signal action is default anddavidxu2003-08-101-0/+21
| | | | | | signal can causes process to exit. Reviewed by: deischen
* Initialize rtld lock just before turning on thread mode anddavidxu2003-08-103-35/+37
| | | | uninitialize rtld lock after thread mode shutdown.
* If thread mode is not activated yet, just call __sys_fork() directly,davidxu2003-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
* Tweak rtld lock to allow recursive on reader lock and detect recursivedavidxu2003-08-101-10/+67
| | | | | | on writer lock. This is first cut at rwlock for rtld. Submitted by: desichen
* If thread mode is not activated yet, don't do extra work.davidxu2003-08-101-0/+4
| | | | Reviewed by: deischen
* o Add code to GC freed KSEs and KSE groupsdavidxu2003-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
* Don't call kse_set_curthread() when scheduling a new bounddeischen2003-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
* Fix an off by one error in the number of arguments passed tomarcel2003-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.
* Rethink the MD interfaces for libpthread to account fordeischen2003-08-057-210/+197
| | | | | | | | | 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
* sysctlbyname needs size_t type, not int.davidxu2003-07-311-1/+1
|
* Don't forget to unlock the scheduler lock. Somehow this got removeddeischen2003-07-301-0/+1
| | | | | | | from one of my last commits. This only affected priority ceiling mutexes. Pointy hat to: deischen
* Simplify sigwait code a bit by using a waitset and removing oldsigmask.davidxu2003-07-273-22/+17
| | | | Reviewed by: deischen
* Move idle kse wakeup to outside of regions where locks are held.deischen2003-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
* Override libc function raise(), in threading mode, raise() willdavidxu2003-07-192-0/+54
| | | | | | send signal to current thread. Reviewed by: deischen
* Cleanup thread accounting. Don't reset a threads timeslicedeischen2003-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
* Add a preemption point when a mutex or condition variable isdeischen2003-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
* o Eliminate upcall for PTHREAD_SYSTEM_SCOPE thread, now itdavidxu2003-07-1714-395/+596
| | | | | | | | | | | | | 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
* Don't resume sigwait thread If signal is masked.davidxu2003-07-091-8/+12
|
* POSIX says if a thread is in sigwait state, although a signal may not indavidxu2003-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.
* Restore signal mask correctly after fork().davidxu2003-07-092-4/+6
|
* Save and restore thread's error code around signal handling.davidxu2003-07-091-1/+2
| | | | Reviewed by: deischen
* Correctly print signal mask, the bug was introduced by cut and pastedavidxu2003-07-071-11/+20
| | | | in last commit.
* Add a newline to debug message.davidxu2003-07-071-1/+1
|
* Avoid accessing user provided parameters in critical region.davidxu2003-07-079-46/+65
| | | | Reviewed by: deischen
* Print thread's scope, also print signal mask for every thread and printdavidxu2003-07-071-17/+13
| | | | it in one line.
* Correctly lock/unlock signal lock. I must be in bad state, need to sleep.davidxu2003-07-041-1/+2
|
* Always check and restore sigaction previously set, also access user parameterdavidxu2003-07-041-4/+7
| | | | outside of lock.
* If select() is only used for sleep, convert it to nanosleep,davidxu2003-07-031-4/+9
| | | | it only need purely wait in user space.
* Check if thread is in critical region, only testing check_pendingdavidxu2003-07-031-1/+2
| | | | is not enough.
* Set unlock_mutex to 1 after locked mutex.davidxu2003-07-021-2/+4
| | | | | Use THR_CONDQ_CLEAR not THR_COND_SET in cond_queue_deq, current cond_queue_deq is not used.
* Fix typo.davidxu2003-07-021-1/+1
|
* Because there are only _SIG_MAXSIG elements in thread siginfo array,davidxu2003-06-303-16/+16
| | | | use [signal number - 1] as subscript to access the array.
* Remove surplus unlocking code I accidentally checked in. This won't bedavidxu2003-06-301-4/+0
| | | | triggered until LDT entry is exhausted.
* o Use a daemon thread to monitor signal events in kernel, if pendingdavidxu2003-06-2812-586/+806
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | 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().
* Use mmap retuned value.davidxu2003-06-281-2/+3
| | | | Reviewed by: deischen
* Temporary disable rwlock based code, replace it with low level KSE lockingdavidxu2003-06-281-0/+92
| | | | | | | code until rtld-elf and libkse can cooperate better, those code can be restored. Reviewed by: deischen
* Write new thread pointer back only when success.davidxu2003-06-281-3/+4
| | | | Reviewed by: deischen
* After thread was interrupted by signal, it should relock mutex.davidxu2003-06-281-2/+1
| | | | Reviewed by: deischen
* if thread is exiting, just returns. kse_thr_interrupt interfacedavidxu2003-06-281-2/+6
| | | | | | | was changed, it needs signal parameter, pass -1 to it, it indicates to interrupt syscall. Reviewed by: deischen
* Explicitly widen int types before casting to pointer types. On 64-bitmarcel2003-06-241-3/+4
| | | | | | | | platforms the compiler warns about incompatible integer/pointer casts and on ia64 this generally is bad news. We know that what we're doing here is valid/correct, so suppress the warning. No functional change. Sleeps better: marcel
* Untangle the inter-dependency of kse types and ksd types/functionsmarcel2003-06-232-2/+1
| | | | | | | | | | | | | | | | | | | by moving the definition of struct ksd to pthread_md.h and removing the inclusion of ksd.h from thr_private.h (which has the definition of struct kse and kse_critical_t). This allows ksd.h to have inline functions that use struct kse and kse_critical_t and generally yields a cleaner implementation at the cost of not having all ksd related types/definitions in one header. Implement the ksd functionality on ia64 by using inline functions and permanently remove ksd.c from the ia64 specific makefile. This change does not clean up the i386 specific version of ksd.h. NOTE: The ksd code on ia64 abuses the tp register in the same way as it is abused in libthr in that it is incompatible with the runtime specification. This will be address when support for TLS hits the tree.
* Change the definition of _ksd_curkse, _ksd_curthread andmarcel2003-06-231-3/+3
| | | | | | | | | _ksd_readandclear_tmbx to be function-like. That way we can define them as inline functions or create prototypes for them. This change allows the ksd interface on ia64 to be fully inlined.
* Don't lock scheduler lock twice.davidxu2003-06-181-2/+1
|
* After selecting a thread to handle a signal and takingdeischen2003-06-081-3/+8
| | | | | | | | its scheduling lock, make sure that the thread still has the signal unmasked. Make a debug statement conditional on debugging being enabled.
* Insert threads at the end of the free thread list so thatdeischen2003-06-081-1/+1
| | | | | | | the chance of getting the same thread id when allocating a new thread is reduced. This won't work if the application creates a new thread for every time a thread exits, but we're still within the allowances of POSIX.
OpenPOWER on IntegriCloud