summaryrefslogtreecommitdiffstats
path: root/lib/libpthread/arch
Commit message (Collapse)AuthorAgeFilesLines
...
* Stop using the setcontext() syscall to restore an async context.marcel2003-09-191-5/+5
| | | | | Instead use the break instruction with an immediate specially created for us.
* Remove a comment that questioned why the size of the FPUdeischen2003-09-161-10/+1
| | | | | | | | | | | state for amd64 was twice as large as necessary. Peter recently fixed this, so the comment no longer applies. Also, since the size of struct mcontext changed, adjust the threads library version of get&set context to match. FYI, any change layout/size change to any arch's struct mcontext will likely need some minor changes in libpthread.
* Don't assume sizeof(long) = sizeof(int) on x86; use intdeischen2003-09-033-9/+34
| | | | | | | | | | | | 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
* Don't forget to set kcb_self.davidxu2003-08-121-0/+1
|
* Add alpha support to libpthread. It compiles but hasn't been tested;deischen2003-08-096-1/+761
| | | | | | there is still some missing kernel support. Reviewed by: marcel
* 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.
* 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-0513-466/+786
| | | | | | | | | 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
|
* Use FSBase to map kse, GCC generates code which uses %fs to access TLS data.davidxu2003-07-311-4/+4
| | | | Reminded by: marcel
* This file hasn't been used for some time; nuke it.deischen2003-07-311-42/+0
|
* Take the same approach for i386 as that for ia64 and amd64. Usedeischen2003-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
* Set GSBASE for kse. Finally make libkse work on AMD64.davidxu2003-07-311-6/+3
|
* Fix some typos, correctly jump into UTS.davidxu2003-07-311-2/+2
|
* Fix typo.davidxu2003-07-261-5/+5
|
* Add missing arguments to _amd64_restore_context() when called fromdeischen2003-07-201-2/+4
| | | | THR_SETCONTEXT().
* Add some very beta amd64 bits. These will also need some tweaking.deischen2003-07-196-0/+528
|
* Clean up KSE specific data (KSD) macros a bit.deischen2003-07-181-29/+8
| | | | Reviewed by: davidxu
* 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.
* Untangle the inter-dependency of kse types and ksd types/functionsmarcel2003-06-236-14/+111
| | | | | | | | | | | | | | | | | | | 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-4/+4
| | | | | | | | | _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.
* Remove _atomic_lock. It's not used.marcel2003-06-232-93/+0
|
* Move the machine specific files from sys/Makefile.inc and put themmarcel2003-06-233-0/+15
| | | | | in a machine specific makefile. While here, sort the sub-directories in Makefile and remove _atomic_lock.S from all makefiles.
* Eek, staticize a couple of functions that shouldn'tdeischen2003-05-191-1/+3
| | | | | | | | | | | | 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)
* Move the mailbox to the beginning of the thread and align thedeischen2003-04-301-0/+3
| | | | thread so that the context (SSE FPU state) is also aligned.
* Jump to the correct label upon detecting an error.deischen2003-04-291-2/+2
|
* o Don't add a scope system thread's KSE to the list of availabledeischen2003-04-281-2/+4
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | KSEs when it's thread exits; allow the GC handler to do that. o Make spinlock/spinlock critical regions. The following were submitted by davidxu o Alow thr_switch() to take a null mailbox argument. o Better protect cancellation checks. o Don't set KSE specific data when creating new KSEs; rely on the first upcall of the KSE to set it. o Add the ability to set the maximum concurrency level and do this automatically. We should have a way to enable/disable this with some sort of tunable because some applications may not want this to be the default. o Hold the scheduling lock across thread switch calls. o If scheduling of a thread fails, make sure to remove it from the list of active threads. o Better protect accesses to a joining threads when the target thread is exited and detached. o Remove some macro definitions that are now provided by <sys/kse.h>. o Don't leave the library in threaded mode if creation of the initial KSE fails. o Wakeup idle KSEs when there are threads ready to run. o Maintain the number of threads active in the priority queue.
* Add a macro to get the current thread mailbox pointer.deischen2003-04-231-0/+1
|
* Use popfl to get the flags off the stack instead of popf.deischen2003-04-211-1/+1
| | | | Submitted by: davidxu
* Sorry folks; I accidentally committed a patch from what I was workingdeischen2003-04-185-15/+12
| | | | | | on a couple of days ago. This should be the most recent changes. Noticed by: davidxu
* Add architecture dependent atomic ops (atomic_swap only), KSE specificdeischen2003-04-187-10/+602
| | | | | | | data, and userland versions of [gs]etcontext(). Modify the UTS entry and exit functions to account of FPU validity and format.
* Directly load %edx from mailboxdavidxu2002-11-231-4/+3
|
* In _thread_enter_uts, fix eflags saving bug.davidxu2002-11-222-7/+15
| | | | | | | | In _thread_switch, set current thread pointer in kse mailbox only after all registers copied out of thread mailbox, kernel will do upcall at trap time, if set current thread pointer before loading all registers from thread mailbox, at trap time, the thread mailbox data will be overwritten by kernel, result is junk data is loaded into CPU.
* Adjust code for new mailbox format.davidxu2002-11-181-3/+3
| | | | Reviewed by: deischen, mini
* Use KSE to schedule threads.mini2002-10-302-0/+185
|
* Add an ia64 atomic lock primitive for libc_r. This is mostly forpeter2002-07-201-0/+48
| | | | | | | | | | completeness and doesn't get us a working libc_r there because libc_r uses setjmp() and setjmp() cannot be used for context switches on ia64 as-is (or sparc64). Rather than making setjmp/longjmp behave like the *context() calls, it would be far better to make libc_r use *context() directly which is what they are for. Obtained from: marcel
* Change #include "DEFS.h" to <machine/asm.h>.peter2001-10-251-1/+1
|
* Removed duplicate VCS ID tags, as per style(9).ru2001-08-131-3/+0
|
* $Id$ -> $FreeBSD$peter1999-08-282-3/+3
|
* Change to a code sequence which is more likely to work on SMP systems.dfr1998-09-161-20/+8
| | | | Now all I need is an alpha SMP box to port FreeBSD to :-)
* Delete the atomic unlock function since it is no longer required.jb1998-06-091-15/+5
| | | | | Simplify the atomic lock to just write a value of 1 to the lock instead of taking the value passed by the caller (which just confused things).
OpenPOWER on IntegriCloud