summaryrefslogtreecommitdiffstats
path: root/sys/kern/kern_kse.c
Commit message (Collapse)AuthorAgeFilesLines
* unlock sched_lock at right time.davidxu2003-04-271-1/+1
|
* Add an argument to get_mcontext() which specified whether thedeischen2003-04-251-15/+1
| | | | | | | | | | | | | | | | | | | | syscall return values should be cleared. The system calls getcontext() and swapcontext() want to return 0 on success but these contexts can be switched to at a later time so the return values need to be cleared in the saved register sets. Other callers of get_mcontext() would normally want the context without clearing the return values. Remove the i386-specific context saving from the KSE code. get_mcontext() is not i386-specific any more. Fix a bad pointer in the alpha get_mcontext() code. The context was being bcopy()'d from &td->tf_frame, but tf_frame is itself a pointer, so the thread was being copied instead. Spotted by jake. Glanced at by: jake Reviewed by: bde (months ago)
* - Protect p_numthreads with the sched_lock.jhb2003-04-231-13/+14
| | | | | - Protect p_singlethread with both the sched_lock and the proc lock. - Protect p_suspcount with the proc lock.
* - Mark the kse_purge_group() and kse_purge() definitions static to matchjhb2003-04-221-5/+3
| | | | | | | their prototypes. - Remove sched_lock locking from kse_purge() as all callers already lock the sched_lock before calling it. - Hold the proc lock slightly longer to protect P_SHOULDSTOP().
* Fix lock order reversal problem.davidxu2003-04-211-3/+2
|
* Introduce two flags to control upcall behaviour:davidxu2003-04-211-51/+36
| | | | | | | | | | | | | | | | | | | o KMF_NOUPCALL Ask kse_release to not return to userland upcall entry, but instead direct returns to userland by using current thread's stack and return address on stack. This flags is intended to be used by UTS in critical region to wait another UTS thread to leave critical region, by using kse_release with this flag to avoid spinnng and burning CPU. Also this flags can be used by UTS to poll completed context when there is nothing to do in userland and needn't restart from its entry like normal upcall. o KMF_NOCOMPLETED Ask kernel to not bring completed thread contexts back to userland when doing upcall, this flags is intend to be used with above flag when an upcall thread is in critical region and can not process completed contexts at that time. Tested by: deischen
* Test next upcall time correctly.davidxu2003-04-191-1/+1
|
* Use correct thread pointer.davidxu2003-04-191-1/+1
|
* Use the proc lock to protect p_singlethread and a P_WEXIT test. Thisjhb2003-04-181-2/+2
| | | | | fixes a couple of potential KSE panics on non-i386 arch's that weren't holding the proc lock when calling thread_exit().
* Add a thread_unlink() and use it.julian2003-04-181-11/+14
| | | | | It could also be used twice in kern_thr.c but that's owned by jeff so I'l let him change it when he's next there.
* Protect td_sigmask with the proc lock.jhb2003-04-171-0/+2
|
* Move the _oncpu entry from the KSE to the thread.julian2003-04-101-0/+1
| | | | | The entry in the KSE still exists but it's purpose will change a bit when we add the ability to lock a KSE to a cpu.
* Inherit blocked thread's context for upcall thread.davidxu2003-04-081-7/+5
|
* Commit a partial lazy thread switch mechanism for i386. it isn't as lazypeter2003-04-021-0/+6
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | as it could be and can do with some more cleanup. Currently its under options LAZY_SWITCH. What this does is avoid %cr3 reloads for short context switches that do not involve another user process. ie: we can take an interrupt, switch to a kthread and return to the user without explicitly flushing the tlb. However, this isn't as exciting as it could be, the interrupt overhead is still high and too much blocks on Giant still. There are some debug sysctls, for stats and for an on/off switch. The main problem with doing this has been "what if the process that you're running on exits while we're borrowing its address space?" - in this case we use an IPI to give it a kick when we're about to reclaim the pmap. Its not compiled in unless you add the LAZY_SWITCH option. I want to fix a few more things and get some more feedback before turning it on by default. This is NOT a replacement for Bosko's lazy interrupt stuff. This was more meant for the kthread case, while his was for interrupts. Mine helps a little for interrupts, but his helps a lot more. The stats are enabled with options SWTCH_OPTIM_STATS - this has been a pseudo-option for years, I just added a bunch of stuff to it. One non-trivial change was to select a new thread before calling cpu_switch() in the first place. This allows us to catch the silly case of doing a cpu_switch() to the current process. This happens uncomfortably often. This simplifies a bit of the asm code in cpu_switch (no longer have to call choosethread() in the middle). This has been implemented on i386 and (thanks to jake) sparc64. The others will come soon. This is actually seperate to the lazy switch stuff. Glanced at by: jake, jhb
* - Borrow the KSE single threading code for exec and exit. We use the checkjeff2003-04-011-3/+7
| | | | | | | | if (p->p_numthreads > 1) and not a flag because action is only necessary if there are other threads. The rest of the system has no need to identify thr threaded processes. - In kern_thread.c use thr_exit1() instead of thread_exit() if P_THREADED is not set.
* - Move p->p_sigmask to td->td_sigmask. Signal masks will be per thread withjeff2003-03-311-4/+11
| | | | | | | a follow on commit to kern_sig.c - signotify() now operates on a thread since unmasked pending signals are stored in the thread. - PS_NEEDSIGCHK moves to TDF_NEEDSIGCHK.
* Check for the PS_NEEDSIGCHK flag in the right flags field.jhb2003-03-281-1/+1
|
* Adjust code for userland preemptive. Userland can set a quantum indavidxu2003-03-191-24/+45
| | | | | | | | | | kse_mailbox to schedule an upcall, this is useful for userland timeout routine, for example pthread_cond_timedwait(). Also extract upcall scheduling code from kse_reassign and create a new function called thread_switchout to include these code. Reviewed by: julain
* Export current time when returning from never blocked syscall.davidxu2003-03-141-1/+8
|
* Lock proc lock before changing p_flag.davidxu2003-03-111-0/+2
|
* Fix signal delivering bug for threaded process.davidxu2003-03-111-6/+4
|
* Fix threaded process job control bug. SMP tested.davidxu2003-03-111-28/+16
| | | | Reviewed by: julian
* Lock sched_lock before modifying td_flags.davidxu2003-03-081-0/+2
|
* Check kse group limit before linking new ksegrp.davidxu2003-02-281-2/+2
|
* Release sched_lock before calling upcall_free.davidxu2003-02-271-1/+1
|
* Change the process flags P_KSES to be P_THREADED.julian2003-02-271-5/+5
| | | | This is just a cosmetic change but I've been meaning to do it for about a year.
* Add a missing '!'.davidxu2003-02-261-2/+2
|
* Add a simple facility to allow round roubin in userland.davidxu2003-02-261-41/+45
| | | | Reviewed by: julain
* Remove a bogus comment.davidxu2003-02-251-6/+0
|
* Remove a XXXKSE. kg_completed now needs proc lock.davidxu2003-02-241-1/+0
|
* Backout last surplus commit. That day just wasn't my day.davidxu2003-02-241-5/+0
|
* If UTS kernel is calling kse_wakeup for itself, do nothing.davidxu2003-02-211-3/+6
|
* Forgot to set KU_DOUPCALL in kse_wakeup.davidxu2003-02-201-0/+1
|
* Add a timeout parameter to kse_release.davidxu2003-02-201-11/+27
|
* Move thread limits testing code up a bit. This let UPCALLING threaddavidxu2003-02-201-26/+27
| | | | takes possible accumulated contexts away.
* Count non-threaded group.davidxu2003-02-191-5/+10
|
* M_WAITOK and remove an useless comment.davidxu2003-02-191-2/+1
|
* Back out M_* changes, per decision of the TRB.imp2003-02-191-3/+3
| | | | Approved by: trb
* Optimize the case when max threads number was hit.davidxu2003-02-191-43/+57
|
* Further fix PS_NEEDSIGCHKdavidxu2003-02-171-0/+2
|
* Move code for detecting PS_NEEDSIGCHK into thread_schedule_upcall,davidxu2003-02-171-0/+2
| | | | I think it is a better place to handle it.
* - Add a new function, thread_signal_add(), that is called from postsig tojeff2003-02-171-28/+34
| | | | | | | | add a signal to a mailbox's pending set. - Add a new function, thread_signal_upcall(), this causes the current thread to upcall so that we can deliver pending signals. Reviewed by: mini
* Move a bunch of flags from the KSE to the thread.julian2003-02-171-4/+1
| | | | | | | | I was in two minds as to where to put them in the first case.. I should have listenned to the other mind. Submitted by: parts by davidxu@ Reviewed by: jeff@ mini@
* - Split the struct kse into struct upcall and struct kse. struct kse willjeff2003-02-171-515/+649
| | | | | | | soon be visible only to schedulers. This greatly simplifies much the KSE code. Submitted by: davidxu
* Reversion of commit by Davidxu plus fixes since applied.julian2003-02-011-648/+515
| | | | | | | | I'm not convinced there is anything major wrong with the patch but them's the rules.. I am using my "David's mentor" hat to revert this as he's offline for a while.
* Only add one tick per tick to the thread stats, instead of some random number.julian2003-01-311-2/+2
|
* Use kg_numupcalls to see if we are closing a thread group,davidxu2003-01-261-2/+2
| | | | not kg_kses which is not changed when a group is still working.
* Move UPCALL related data structure out of kse, introduce a newdavidxu2003-01-261-513/+646
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | data structure called kse_upcall to manage UPCALL. All KSE binding and loaning code are gone. A thread owns an upcall can collect all completed syscall contexts in its ksegrp, turn itself into UPCALL mode, and takes those contexts back to userland. Any thread without upcall structure has to export their contexts and exit at user boundary. Any thread running in user mode owns an upcall structure, when it enters kernel, if the kse mailbox's current thread pointer is not NULL, then when the thread is blocked in kernel, a new UPCALL thread is created and the upcall structure is transfered to the new UPCALL thread. if the kse mailbox's current thread pointer is NULL, then when a thread is blocked in kernel, no UPCALL thread will be created. Each upcall always has an owner thread. Userland can remove an upcall by calling kse_exit, when all upcalls in ksegrp are removed, the group is atomatically shutdown. An upcall owner thread also exits when process is in exiting state. when an owner thread exits, the upcall it owns is also removed. KSE is a pure scheduler entity. it represents a virtual cpu. when a thread is running, it always has a KSE associated with it. scheduler is free to assign a KSE to thread according thread priority, if thread priority is changed, KSE can be moved from one thread to another. When a ksegrp is created, there is always N KSEs created in the group. the N is the number of physical cpu in the current system. This makes it is possible that even an userland UTS is single CPU safe, threads in kernel still can execute on different cpu in parallel. Userland calls kse_create to add more upcall structures into ksegrp to increase concurrent in userland itself, kernel is not restricted by number of upcalls userland provides. The code hasn't been tested under SMP by author due to lack of hardware. Reviewed by: julian
* Remove M_TRYWAIT/M_WAITOK/M_WAIT. Callers should use 0.alfred2003-01-211-3/+3
| | | | Merge M_NOWAIT/M_DONTWAIT into a single flag M_NOWAIT.
* Remove a KASSERT that can now happen and add a missing setrunnable.julian2003-01-201-0/+2
|
OpenPOWER on IntegriCloud