summaryrefslogtreecommitdiffstats
path: root/lib/libkse
Commit message (Collapse)AuthorAgeFilesLines
* Direct call exit if thread was never created. This makes it safe to calldavidxu2003-08-181-0/+2
| | | | | | pthread_exit in main() without creating any thread. Tessted by: deischen
* Treat initial thread as scope system thread when KSE mode is not activateddavidxu2003-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
* 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.
* Don't run verify directly as that would require the perl script tomarcel2003-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.
* Always set tcb for bound thread, and switch tcb for M:N thread at correctdavidxu2003-08-131-7/+18
| | | | time.
* Don't forget to set kcb_self.davidxu2003-08-121-0/+1
|
* 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
* Allow gcc driver to process -r option iself, do not use -Wl,-r tokan2003-08-081-1/+1
| | | | | | | bypass it. Doing otherwise did not allow compiler to detect and disable conflicting options generated from specs. Reported by: jake
* Grok async contexts. When a thread is interrupted and an upcallmarcel2003-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).
* Fix a typo. s/Line/Like/deischen2003-08-061-1/+1
|
* Avoid a level of indirection to get from the thread pointer to themarcel2003-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.
* 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.
* Define the static TLS as an array of long double. This will guaranteemarcel2003-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).
* Use auto LDT allocation for i386.deischen2003-08-051-63/+6
|
* Rethink the MD interfaces for libpthread to account fordeischen2003-08-0517-284/+1094
| | | | | | | | | 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
* Define THR_GETCONTEXT and THR_SETCONTEXT in terms of the userlandmarcel2003-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.
* o In _ia64_save_context() clear the return registers except for r8.marcel2003-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.
* -15 is incorrect to be used to align stack to 16 bytes, use ~15 instead.davidxu2003-08-021-1/+1
|
* Take the same approach for i386 as that for ia64 and amd64. Usedeischen2003-07-314-113/+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
* Fix some typos, correctly jump into UTS.davidxu2003-07-311-2/+2
|
* 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
* Fix typo.davidxu2003-07-261-5/+5
|
* 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
* Add missing arguments to _amd64_restore_context() when called fromdeischen2003-07-201-2/+4
| | | | THR_SETCONTEXT().
* Override libc function raise(), in threading mode, raise() willdavidxu2003-07-192-0/+54
| | | | | | send signal to current thread. Reviewed by: deischen
* Add some very beta amd64 bits. These will also need some tweaking.deischen2003-07-195-0/+393
|
* 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-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
* 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.
OpenPOWER on IntegriCloud