summaryrefslogtreecommitdiffstats
path: root/lib/libkse
Commit message (Collapse)AuthorAgeFilesLines
* 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.
* Style.ru2003-07-021-2/+2
|
* Take thr_support.c out of SRCS so that it does not end up in libraries.ru2003-07-022-3/+8
| | | | | | Record the missing dependency of thr_libc.So on the libc_pic.a library. OK'ed by: kan
* 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
|
* Unbreak "make checkdpadd".ru2003-07-011-1/+1
|
* Axe AINC.ru2003-07-011-1/+0
| | | | Submitted by: bde
* 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-2813-586/+809
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | 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
* Implement _ia64_save_context() and _ia64_restore_context(). Bothmarcel2003-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).
* Implement _ia64_enter_uts(). The purpose of this function is to switchmarcel2003-06-263-1/+101
| | | | | | | | | the register stack and memory stack and call the function given to it. While here, provide empty, non-working, stubs for the context functions (_ia64_save_context() and _ia64_restore_context()) so that anyone can at least compile libkse from CVS sources. Real implementations will follow soon.
* Implement _thr_enter_uts() and _thr_switch() as inline functions tomarcel2003-06-261-0/+30
| | | | | | | | | | | minimize the amount and complexity of assembly code that needs to be written. This way the core functionality is spread over 3 elementary functions that don't have to do anything that can more easily and more safely be done in C. As such, assembly code will only have to know about the definition of mcontext_t. The runtime cost of not having these functions being inlined is less important than the cleanliness and maintainability of the code at this stage of the implementation.
* 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-235-3/+20
| | | | | | | | | | | | | | | | | | | 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.
* Define THR_{G|S}ETCONTEXT to expand to {g|s}etcontext(2).marcel2003-06-231-0/+38
| | | | Define THR_ALIGN to align at 16-byte boundaries.
* Implement atomic_swap_{int|long|ptr}. Define atomic_swap_ptr as amarcel2003-06-231-0/+47
| | | | | macro that expands to atomic_swap_long() to avoid compiler warnings caused by incompatible pointer passing.
* Move the machine specific files from sys/Makefile.inc and put themmarcel2003-06-234-6/+15
| | | | | in a machine specific makefile. While here, sort the sub-directories in Makefile and remove _atomic_lock.S from all makefiles.
* 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.
* Provide a reference to __sys_write. The implementation uses this whendeischen2003-06-081-0/+3
| | | | | | | | debugging is enabled so the symbol needs to be resolved before rtld locking is enabled. I may not really know what I'm talking about, but it works. Submitted by: kan
* Don't force -L/usr/lib. This is incorrect because we should not beimp2003-06-081-1/+1
| | | | | | | looking at the host environment for anything. This breaks building -CURRENT on 4.x as well. Submitted by: kan@
* Only init _thread_sigact once, needn't init it again after a fork().davidxu2003-06-041-31/+31
| | | | Obtained from: deischen
* Despite whether threaded mode is turned on, always save thread'sdavidxu2003-06-041-4/+6
| | | | signal mask.
* KMF_DONE is now in /sys/sys/kse.h, no longer need to define it here.davidxu2003-06-042-7/+0
|
* Free memory of internal low level lock when mutex and condition variabledavidxu2003-06-032-0/+9
| | | | | | are destroyed. Submitted by: tegge
* Save THR_FLAGS_IN_TDLIST in signal frame, otherwise if a thread receiveddavidxu2003-05-301-1/+2
| | | | | | | a signal will can not be removed from thread list after it exited. Reviewed by: deischen Approved by: re (jhb)
* Attempt to eliminate PLT relocations from rwlock aquire/releasekan2003-05-3012-21/+263
| | | | | | | | | | | path, making them suitable for direct use by the dynamic loader. Register libpthread-specific locking API with rtld on startup. This still has some rough edges with signals which should be addresses later. Approved by: re (scottl)
* Call the __sys_sigprocmask(the system call) when sigprocmask()deischen2003-05-301-1/+4
| | | | | | | | | is called and the application is not threaded. This works around a problem when an application that hasn't yet become threaded tries to jump out of a signal handler. Reported by: mbr Approved by: re@ (rwatson)
* Don't really spin on a spinlock; silently convert it to the samedeischen2003-05-294-16/+71
| | | | | | | | | | | | low-level lock used by the libpthread implementation. In the future, we'll eliminate spinlocks from libc but that will wait until after 5.1-release. Don't call an application signal handler if the handler is the same as the library-installed handler. This seems to be possible after a fork and is the cause of konsole hangs. Approved by: re@ (jhb)
* Change low-level locking a bit so that we can tell ifdeischen2003-05-2412-157/+297
| | | | | | | | | | | | | | | | | | | | | | | | | | a lock is being waitied on. Fix a races in join and cancellation. When trying to wait on a CV and the library is not yet threaded, make it threaded so that waiting actually works. When trying to nanosleep() and we're not threaded, just call the system call nanosleep instead of adding the thread to the wait queue. Clean up adding/removing new threads to the "all threads queue", assigning them unique ids, and tracking how many active threads there are. Do it all when the thread is added to the scheduling queue instead of making pthread_create() know how to do it. Fix a race where a thread could be marked for signal delivery but it could be exited before we actually add the signal to it. Other minor cleanups and bug fixes. Submitted by: davidxu Approved by: re@ (blanket for libpthread)
* Eek, staticize a couple of functions that shouldn'tdeischen2003-05-193-23/+21
| | | | | | | | | | | | be external (initialize()!). Remove cancellation points from _pthread_cond_wait and _pthread_cond_timedwait (single underscore versions are libc private functions). Point the weak reference(!) for these functions to the versions with cancellation points. Approved by: re@(blanket till 5/19) Pointed out by: kan (cancellation point bug)
* Add a method of yielding the current thread with the schedulerdeischen2003-05-1614-314/+343
| | | | | | | | | | | | | | | | | | | | | | | lock held (_thr_sched_switch_unlocked()) and use this to avoid dropping the scheduler lock and having the scheduler retake the same lock again. Add a better way of detecting if a low-level lock is in use. When switching out a thread due to blocking in the UTS, don't switch to the KSE's scheduler stack only to switch back to another thread. If possible switch to the new thread directly from the old thread and avoid the overhead of the extra context switch. Check for pending signals on a thread when entering the scheduler and add them to the threads signal frame. This includes some other minor signal fixes. Most of this was a joint effor between davidxu and myself. Reviewed by: davidxu Approved by: re@ (blanket for libpthread)
* Make pthread_join() async-cancel-safe. David was going to commitdeischen2003-05-061-9/+0
| | | | | | | this, but I think he's asleep and want to be sure it gets in before the freeze. Submitted by: davidxu
* call dump_queues() only when DEBUG_THREAD_KERN is defined, save somedavidxu2003-05-051-0/+2
| | | | cpu cycles.
* Protect against a race between granting a lock and accessingdeischen2003-05-042-7/+28
| | | | | | other parts of the lock. Submitted by: davidxu
* Fix suspend and resume.deischen2003-05-046-43/+47
| | | | Submitted (in part) by: Kazuaki Oda <kaakun@highway.ne.jp>
* Handle thread canceled case, it is same as signal caused backout,davidxu2003-05-021-1/+1
| | | | but will break out of loop.
* Move the mailbox to the beginning of the thread and align thedeischen2003-04-305-7/+24
| | | | thread so that the context (SSE FPU state) is also aligned.
OpenPOWER on IntegriCloud