summaryrefslogtreecommitdiffstats
path: root/sys/kern/kern_thread.c
Commit message (Collapse)AuthorAgeFilesLines
* iBack out david's last commit. the suspension code needs to be calledjulian2002-10-261-12/+0
| | | | for non KSE processes too.
* Move suspension checking code from userret() into thread_userret().davidxu2002-10-261-0/+12
|
* Backout revision 1.48.davidxu2002-10-261-2/+1
|
* suspend thread only when it can be interrupted.davidxu2002-10-251-1/+2
|
* let thread_schedule_upcall() handle idle kse.davidxu2002-10-251-2/+8
|
* fix style-ojulian2002-10-251-1/+1
|
* More work on the interaction between suspending and sleeping threads.julian2002-10-251-12/+26
| | | | | | Also clean up some code used with 'single-threading'. Reviewed by: davidxu
* fix typo.davidxu2002-10-251-1/+2
|
* Extract out KSE specific code from machine specific codejulian2002-10-241-0/+47
| | | | | | | | so that there is ony one copy of it. Fix that one copy so that KSEs with no mailbox in a KSE program are not a cause of page faults (this can legitmatly happen). Submitted by: (parts) davidxu
* respect TDF_SINTR, also for SINGLE_NO_EXIT threading mode, if a threaddavidxu2002-10-241-6/+6
| | | | was already suspended, do nothing.
* don't forget to remove kse from idle queue.davidxu2002-10-241-0/+2
|
* Move thread related code from kern_proc.c to kern_thread.c.julian2002-10-241-28/+500
| | | | | | | | | | Add code to free KSEs and KSEGRPs on exit. Sort KSE prototypes in proc.h. Add the missing kse_exit() syscall. ksetest now does not leak KSEs and KSEGRPS. Submitted by: (parts) davidxu
* Round out the facilty for a 'bound' thread to loan out its KSEjulian2002-10-091-169/+264
| | | | | | | | | | | | | | | | | | | | | | | | in specific situations. The owner thread must be blocked, and the borrower can not proceed back to user space with the borrowed KSE. The borrower will return the KSE on the next context switch where teh owner wants it back. This removes a lot of possible race conditions and deadlocks. It is consceivable that the borrower should inherit the priority of the owner too. that's another discussion and would be simple to do. Also, as part of this, the "preallocatd spare thread" is attached to the thread doing a syscall rather than the KSE. This removes the need to lock the scheduler when we want to access it, as it's now "at hand". DDB now shows a lot mor info for threaded proceses though it may need some optimisation to squeeze it all back into 80 chars again. (possible JKH project) Upcalls are now "bound" threads, but "KSE Lending" now means that other completing syscalls can be completed using that KSE before the upcall finally makes it back to the UTS. (getting threads OUT OF THE KERNEL is one of the highest priorities in the KSE system.) The upcall when it happens will present all the completed syscalls to the KSE for selection.
* Put an easy-to-miss assignment into the proper place. It was stray in thejmallett2002-10-051-2/+4
| | | | | middle of a block of code, with no clear assignment. While here, move one nearby assignment out of declaration.
* Remove bogus duplicate assignment of local variables.jmallett2002-10-051-2/+2
|
* Add some unspeakable hackery to the tree under #ifdef __ia64__ to workpeter2002-10-041-0/+14
| | | | | | | | around limitations in the ia64 kernel stack handling code. Basically preallocate a bunch of threads (and hence kstacks) while contigmalloc() still works, and never free them back to the general memory pool. After the system has been running for a while, contigmalloc() eventually fails at a critical momemt and panics the system.
* Some kernel threads try to do significant work, and the default KSTACK_PAGESscottl2002-10-021-1/+1
| | | | | | | | | | | | | doesn't give them enough stack to do much before blowing away the pcb. This adds MI and MD code to allow the allocation of an alternate kstack who's size can be speficied when calling kthread_create. Passing the value 0 prevents the alternate kstack from being created. Note that the ia64 MD code is missing for now, and PowerPC was only partially written due to the pmap.c being incomplete there. Though this patch does not modify anything to make use of the alternate kstack, acpi and usb are good candidates. Reviewed by: jake, peter, jhb
* Implement basic KSE loaning. This stops a hread that is blocked in BOUND modejulian2002-09-291-0/+9
| | | | | | | | | from stopping another thread from completing a syscall, and this allows it to release its resources etc. Probably more related commits to follow (at least one I know of) Initial concept by: julian, dillon Submitted by: davidxu
* lock proc while calling psignaljulian2002-09-291-9/+17
| | | | | | (plus related cleanups) Submitted by: davidxu
* Redo how completing threads pass their state to userlandjulian2002-09-271-81/+121
| | | | | | | if they are not going to cross over themselves. Also change how the list of completed user threads is tracked and passed to the KSE. This is not a change in design but rather the implementation of what was originally envisionned.
* Make the following name changes to KSE related functions, etc., to betterarchie2002-09-251-3/+3
| | | | | | | | | | | | | | | represent their purpose and minimize namespace conflicts: kse_fn_t -> kse_func_t struct thread_mailbox -> struct kse_thr_mailbox thread_interrupt() -> kse_thr_interrupt() kse_yield() -> kse_release() kse_new() -> kse_create() Add missing declaration of kse_thr_interrupt() to <sys/kse.h>. Regenerate the various generated syscall files. Minor style fixes. Reviewed by: julian
* Don't use local variable 'p' in a debug statement.. we removed it.julian2002-09-231-1/+1
|
* slightly clean up the thread_userret() and thread_consider_upcall() calls.julian2002-09-231-12/+24
| | | | | | | also some slight changes for TDF_BOUND testing and small style changes Should ONLY affect KSE programs Submitted by: davidxu
* Argh. I've been reading makefiles for too long. Change comment to apeter2002-09-171-4/+8
| | | | C-style comment.
* Stub out the calls to get_mcontext and set_mcontext which only exist onpeter2002-09-171-0/+10
| | | | | i386. This stuff should not be prototyped in MD inludes if the interface is expected to be MI.
* Add kernel support needed for the KSE-aware libpthread:mini2002-09-161-118/+233
| | | | | | | | | | | | - Use ucontext_t's to store KSE thread state. - Synthesize state for the UTS upon each upcall, rather than saving and copying a trapframe. - Deliver signals to KSE-aware processes via upcall. - Rename kse mailbox structure fields to be more BSD-like. - Store the UTS's stack in struct proc in a stack_t. Reviewed by: bde, deischen, julian Approved by: -arch
* Allocate KSEs and KSEGRPs separatly and remove them from the proc structure.julian2002-09-151-25/+51
| | | | | | | | | next step is to allow > 1 to be allocated per process. This would give multi-processor threads. (when the rest of the infrastructure is in place) While doing this I noticed libkvm and sys/kern/kern_proc.c:fill_kinfo_proc are diverging more than they should.. corrective action needed soon.
* Apparently something down in the guts of vm/uvm still needs giantjulian2002-09-141-0/+2
| | | | Obtained from: mini via P4 KSE tree.
* Completely redo thread states.julian2002-09-111-56/+39
| | | | Reviewed by: davidxu@freebsd.org
* fix braino..julian2002-09-071-1/+1
| | | | was clearing part of wrong thread structure..
* fix misplaced schedlockjulian2002-09-071-1/+1
| | | | Submitted by: davidxu@freebsd.org
* Use UMA as a complex object allocator.julian2002-09-061-42/+46
| | | | | | | | | | | | | | | The process allocator now caches and hands out complete process structures *including substructures* . i.e. it get's the process structure with the first thread (and soon KSE) already allocated and attached, all in one hit. For the average non threaded program (non KSE that is) the allocated thread and its stack remain attached to the process, even when the process is unused and in the process cache. This saves having to allocate and attach it later, effectively bringing us (hopefully) close to the efficiency of pre-KSE systems where these were a single structure. Reviewed by: davidxu@freebsd.org, peter@freebsd.org
* s/SGNL/SIG/davidxu2002-09-051-11/+11
| | | | | | | | | | s/SNGL/SINGLE/ s/SNGLE/SINGLE/ Fix abbreviation for P_STOPPED_* etc flags, in original code they were inconsistent and difficult to distinguish between them. Approved by: julian (mentor)
* In the kernel code, we have the tsleep() call with the PCATCH argument.davidxu2002-09-031-6/+32
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | PCATCH means 'if we get a signal, interrupt me!" and tsleep returns either EINTR or ERESTART depending on the circumstances. ERESTART is "special" because it causes the system call to fail, but right as it returns back to userland it tells the trap handler to move %eip back a bit so that userland will immediately re-run the syscall. This is a syscall restart. It only works for things like read() etc where nothing has changed yet. Note that *userland* is tricked into restarting the syscall by the kernel. The kernel doesn't actually do the restart. It is deadly for things like select, poll, nanosleep etc where it might cause the elapsed time to be reset and start again from scratch. So those syscalls do this to prevent userland rerunning the syscall: if (error == ERESTART) error = EINTR; Fake "signals" like SIGTSTP from ^Z etc do not normally invoke userland signal handlers. But, in -current, the PCATCH *is* being triggered and tsleep is returning ERESTART, and the syscall is aborted even though no userland signal handler was run. That is the fault here. We're triggering the PCATCH in cases that we shouldn't. ie: it is being triggered on *any* signal processing, rather than the case where the signal is posted to userland. --- Peter The work of psignal() is a patchwork of special case required by the process debugging and job-control facilities... --- Kirk McKusick "The design and impelementation of the 4.4BSD Operating system" Page 105 in STABLE source, when psignal is posting a STOP signal to sleeping process and the signal action of the process is SIG_DFL, system will directly change the process state from SSLEEP to SSTOP, and when SIGCONT is posted to the stopped process, if it finds that the process is still on sleep queue, the process state will be restored to SSLEEP, and won't wakeup the process. this commit mimics the behaviour in STABLE source tree. Reviewed by: Jon Mini, Tim Robbins, Peter Wemm Approved by: julian@freebsd.org (mentor)
* Fix crack-smoking code that was panicing on the quad xeon:julian2002-08-291-26/+23
| | | | | | | | | | | | - If either of proc or kse are NULL during thread_exit(), then the kernel is going to fault because parts of the function assume they aren't NULL. Instead, just assert they aren't NULL (as well as the kse group) and assume they are in all of the code. It doesn't make sense for them to be NULL here anyways. - Move the PROC_UNLOCK(p) up above clearing td_proc, etc. since otherwise we will panic if the proc's lock is contested. Submitted by: jhb@freebsd.org
* slight cleanup of single-threading code for KSE processesjulian2002-08-221-1/+16
|
* Revert some suspension/sleep/signal code from KSE-IIIjulian2002-08-211-0/+11
| | | | | | | | | We need to rethink a bit of this and it doesn't matter if we break the KSE test program for now as long as non-KSE programs act as expected. Submitted by: David Xu <bsddiy@yahoo.com> (this guy's just asking to get hit with a commit bit..)
* Fix a comment.julian2002-08-011-1/+1
|
* get suspension counting right.julian2002-07-251-0/+4
| | | | | | fix an error message Submitted by: David Xu <bsddiy@yahoo.com>
* fix some style problems and remove a mis-merged assert.julian2002-07-251-30/+12
|
* Add some locking asserts and some commentsjulian2002-07-241-0/+4
|
* When single threading a multithreaded program, awaken thejulian2002-07-241-0/+7
| | | | | | | | | 'single threading thread' when the last other thread suspends. I had this code in there before but it seems to have been accidentally deleted somewhere along the way. This would only affect multithreaded processes. Reviewed by: David Xu <bsddiy@yahoo.com>
* When suspending a thread, update the appropriate (sic) statistic.julian2002-07-241-0/+1
|
* ia64 does not have the same degree of stealth include file nesting,peter2002-07-171-0/+2
| | | | | | so it needs an explicit #include <machine/frame.h> to get 'struct trapframe'. The fact that it needs this at this level is rather bogus but it will not compile without it.
* Pacify gcc on ia64peter2002-07-171-0/+3
|
* Thinking about it I came to the conclusion that the KSE states were incorrectlyjulian2002-07-141-3/+0
| | | | | | | | | | | | | | formulated. The correct states should be: IDLE: On the idle KSE list for that KSEG RUNQ: Linked onto the system run queue. THREAD: Attached to a thread and slaved to whatever state the thread is in. This means that most places where we were adjusting kse state can go away as it is just moving around because the thread is.. The only places we need to adjust the KSE state is in transition to and from the idle and run queues. Reviewed by: jhb@freebsd.org
* Collect all the (now equivalent) pmap_new_proc/pmap_dispose_proc/peter2002-07-071-0/+10
| | | | | | | | | | | | | pmap_swapin_proc/pmap_swapout_proc functions from the MD pmap code and use a single equivalent MI version. There are other cleanups needed still. While here, use the UMA zone hooks to keep a cache of preinitialized proc structures handy, just like the thread system does. This eliminates one dependency on 'struct proc' being persistent even after being freed. There are some comments about things that can be factored out into ctor/dtor functions if it is worth it. For now they are mostly just doing statistics to get a feel of how it is working.
* Make this compile on 64 bit platformspeter2002-07-071-4/+4
|
* - In thread_userret(), remove the Giant locking and unlocking around thearr2002-07-011-2/+0
| | | | | | | call to thread_alloc(). Approved by: julian Reviewed by: jake, jeff
* Add files that are new for KSE.julian2002-06-291-0/+790
OpenPOWER on IntegriCloud